提交 18a85209 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 bfa69ccc
......@@ -40,10 +40,11 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3>
<h3>Version 1.0.60 (2007-10-?)</h3><ul>
<li>PreparedStatement.setMaxRows could not be changed to a higher value after the statement was executed.
<li>Prepared statements could not be used after data definition statements (creating tables and so on). Fixed.
</li><li>PreparedStatement.setMaxRows could not be changed to a higher value after the statement was executed.
</li><li>The H2 Console could not connect twice to the same H2 embedded database at the same time. Fixed.
</li><li>CSVREAD, RUNSCRIPT and so on now support URLs as well, using
URL.openStream(). Example: select * from csvread('jar:file:///c:/temp/test.jar!/test.csv');
URL.openStream(). Example: select * from csvread('jar:file:///c:/temp/test.jar!/test.csv');
</li></ul>
<h3>Version 1.0.59 (2007-10-03)</h3><ul>
......
......@@ -93,7 +93,7 @@ public class Constants {
public static final int DEFAULT_SERVER_PORT = 9092; // this is also in the docs
public static final String START_URL = "jdbc:h2:";
public static final String URL_FORMAT = START_URL + "{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]";
public static final String PRODUCT_NAME = "H2";
public static final String PRODUCT_NAME = "H2"; // must stay like that (http://opensource.atlassian.com/projects/hibernate/browse/HHH-2682)
public static final String DRIVER_NAME = "H2 JDBC Driver";
public static final int IO_BUFFER_SIZE = 4 * 1024;
public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024;
......
......@@ -69,7 +69,7 @@ public class CompareLike extends Condition {
if (left.getType() == Value.STRING_IGNORECASE) {
ignoreCase = true;
}
if (left.isConstant()) {
if (left.isValueSet()) {
Value l = left.getValue(session);
if (l == ValueNull.INSTANCE) {
// NULL LIKE something > NULL
......@@ -79,8 +79,8 @@ public class CompareLike extends Condition {
if (escape != null) {
escape = escape.optimize(session);
}
if (right.isConstant() && (escape == null || escape.isConstant())) {
if (left.isConstant()) {
if (right.isValueSet() && (escape == null || escape.isValueSet())) {
if (left.isValueSet()) {
return ValueExpression.get(getValue(session));
}
Value r = right.getValue(session);
......@@ -130,10 +130,10 @@ public class CompareLike extends Condition {
// otherwise we would need to prepare at execute time,
// which is maybe slower (but maybe not in this case!)
// TODO optimizer: like: check what other databases do!
if (!right.isConstant()) {
if (!right.isValueSet()) {
return;
}
if (escape != null && !escape.isConstant()) {
if (escape != null && !escape.isValueSet()) {
return;
}
String p = right.getValue(session).getString();
......
......@@ -47,6 +47,10 @@ public abstract class Expression {
return false;
}
public boolean isValueSet() {
return false;
}
public boolean isAutoIncrement() {
return false;
}
......
......@@ -70,6 +70,10 @@ public class Parameter extends Expression implements ParameterInterface {
}
public boolean isConstant() {
return false;
}
public boolean isValueSet() {
return value != null;
}
......
......@@ -62,6 +62,10 @@ public class ValueExpression extends Expression {
public boolean isConstant() {
return true;
}
public boolean isValueSet() {
return true;
}
public void setEvaluatable(TableFilter tableFilter, boolean b) {
}
......
......@@ -28,6 +28,7 @@ public class TestPreparedStatement extends TestBase {
deleteDb("preparedStatement");
Connection conn = getConnection("preparedStatement");
testPrepareRecompile(conn);
testMaxRowsChange(conn);
testUnknownDataType(conn);
testCancelReuse(conn);
......@@ -52,6 +53,41 @@ public class TestPreparedStatement extends TestBase {
conn.close();
}
private void testPrepareRecompile(Connection conn) throws Exception {
Statement stat = conn.createStatement();
PreparedStatement prep;
ResultSet rs;
prep = conn.prepareStatement("SELECT COUNT(*) FROM DUAL WHERE ? IS NULL");
prep.setString(1, null);
prep.executeQuery();
stat.execute("CREATE TABLE TEST(ID INT)");
stat.execute("DROP TABLE TEST");
prep.setString(1, null);
prep.executeQuery();
prep.setString(1, "X");
rs = prep.executeQuery();
rs.next();
check(rs.getInt(1), 0);
stat.execute("CREATE TABLE t1 (c1 INT, c2 VARCHAR(10))");
stat.execute("INSERT INTO t1 SELECT X, CONCAT('Test', X) FROM SYSTEM_RANGE(1, 5);");
prep = conn.prepareStatement("SELECT c1, c2 FROM t1 WHERE c1 = ?");
prep.setInt(1, 1);
prep.executeQuery();
stat.execute("CREATE TABLE t2 (x int PRIMARY KEY)");
prep.setInt(1, 2);
rs = prep.executeQuery();
rs.next();
check(rs.getInt(1), 2);
prep.setInt(1, 3);
rs = prep.executeQuery();
rs.next();
check(rs.getInt(1), 3);
stat.execute("DROP TABLE t1, t2");
}
private void testMaxRowsChange(Connection conn) throws Exception {
PreparedStatement prep = conn.prepareStatement("SELECT * FROM SYSTEM_RANGE(1, 100)");
ResultSet rs;
......
......@@ -509,4 +509,5 @@ imports bnot severity colon braces suppress star bxor band bor unary bsr puppy l
forge chr trunc gabealbert tunebackup manifest
lumber thus taking repositories ago delegated mention leaks pgsql seeded felt efficiently mill mentioned forgot leaked restarted clearing occupies randomness warn implementing abstraction
spfile svr pkey synced semicolon terminating
framework constructing architectural jmatter workgroup upgraded naked stopper skipping
\ No newline at end of file
framework constructing architectural jmatter workgroup upgraded naked stopper skipping assumed
opensource atlassian hhh
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论