提交 3bfd6df7 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 21d886ed
...@@ -17,7 +17,15 @@ Change Log ...@@ -17,7 +17,15 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>- <li>Infinite numbers in SQL script are listed as POWER(0, -1)), negative
infinite as (-POWER(0, -1)), and NaN (not a number) as SQRT(-1).
</li><li>Comparison did not work correctly when using the special
double and float value 'NaN' (not a number).
</li><li>SET QUERY_TIMEOUT and Statement.setQueryTimeout no longer commits
a transaction. The same applies to SET @VARIABLE, SET LOCK_TIMEOUT,
SET TRACE_LEVEL_*, SET THROTTLE, and SET PATH.
</li><li>ParameterMetaData now also returns the right data type for most
conditions, as in WHERE ID=?.
</li></ul> </li></ul>
<h2>Version 1.0.72 (2008-05-10)</h2> <h2>Version 1.0.72 (2008-05-10)</h2>
......
...@@ -86,7 +86,8 @@ Features ...@@ -86,7 +86,8 @@ Features
</li><li>Supports standard SQL, JDBC API </li><li>Supports standard SQL, JDBC API
</li><li>Embedded and Server mode, Clustering support </li><li>Embedded and Server mode, Clustering support
</li><li>Strong security features </li><li>Strong security features
</li><li>Experimental native version (GCJ) and ODBC drivers </li><li>The PostgreSQL ODBC driver can be used
</li><li>Multi version concurrency
</li></ul> </li></ul>
<h3>Additional Features</h3> <h3>Additional Features</h3>
...@@ -127,7 +128,7 @@ Features ...@@ -127,7 +128,7 @@ Features
<h3>Other Features and Tools</h3> <h3>Other Features and Tools</h3>
<ul> <ul>
<li>Small footprint (smaller than 1 MB), low memory requirements <li>Small footprint (smaller than 1 MB), low memory requirements
</li><li>Multiple index types (b-tree, tree, hash, linear hash) </li><li>Multiple index types (b-tree, tree, hash)
</li><li>Support for multi-dimensional indexes </li><li>Support for multi-dimensional indexes
</li><li>CSV (comma separated values) file support </li><li>CSV (comma separated values) file support
</li><li>Support for linked tables, and a built-in virtual 'range' table </li><li>Support for linked tables, and a built-in virtual 'range' table
...@@ -219,6 +220,13 @@ http://groups.google.com/group/h2-database/web/roadmap ...@@ -219,6 +220,13 @@ http://groups.google.com/group/h2-database/web/roadmap
<td class="compareN">No</td> <td class="compareN">No</td>
<td class="compareN">No</td> <td class="compareN">No</td>
</tr><tr> </tr><tr>
<td>Linked Tables</td>
<td class="compareY">Yes</td>
<td class="compareN">No</td>
<td class="compareY">Partially *1</td>
<td class="compareY">Partially *2</td>
<td class="compareN">No</td>
</tr><tr>
<td>ODBC Driver</td> <td>ODBC Driver</td>
<td class="compareY">Yes</td> <td class="compareY">Yes</td>
<td class="compareY">Yes?</td> <td class="compareY">Yes?</td>
...@@ -247,14 +255,84 @@ http://groups.google.com/group/h2-database/web/roadmap ...@@ -247,14 +255,84 @@ http://groups.google.com/group/h2-database/web/roadmap
<td class="compareN">Many</td> <td class="compareN">Many</td>
<td class="compareN">Many</td> <td class="compareN">Many</td>
</tr><tr> </tr><tr>
<td>Table Level Locking</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
<td class="compareN">No</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
</tr><tr>
<td>Row Level Locking</td>
<td class="compareN">No</td>
<td class="compareY">Yes</td>
<td class="compareN">No</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
</tr><tr>
<td>Multi Version Concurrency</td>
<td class="compareY">Yes</td>
<td class="compareN">No</td>
<td class="compareN">No</td>
<td class="compareN">No</td>
<td class="compareY">Yes</td>
</tr><tr>
<td>Role Based Security</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes *3</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
</tr><tr>
<td>Updatable Result Sets</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
<td class="compareN">No</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
</tr><tr>
<td>Sequences</td>
<td class="compareY">Yes</td>
<td class="compareN">No</td>
<td class="compareY">Yes</td>
<td class="compareN">No</td>
<td class="compareY">Yes</td>
</tr><tr>
<td>Limit and Offset</td>
<td class="compareY">Yes</td>
<td class="compareN">No</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
</tr><tr>
<td>Temporary Tables</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes *4</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
</tr><tr>
<td>Custom Aggregate Functions</td>
<td class="compareY">Yes</td>
<td class="compareN">No</td>
<td class="compareN">No</td>
<td class="compareY">Yes</td>
<td class="compareY">Yes</td>
</tr><tr>
<td>Footprint (jar/dll size)</td> <td>Footprint (jar/dll size)</td>
<td>~ 1 MB</td> <td>~1 MB *5</td>
<td>~ 2 MB</td> <td>~2 MB</td>
<td>~ 600 KB</td> <td>~600 KB</td>
<td>~ 4 MB</td> <td>~4 MB</td>
<td>~ 6 MB</td> <td>~6 MB</td>
</tr> </tr>
</table> </table>
<p>
*1 HSQLDB supports text tables.<br />
*2 MySQL supports linked MySQL tables under the name 'federated tables'.<br />
*3 Derby support for roles based security and password checking as an option.<br />
*4 Derby only supports global temporary tables.<br />
*5 The default H2 jar file contains debug information.
</p>
<h3>Derby and HSQLDB</h3> <h3>Derby and HSQLDB</h3>
<p> <p>
......
...@@ -358,6 +358,7 @@ Roadmap ...@@ -358,6 +358,7 @@ Roadmap
</li><li>Support getGeneratedKeys to return multiple rows when used with batch updates. </li><li>Support getGeneratedKeys to return multiple rows when used with batch updates.
This is supported by MySQL, but not Derby. Both PostgreSQL and HSQLDB don't support getGeneratedKeys. This is supported by MySQL, but not Derby. Both PostgreSQL and HSQLDB don't support getGeneratedKeys.
Also support it when using INSERT ... SELECT. Also support it when using INSERT ... SELECT.
</li><li>HSQLDB compatibility: automatic data type for SUM if value is the value is too big (by default use the same type as the data).
</li></ul> </li></ul>
<h2>Not Planned</h2> <h2>Not Planned</h2>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -31,7 +31,7 @@ public class JdbcArray extends TraceObject implements Array { ...@@ -31,7 +31,7 @@ public class JdbcArray extends TraceObject implements Array {
/** /**
* INTERNAL * INTERNAL
*/ */
public JdbcArray(SessionInterface session, JdbcConnection conn, Value value, int id) { JdbcArray(SessionInterface session, JdbcConnection conn, Value value, int id) {
setTrace(session.getTrace(), TraceObject.ARRAY, id); setTrace(session.getTrace(), TraceObject.ARRAY, id);
this.conn = conn; this.conn = conn;
this.value = value; this.value = value;
......
...@@ -21,7 +21,7 @@ public class JdbcBatchUpdateException extends BatchUpdateException { ...@@ -21,7 +21,7 @@ public class JdbcBatchUpdateException extends BatchUpdateException {
/** /**
* INTERNAL * INTERNAL
*/ */
public JdbcBatchUpdateException(SQLException next, int[] updateCounts) { JdbcBatchUpdateException(SQLException next, int[] updateCounts) {
super(next.getMessage(), next.getSQLState(), next.getErrorCode(), updateCounts); super(next.getMessage(), next.getSQLState(), next.getErrorCode(), updateCounts);
} }
......
...@@ -28,7 +28,7 @@ implements Savepoint ...@@ -28,7 +28,7 @@ implements Savepoint
//## Java 1.4 end ## //## Java 1.4 end ##
{ {
static final String SYSTEM_SAVEPOINT_PREFIX = "SYSTEM_SAVEPOINT_"; private static final String SYSTEM_SAVEPOINT_PREFIX = "SYSTEM_SAVEPOINT_";
private int savepointId; private int savepointId;
private String name; private String name;
......
...@@ -32,13 +32,13 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -32,13 +32,13 @@ public class JdbcStatement extends TraceObject implements Statement {
protected SessionInterface session; protected SessionInterface session;
protected JdbcResultSet resultSet; protected JdbcResultSet resultSet;
protected int maxRows; protected int maxRows;
protected boolean escapeProcessing = true;
protected int fetchSize = SysProperties.SERVER_RESULT_SET_FETCH_SIZE; protected int fetchSize = SysProperties.SERVER_RESULT_SET_FETCH_SIZE;
protected int updateCount; protected int updateCount;
private CommandInterface executingCommand;
private ObjectArray batchCommands;
protected int resultSetType; protected int resultSetType;
protected boolean closedByResultSet; protected boolean closedByResultSet;
private CommandInterface executingCommand;
private ObjectArray batchCommands;
private boolean escapeProcessing = true;
/** /**
* Executes a query (select statement) and returns the result set. * Executes a query (select statement) and returns the result set.
...@@ -538,7 +538,9 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -538,7 +538,9 @@ public class JdbcStatement extends TraceObject implements Statement {
/** /**
* Sets the current query timeout in seconds. Calling this method will * Sets the current query timeout in seconds. Calling this method will
* commit an open transaction, even if the value is the same as before. * commit an open transaction, even if the value is the same as before.
* Changing the value will affect all statements of this connection. * Changing the value will affect all statements of this connection. This
* method does not commit a transaction, and rolling back a transaction does
* not affect this setting.
* *
* @param seconds the timeout in seconds - 0 means no timeout, values * @param seconds the timeout in seconds - 0 means no timeout, values
* smaller 0 will throw an exception * smaller 0 will throw an exception
......
...@@ -736,6 +736,7 @@ SAVEPOINT HALF_DONE ...@@ -736,6 +736,7 @@ SAVEPOINT HALF_DONE
SET @variableName [=] expression SET @variableName [=] expression
"," ","
Updates a user-defined variable. Updates a user-defined variable.
This command does not commit a transaction, and rollback does not affect it.
"," ","
SET @TOTAL=0 SET @TOTAL=0
" "
...@@ -922,6 +923,7 @@ SET LOCK_TIMEOUT int ...@@ -922,6 +923,7 @@ SET LOCK_TIMEOUT int
"," ","
Sets the lock timeout (in milliseconds) for the current session. Sets the lock timeout (in milliseconds) for the current session.
The default value for this setting is 1000 (one second). The default value for this setting is 1000 (one second).
This command does not commit a transaction, and rollback does not affect it.
This setting can be appended to the database URL: jdbc:h2:test;LOCK_TIMEOUT=10000 This setting can be appended to the database URL: jdbc:h2:test;LOCK_TIMEOUT=10000
"," ","
SET LOCK_TIMEOUT 1000 SET LOCK_TIMEOUT 1000
...@@ -1051,6 +1053,7 @@ Set the query timeout of the current session to the given value. ...@@ -1051,6 +1053,7 @@ Set the query timeout of the current session to the given value.
The timeout is in milliseconds. All kinds of statements will The timeout is in milliseconds. All kinds of statements will
throw an exception if they take longer than the given value. throw an exception if they take longer than the given value.
The default timeout is 0, meaning no timeout. The default timeout is 0, meaning no timeout.
This command does not commit a transaction, and rollback does not affect it.
"," ","
SET QUERY_TIMEOUT 10000 SET QUERY_TIMEOUT 10000
" "
...@@ -1091,6 +1094,7 @@ SET SCHEMA schemaName ...@@ -1091,6 +1094,7 @@ SET SCHEMA schemaName
Changes the default schema of the current connection. Changes the default schema of the current connection.
The default schema is used in statements where no schema is set explicitly. The default schema is used in statements where no schema is set explicitly.
The default schema for new connections is PUBLIC. The default schema for new connections is PUBLIC.
This command does not commit a transaction, and rollback does not affect it.
This setting can be appended to the database URL: jdbc:h2:test;SCHEMA=ABC This setting can be appended to the database URL: jdbc:h2:test;SCHEMA=ABC
"," ","
SET SCHEMA INFORMATION_SCHEMA SET SCHEMA INFORMATION_SCHEMA
...@@ -1102,6 +1106,7 @@ SET THROTTLE int ...@@ -1102,6 +1106,7 @@ SET THROTTLE int
Sets the throttle for the current connection. Sets the throttle for the current connection.
The value is the number of milliseconds delay after each 50 ms. The value is the number of milliseconds delay after each 50 ms.
The default value is 0 (throttling disabled). The default value is 0 (throttling disabled).
This command does not commit a transaction, and rollback does not affect it.
This setting can be appended to the database URL: jdbc:h2:test;THROTTLE=50 This setting can be appended to the database URL: jdbc:h2:test;THROTTLE=50
"," ","
SET THROTTLE 200 SET THROTTLE 200
...@@ -1114,6 +1119,7 @@ Sets the trace level for file the file or system out stream. ...@@ -1114,6 +1119,7 @@ Sets the trace level for file the file or system out stream.
Levels are: 0=off, 1=error, 2=info, 3=debug. Levels are: 0=off, 1=error, 2=info, 3=debug.
This setting is not persistent. This setting is not persistent.
Admin rights are required to execute this command. Admin rights are required to execute this command.
This command does not commit a transaction, and rollback does not affect it.
This setting can be appended to the database URL: jdbc:h2:test;TRACE_LEVEL_SYSTEM_OUT=3 This setting can be appended to the database URL: jdbc:h2:test;TRACE_LEVEL_SYSTEM_OUT=3
To use SLF4J, append ;TRACE_LEVEL_FILE=4 to the database URL when opening the database. To use SLF4J, append ;TRACE_LEVEL_FILE=4 to the database URL when opening the database.
"," ","
......
...@@ -160,19 +160,41 @@ java org.h2.test.TestAll timer ...@@ -160,19 +160,41 @@ java org.h2.test.TestAll timer
/* /*
-- Wildcard schema bug: MySQL:
create schema a; CREATE TABLE user (
create table a.x(ax int); id int(25) NOT NULL auto_increment,
create schema b; name varchar(25) NOT NULL,
create table b.x(bx int); PRIMARY KEY (id,name)
select * from a.x, b.x; )
I've created a linked table to an oracle database, and tried:
create table person as select * from ora_person
This gives me:
Invalid value -127 for parameter scale [90008-71] 90008/90008
Doing a column-by-column select, I get the exception when I try to
create table as select one of the NUMBER fields with unspecified
lengths.
Here's a simpler example:
create table t as select sysadmin from ora_person;
(sysadmin is a NUMBER column)
This works:
create table t as select cast(sysadmin as int) sysadmin from
ora_person
But, it's clunky. Is this something that can be fixed in a future
version?
download PostgreSQL docs
BIT_AND, BIT_OR, BIT_XOR
SOME, EVERY: HSQLDB compatibility
add tests for SOME, EVERY (SOME is used in Parser.java
for something else; test this; maybe use BOOL_AND / BOOL_OR)
document SOME, EVERY
in help.csv, use complete examples for functions; add a test case in help.csv, use complete examples for functions; add a test case
upload and test javadoc/index.html upload and test javadoc/index.html
Test Bnf.COMBINE_KEYWORDS
improve javadocs improve javadocs
write complete page right after checkpoint write complete page right after checkpoint
......
...@@ -24,11 +24,33 @@ import org.h2.test.TestBase; ...@@ -24,11 +24,33 @@ import org.h2.test.TestBase;
public class TestTransaction extends TestBase { public class TestTransaction extends TestBase {
public void test() throws Exception { public void test() throws Exception {
testSetTransaction();
testReferential(); testReferential();
testSavepoint(); testSavepoint();
testIsolation(); testIsolation();
} }
private void testSetTransaction() throws Exception {
deleteDb("transaction");
Connection conn = getConnection("transaction");
conn.setAutoCommit(false);
Statement stat = conn.createStatement();
stat.execute("create table test(id int)");
stat.execute("insert into test values(1)");
stat.execute("set @x = 1");
conn.commit();
checkSingleValue(stat, "select id from test", 1);
checkSingleValue(stat, "call @x", 1);
stat.execute("update test set id=2");
stat.execute("set @x = 2");
conn.rollback();
checkSingleValue(stat, "select id from test", 1);
checkSingleValue(stat, "call @x", 2);
conn.close();
}
private void testReferential() throws Exception { private void testReferential() throws Exception {
deleteDb("transaction"); deleteDb("transaction");
Connection c1 = getConnection("transaction"); Connection c1 = getConnection("transaction");
......
...@@ -10,6 +10,7 @@ import java.sql.Connection; ...@@ -10,6 +10,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Savepoint;
import java.sql.Statement; import java.sql.Statement;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
...@@ -53,6 +54,7 @@ public class TestCancel extends TestBase { ...@@ -53,6 +54,7 @@ public class TestCancel extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testQueryTimeoutInTransaction();
testReset(); testReset();
testMaxQueryTimeout(); testMaxQueryTimeout();
testQueryTimeout(); testQueryTimeout();
...@@ -76,6 +78,21 @@ public class TestCancel extends TestBase { ...@@ -76,6 +78,21 @@ public class TestCancel extends TestBase {
conn.close(); conn.close();
} }
private void testQueryTimeoutInTransaction() throws Exception {
deleteDb("cancel");
Connection conn = getConnection("cancel");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT)");
conn.setAutoCommit(false);
stat.execute("INSERT INTO TEST VALUES(1)");
Savepoint sp = conn.setSavepoint();
stat.execute("INSERT INTO TEST VALUES(2)");
stat.setQueryTimeout(1);
conn.rollback(sp);
conn.commit();
conn.close();
}
private void testJdbcQueryTimeout() throws Exception { private void testJdbcQueryTimeout() throws Exception {
deleteDb("cancel"); deleteDb("cancel");
Connection conn = getConnection("cancel"); Connection conn = getConnection("cancel");
......
...@@ -415,6 +415,10 @@ public class TestPreparedStatement extends TestBase { ...@@ -415,6 +415,10 @@ public class TestPreparedStatement extends TestBase {
checkParameter(prep2, 1, "java.lang.Integer", 4, "INTEGER", 10, 0); checkParameter(prep2, 1, "java.lang.Integer", 4, "INTEGER", 10, 0);
checkParameter(prep2, 2, "java.lang.String", 12, "VARCHAR", 255, 0); checkParameter(prep2, 2, "java.lang.String", 12, "VARCHAR", 255, 0);
checkParameter(prep2, 3, "java.math.BigDecimal", 3, "DECIMAL", 10, 2); checkParameter(prep2, 3, "java.math.BigDecimal", 3, "DECIMAL", 10, 2);
PreparedStatement prep3 = conn.prepareStatement("SELECT * FROM TEST3 WHERE ID=? AND NAME LIKE ? AND ?>DATA");
checkParameter(prep3, 1, "java.lang.Integer", 4, "INTEGER", 10, 0);
checkParameter(prep3, 2, "java.lang.String", 12, "VARCHAR", 0, 0);
checkParameter(prep3, 3, "java.math.BigDecimal", 3, "DECIMAL", 10, 2);
stat.execute("DROP TABLE TEST3"); stat.execute("DROP TABLE TEST3");
} }
......
--- special grammar and test cases --------------------------------------------------------------------------------------------- --- special grammar and test cases ---------------------------------------------------------------------------------------------
CREATE MEMORY TABLE TEST(ID INT, D DOUBLE, F FLOAT);
> ok
insert into test values(0, POWER(0, -1), POWER(0, -1)), (1, -POWER(0, -1), -POWER(0, -1)), (2, SQRT(-1), SQRT(-1));
> update count: 3
select * from test order by id;
> ID D F
> -- --------- ---------
> 0 Infinity Infinity
> 1 -Infinity -Infinity
> 2 NaN NaN
> rows (ordered): 3
script nopasswords nosettings;
> SCRIPT
> -----------------------------------------------------------------------------------------------------------------------------------------
> -- 3 = SELECT COUNT(*) FROM PUBLIC.TEST;
> CREATE MEMORY TABLE PUBLIC.TEST( ID INT, D DOUBLE, F FLOAT );
> CREATE USER IF NOT EXISTS SA PASSWORD '' ADMIN;
> INSERT INTO PUBLIC.TEST(ID, D, F) VALUES (0, POWER(0, -1), POWER(0, -1)), (1, (-POWER(0, -1)), (-POWER(0, -1))), (2, SQRT(-1), SQRT(-1));
> rows: 4
DROP TABLE TEST;
> ok
create schema a;
> ok
create table a.x(ax int);
> ok
create schema b;
> ok
create table b.x(bx int);
> ok
select * from a.x, b.x;
> AX BX
> -- --
> rows: 0
drop schema a;
> ok
drop schema b;
> ok
create table t1 (id int primary key); create table t1 (id int primary key);
> ok > ok
...@@ -5353,8 +5402,8 @@ SELECT * FROM V_UNION WHERE ID=1; ...@@ -5353,8 +5402,8 @@ SELECT * FROM V_UNION WHERE ID=1;
EXPLAIN SELECT * FROM V_UNION WHERE ID=1; EXPLAIN SELECT * FROM V_UNION WHERE ID=1;
> PLAN > PLAN
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT V_UNION.ID, V_UNION.NAME, V_UNION.CLASS FROM PUBLIC.V_UNION /* (SELECT CHILDREN.ID, CHILDREN.NAME, CHILDREN.CLASS FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = CAST(?1 AS INTEGER) ++/ WHERE CHILDREN.ID = CAST(?1 AS INTEGER)) UNION ALL (SELECT CHILDREN.ID, CHILDREN.NAME, CHILDREN.CLASS FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = CAST(?1 AS INTEGER) ++/ WHERE CHILDREN.ID = CAST(?1 AS INTEGER)): ID = 1 */ WHERE ID = 1 > SELECT V_UNION.ID, V_UNION.NAME, V_UNION.CLASS FROM PUBLIC.V_UNION /* (SELECT CHILDREN.ID, CHILDREN.NAME, CHILDREN.CLASS FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = ?1 ++/ WHERE CHILDREN.ID = ?1) UNION ALL (SELECT CHILDREN.ID, CHILDREN.NAME, CHILDREN.CLASS FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = ?1 ++/ WHERE CHILDREN.ID = ?1): ID = 1 */ WHERE ID = 1
> rows: 1 > rows: 1
CREATE VIEW V_EXCEPT AS SELECT * FROM CHILDREN EXCEPT SELECT * FROM CHILDREN WHERE ID=2; CREATE VIEW V_EXCEPT AS SELECT * FROM CHILDREN EXCEPT SELECT * FROM CHILDREN WHERE ID=2;
...@@ -5368,8 +5417,8 @@ SELECT * FROM V_EXCEPT WHERE ID=1; ...@@ -5368,8 +5417,8 @@ SELECT * FROM V_EXCEPT WHERE ID=1;
EXPLAIN SELECT * FROM V_EXCEPT WHERE ID=1; EXPLAIN SELECT * FROM V_EXCEPT WHERE ID=1;
> PLAN > PLAN
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT V_EXCEPT.ID, V_EXCEPT.NAME, V_EXCEPT.CLASS FROM PUBLIC.V_EXCEPT /* (SELECT CHILDREN.ID, CHILDREN.NAME, CHILDREN.CLASS FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = CAST(?1 AS INTEGER) ++/ WHERE CHILDREN.ID = CAST(?1 AS INTEGER)) EXCEPT (SELECT CHILDREN.ID, CHILDREN.NAME, CHILDREN.CLASS FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = 2 ++/ WHERE ID = 2): ID = 1 */ WHERE ID = 1 > SELECT V_EXCEPT.ID, V_EXCEPT.NAME, V_EXCEPT.CLASS FROM PUBLIC.V_EXCEPT /* (SELECT CHILDREN.ID, CHILDREN.NAME, CHILDREN.CLASS FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = ?1 ++/ WHERE CHILDREN.ID = ?1) EXCEPT (SELECT CHILDREN.ID, CHILDREN.NAME, CHILDREN.CLASS FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = 2 ++/ WHERE ID = 2): ID = 1 */ WHERE ID = 1
> rows: 1 > rows: 1
CREATE VIEW V_INTERSECT AS SELECT ID, NAME FROM CHILDREN INTERSECT SELECT * FROM CLASSES; CREATE VIEW V_INTERSECT AS SELECT ID, NAME FROM CHILDREN INTERSECT SELECT * FROM CLASSES;
...@@ -5382,8 +5431,8 @@ SELECT * FROM V_INTERSECT WHERE ID=1; ...@@ -5382,8 +5431,8 @@ SELECT * FROM V_INTERSECT WHERE ID=1;
EXPLAIN SELECT * FROM V_INTERSECT WHERE ID=1; EXPLAIN SELECT * FROM V_INTERSECT WHERE ID=1;
> PLAN > PLAN
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT V_INTERSECT.ID, V_INTERSECT.NAME FROM PUBLIC.V_INTERSECT /* (SELECT ID, NAME FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = CAST(?1 AS INTEGER) ++/ WHERE ID = CAST(?1 AS INTEGER)) INTERSECT (SELECT CLASSES.ID, CLASSES.NAME FROM PUBLIC.CLASSES /++ PUBLIC.PRIMARY_KEY_5: ID = CAST(?1 AS INTEGER) ++/ WHERE CLASSES.ID = CAST(?1 AS INTEGER)): ID = 1 */ WHERE ID = 1 > SELECT V_INTERSECT.ID, V_INTERSECT.NAME FROM PUBLIC.V_INTERSECT /* (SELECT ID, NAME FROM PUBLIC.CHILDREN /++ PUBLIC.PRIMARY_KEY_9: ID = ?1 ++/ WHERE ID = ?1) INTERSECT (SELECT CLASSES.ID, CLASSES.NAME FROM PUBLIC.CLASSES /++ PUBLIC.PRIMARY_KEY_5: ID = ?1 ++/ WHERE CLASSES.ID = ?1): ID = 1 */ WHERE ID = 1
> rows: 1 > rows: 1
DROP VIEW V_UNION; DROP VIEW V_UNION;
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
package org.h2.test.unit; package org.h2.test.unit;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.value.Value;
import org.h2.value.ValueDouble;
import org.h2.value.ValueFloat;
import org.h2.value.ValueUuid; import org.h2.value.ValueUuid;
/** /**
...@@ -16,6 +19,32 @@ public class TestValue extends TestBase { ...@@ -16,6 +19,32 @@ public class TestValue extends TestBase {
public void test() throws Exception { public void test() throws Exception {
testUUID(); testUUID();
testDouble(false);
testDouble(true);
}
private void testDouble(boolean useFloat) throws Exception {
double[] d = new double[]{
Double.NEGATIVE_INFINITY,
-1,
0,
1,
Double.POSITIVE_INFINITY,
Double.NaN
};
Value[] values = new Value[d.length];
for (int i = 0; i < d.length; i++) {
Value v = useFloat ? (Value) ValueFloat.get((float) d[i]) : (Value) ValueDouble.get(d[i]);
values[i] = v;
check(values[i].compareTypeSave(values[i], null) == 0);
check(v.equals(v));
check(i < 2 ? -1 : i > 2 ? 1 : 0, v.getSignum());
}
for (int i = 0; i < d.length - 1; i++) {
check(values[i].compareTypeSave(values[i+1], null) < 0);
check(values[i + 1].compareTypeSave(values[i], null) > 0);
check(!values[i].equals(values[i+1]));
}
} }
private void testUUID() throws Exception { private void testUUID() throws Exception {
......
...@@ -510,4 +510,5 @@ dieguez dfile mvn dversion dgroup dpackaging dartifact durl dpom pom ...@@ -510,4 +510,5 @@ dieguez dfile mvn dversion dgroup dpackaging dartifact durl dpom pom
subpackages slowed deactivate throttled noindex expired arizona export subpackages slowed deactivate throttled noindex expired arizona export
intentional knowing jcl plug facade deployment logback confusion visited intentional knowing jcl plug facade deployment logback confusion visited
pickle associate subtraction negation multiplication visitors sharp connector pickle associate subtraction negation multiplication visitors sharp connector
derbynet ado happy derbyclient derbynet ado happy derbyclient unspecified federated sysadmin lengths doing
gives clunky
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论