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

--no commit message

--no commit message
上级 bfa69ccc
...@@ -40,7 +40,8 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -40,7 +40,8 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3> <h3>Version 1.0 (Current)</h3>
<h3>Version 1.0.60 (2007-10-?)</h3><ul> <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>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 </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');
......
...@@ -93,7 +93,7 @@ public class Constants { ...@@ -93,7 +93,7 @@ public class Constants {
public static final int DEFAULT_SERVER_PORT = 9092; // this is also in the docs 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 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 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 String DRIVER_NAME = "H2 JDBC Driver";
public static final int IO_BUFFER_SIZE = 4 * 1024; public static final int IO_BUFFER_SIZE = 4 * 1024;
public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024; public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024;
......
...@@ -69,7 +69,7 @@ public class CompareLike extends Condition { ...@@ -69,7 +69,7 @@ public class CompareLike extends Condition {
if (left.getType() == Value.STRING_IGNORECASE) { if (left.getType() == Value.STRING_IGNORECASE) {
ignoreCase = true; ignoreCase = true;
} }
if (left.isConstant()) { if (left.isValueSet()) {
Value l = left.getValue(session); Value l = left.getValue(session);
if (l == ValueNull.INSTANCE) { if (l == ValueNull.INSTANCE) {
// NULL LIKE something > NULL // NULL LIKE something > NULL
...@@ -79,8 +79,8 @@ public class CompareLike extends Condition { ...@@ -79,8 +79,8 @@ public class CompareLike extends Condition {
if (escape != null) { if (escape != null) {
escape = escape.optimize(session); escape = escape.optimize(session);
} }
if (right.isConstant() && (escape == null || escape.isConstant())) { if (right.isValueSet() && (escape == null || escape.isValueSet())) {
if (left.isConstant()) { if (left.isValueSet()) {
return ValueExpression.get(getValue(session)); return ValueExpression.get(getValue(session));
} }
Value r = right.getValue(session); Value r = right.getValue(session);
...@@ -130,10 +130,10 @@ public class CompareLike extends Condition { ...@@ -130,10 +130,10 @@ public class CompareLike extends Condition {
// otherwise we would need to prepare at execute time, // otherwise we would need to prepare at execute time,
// which is maybe slower (but maybe not in this case!) // which is maybe slower (but maybe not in this case!)
// TODO optimizer: like: check what other databases do! // TODO optimizer: like: check what other databases do!
if (!right.isConstant()) { if (!right.isValueSet()) {
return; return;
} }
if (escape != null && !escape.isConstant()) { if (escape != null && !escape.isValueSet()) {
return; return;
} }
String p = right.getValue(session).getString(); String p = right.getValue(session).getString();
......
...@@ -47,6 +47,10 @@ public abstract class Expression { ...@@ -47,6 +47,10 @@ public abstract class Expression {
return false; return false;
} }
public boolean isValueSet() {
return false;
}
public boolean isAutoIncrement() { public boolean isAutoIncrement() {
return false; return false;
} }
......
...@@ -70,6 +70,10 @@ public class Parameter extends Expression implements ParameterInterface { ...@@ -70,6 +70,10 @@ public class Parameter extends Expression implements ParameterInterface {
} }
public boolean isConstant() { public boolean isConstant() {
return false;
}
public boolean isValueSet() {
return value != null; return value != null;
} }
......
...@@ -63,6 +63,10 @@ public class ValueExpression extends Expression { ...@@ -63,6 +63,10 @@ public class ValueExpression extends Expression {
return true; return true;
} }
public boolean isValueSet() {
return true;
}
public void setEvaluatable(TableFilter tableFilter, boolean b) { public void setEvaluatable(TableFilter tableFilter, boolean b) {
} }
......
...@@ -28,6 +28,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -28,6 +28,7 @@ public class TestPreparedStatement extends TestBase {
deleteDb("preparedStatement"); deleteDb("preparedStatement");
Connection conn = getConnection("preparedStatement"); Connection conn = getConnection("preparedStatement");
testPrepareRecompile(conn);
testMaxRowsChange(conn); testMaxRowsChange(conn);
testUnknownDataType(conn); testUnknownDataType(conn);
testCancelReuse(conn); testCancelReuse(conn);
...@@ -52,6 +53,41 @@ public class TestPreparedStatement extends TestBase { ...@@ -52,6 +53,41 @@ public class TestPreparedStatement extends TestBase {
conn.close(); 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 { private void testMaxRowsChange(Connection conn) throws Exception {
PreparedStatement prep = conn.prepareStatement("SELECT * FROM SYSTEM_RANGE(1, 100)"); PreparedStatement prep = conn.prepareStatement("SELECT * FROM SYSTEM_RANGE(1, 100)");
ResultSet rs; ResultSet rs;
......
...@@ -509,4 +509,5 @@ imports bnot severity colon braces suppress star bxor band bor unary bsr puppy l ...@@ -509,4 +509,5 @@ imports bnot severity colon braces suppress star bxor band bor unary bsr puppy l
forge chr trunc gabealbert tunebackup manifest 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 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 spfile svr pkey synced semicolon terminating
framework constructing architectural jmatter workgroup upgraded naked stopper skipping framework constructing architectural jmatter workgroup upgraded naked stopper skipping assumed
\ No newline at end of file opensource atlassian hhh
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论