提交 54827992 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 25f0a14a
......@@ -18,7 +18,12 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>H2 Console: Oracle system tables are no longer listed, improving performance.
<ul><li>PG Server: new system property h2.pgClientEncoding to explicitly set the encoding
for clients that don't send the encoding (the default encoding is UTF-8).
Thanks a lot to Sergi Vladykin for the patch!
</li><li>PG Server: improved compatibility by using the type ids of the PostgreSQL driver.
Thanks a lot to Sergi Vladykin for the patch!
</li><li>H2 Console: Oracle system tables are no longer listed, improving performance.
</li><li>Result sets are now read-only except if the statement or prepared statement was created
with the concurrency ResultSet.CONCUR_UPDATABLE. This change is required because the old behavior
(all result set are updatable) violated the JDBC spec. For backward compatibility, use the
......
......@@ -428,7 +428,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Oracle compatibility: support DECODE(x, ...).
</li><li>Console: Start Browser: if ip number changed, try localhost instead.
</li><li>MVCC: compare concurrent update behavior with PostgreSQL and Oracle.
</li><li>HSQLDB compatibility: CREATE FUNCTION (maybe using a Function interface).
</li><li>HSQLDB compatibility: CREATE FUNCTION (maybe using a Function interface).
</li><li>HSQLDB compatibility: support CALL "java.lang.Math.sqrt"(2.0)
</li></ul>
......
......@@ -156,6 +156,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
*
* @param id the page id
* @param leaf the leaf page
* @param offset the offset in bytes
* @return the page
*/
PageDataLeafOverflow getPageOverflow(int id, PageDataLeaf leaf, int offset) throws SQLException {
......
......@@ -33,7 +33,7 @@ public class TestCluster extends TestBase {
}
public void test() throws SQLException {
if (config.memory || config.networked) {
if (config.memory || config.networked || config.cipher != null) {
return;
}
deleteFiles();
......@@ -43,7 +43,8 @@ public class TestCluster extends TestBase {
org.h2.Driver.load();
String urlNode1 = getURL("node1/test", true);
String urlNode2 = getURL("node2/test", true);
conn = DriverManager.getConnection(urlNode1, "sa", "");
String user = getUser(), password = getPassword();
conn = DriverManager.getConnection(urlNode1, user, password);
Statement stat;
stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST");
......@@ -59,7 +60,7 @@ public class TestCluster extends TestBase {
conn.close();
CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget",
urlNode2, "-user", "sa", "-serverList",
urlNode2, "-user", user, "-password", password, "-serverList",
"localhost:9191,localhost:9192" });
Server n1 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start();
......@@ -67,47 +68,47 @@ public class TestCluster extends TestBase {
new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start();
try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test", "sa", "");
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test", user, password);
fail("should not be able to connect in standalone mode");
} catch (SQLException e) {
assertKnownException(e);
}
try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", "");
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", user, password);
fail("should not be able to connect in standalone mode");
} catch (SQLException e) {
assertKnownException(e);
}
// test regular cluster connection
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", "sa", "");
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
check(conn, len);
conn.close();
// test if only one server is available at the beginning
n2.stop();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", "sa", "");
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
stat = conn.createStatement();
check(conn, len);
conn.close();
// disable the cluster
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", "sa", "");
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", user, password);
conn.close();
n1.stop();
// re-create the cluster
DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node2", "-quiet" });
CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget",
urlNode2, "-user", "sa", "-serverList",
urlNode2, "-user", user, "-password", password, "-serverList",
"localhost:9191,localhost:9192" });
n1 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start();
n2 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", "sa", "");
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
stat = conn.createStatement();
stat.execute("CREATE TABLE BOTH(ID INT)");
......@@ -119,14 +120,14 @@ public class TestCluster extends TestBase {
n1 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" })
.start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", "sa", "");
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", user, password);
check(conn, len);
conn.close();
n1.stop();
n2 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" })
.start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test;CLUSTER=''", "sa", "");
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test;CLUSTER=''", user, password);
check(conn, len);
conn.createStatement().execute("SELECT * FROM A");
conn.close();
......
......@@ -234,6 +234,10 @@ public class TestLinkedTable extends TestBase {
}
private void testLinkEmitUpdates() throws SQLException {
if (config.memory || config.networked) {
return;
}
deleteDb("linked1");
deleteDb("linked2");
org.h2.Driver.load();
......@@ -241,16 +245,16 @@ public class TestLinkedTable extends TestBase {
String url1 = getURL("linked1", true);
String url2 = getURL("linked2", true);
Connection conn = DriverManager.getConnection(url1, "sa1", "abc");
Connection conn = DriverManager.getConnection(url1, "sa1", "abc abc");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
Connection conn2 = DriverManager.getConnection(url2, "sa2", "def");
Connection conn2 = DriverManager.getConnection(url2, "sa2", "def def");
Statement stat2 = conn2.createStatement();
String link = "CREATE LINKED TABLE TEST_LINK_U('', '" + url1
+ "', 'sa1', 'abc', 'TEST') EMIT UPDATES";
+ "', 'sa1', 'abc abc', 'TEST') EMIT UPDATES";
stat2.execute(link);
link = "CREATE LINKED TABLE TEST_LINK_DI('', '" + url1 + "', 'sa1', 'abc', 'TEST')";
link = "CREATE LINKED TABLE TEST_LINK_DI('', '" + url1 + "', 'sa1', 'abc abc', 'TEST')";
stat2.execute(link);
stat2.executeUpdate("INSERT INTO TEST_LINK_U VALUES(1, 'Hello')");
stat2.executeUpdate("INSERT INTO TEST_LINK_DI VALUES(2, 'World')");
......@@ -296,19 +300,23 @@ public class TestLinkedTable extends TestBase {
}
private void testLinkSchema() throws SQLException {
if (config.memory || config.networked) {
return;
}
deleteDb("linked1");
deleteDb("linked2");
org.h2.Driver.load();
String url1 = getURL("linked1", true);
String url2 = getURL("linked2", true);
Connection conn = DriverManager.getConnection(url1, "sa1", "abc");
Connection conn = DriverManager.getConnection(url1, "sa1", "abc abc");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST1(ID INT PRIMARY KEY)");
Connection conn2 = DriverManager.getConnection(url2, "sa2", "def");
Connection conn2 = DriverManager.getConnection(url2, "sa2", "def def");
Statement stat2 = conn2.createStatement();
String link = "CALL LINK_SCHEMA('LINKED', '', '" + url1 + "', 'sa1', 'abc', 'PUBLIC')";
String link = "CALL LINK_SCHEMA('LINKED', '', '" + url1 + "', 'sa1', 'abc abc', 'PUBLIC')";
stat2.execute(link);
stat2.executeQuery("SELECT * FROM LINKED.TEST1");
......@@ -322,6 +330,10 @@ public class TestLinkedTable extends TestBase {
}
private void testLinkTable() throws SQLException {
if (config.memory || config.networked) {
return;
}
deleteDb("linked1");
deleteDb("linked2");
org.h2.Driver.load();
......@@ -329,7 +341,7 @@ public class TestLinkedTable extends TestBase {
String url1 = getURL("linked1", true);
String url2 = getURL("linked2", true);
Connection conn = DriverManager.getConnection(url1, "sa1", "abc");
Connection conn = DriverManager.getConnection(url1, "sa1", "abc abc");
Statement stat = conn.createStatement();
stat.execute("CREATE TEMP TABLE TEST_TEMP(ID INT PRIMARY KEY)");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(200), XT TINYINT, XD DECIMAL(10,2), XTS TIMESTAMP, XBY BINARY(255), XBO BIT, XSM SMALLINT, XBI BIGINT, XBL BLOB, XDA DATE, XTI TIME, XCL CLOB, XDO DOUBLE)");
......@@ -342,7 +354,7 @@ public class TestLinkedTable extends TestBase {
stat.execute("SELECT * FROM TEST_TEMP");
conn.close();
conn = DriverManager.getConnection(url1, "sa1", "abc");
conn = DriverManager.getConnection(url1, "sa1", "abc abc");
stat = conn.createStatement();
testRow(stat, "TEST");
try {
......@@ -353,12 +365,12 @@ public class TestLinkedTable extends TestBase {
}
conn.close();
conn = DriverManager.getConnection(url2, "sa2", "def");
conn = DriverManager.getConnection(url2, "sa2", "def def");
stat = conn.createStatement();
stat.execute("CREATE LINKED TABLE IF NOT EXISTS LINK_TEST('org.h2.Driver', '" + url1
+ "', 'sa1', 'abc', 'TEST')");
+ "', 'sa1', 'abc abc', 'TEST')");
stat.execute("CREATE LINKED TABLE IF NOT EXISTS LINK_TEST('org.h2.Driver', '" + url1
+ "', 'sa1', 'abc', 'TEST')");
+ "', 'sa1', 'abc abc', 'TEST')");
testRow(stat, "LINK_TEST");
ResultSet rs = stat.executeQuery("SELECT * FROM LINK_TEST");
ResultSetMetaData meta = rs.getMetaData();
......@@ -366,7 +378,7 @@ public class TestLinkedTable extends TestBase {
assertEquals(200, meta.getPrecision(2));
conn.close();
conn = DriverManager.getConnection(url2, "sa2", "def");
conn = DriverManager.getConnection(url2, "sa2", "def def");
stat = conn.createStatement();
stat.execute("INSERT INTO LINK_TEST VALUES(3, 'Link Test', 30, 100.05, '2005-12-31 12:34:56.789', X'FFEECC33', FALSE, 1, -1234567890123456789, X'4455FF', DATE '9999-12-31', TIME '23:59:59', 'George', -2.5)");
......@@ -412,7 +424,7 @@ public class TestLinkedTable extends TestBase {
stat.execute("DROP TABLE LINK_TEST");
stat.execute("CREATE LINKED TABLE LINK_TEST('org.h2.Driver', '" + url1
+ "', 'sa1', 'abc', '(SELECT COUNT(*) FROM TEST)')");
+ "', 'sa1', 'abc abc', '(SELECT COUNT(*) FROM TEST)')");
rs = stat.executeQuery("SELECT * FROM LINK_TEST");
rs.next();
assertEquals(rs.getInt(1), 3);
......
......@@ -60,6 +60,10 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
}
private void testBackup() throws SQLException {
if (config.memory || config.logMode == 0) {
return;
}
deleteDb("openClose");
String url = getURL("openClose", true);
org.h2.Driver.load();
......@@ -82,10 +86,15 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
}
private void testReconnectFast() throws SQLException {
if (config.memory) {
return;
}
deleteDb("openClose");
String user = getUser(), password = getPassword();
String url = getURL("openClose;DATABASE_EVENT_LISTENER='" + TestOpenClose.class.getName()
+ "'", true);
Connection conn = DriverManager.getConnection(url, "sa", "sa");
Connection conn = DriverManager.getConnection(url, user, password);
Statement stat = conn.createStatement();
try {
stat.execute("CREATE TABLE TEST(ID IDENTITY, NAME VARCHAR)");
......@@ -97,7 +106,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
}
stat.close();
conn.close();
conn = DriverManager.getConnection(url, "sa", "sa");
conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM DUAL");
if (rs.next()) {
......@@ -106,7 +115,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
rs.close();
stat.close();
conn.close();
conn = DriverManager.getConnection(url, "sa", "sa");
conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement();
// stat.execute("SET DB_CLOSE_DELAY 0");
stat.executeUpdate("SHUTDOWN");
......@@ -115,10 +124,15 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
}
private void testCase() throws Exception {
if (config.memory) {
return;
}
org.h2.Driver.load();
deleteDb("openClose");
final String url = getURL("openClose;FILE_LOCK=NO", true);
Connection conn = DriverManager.getConnection(url, "sa", "");
final String user = getUser(), password = getPassword();
Connection conn = DriverManager.getConnection(url, user, password);
conn.createStatement().execute("drop table employee if exists");
conn.createStatement().execute("create table employee(id int primary key, name varchar, salary int)");
conn.close();
......@@ -128,7 +142,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
threads[i] = new Thread() {
public void run() {
try {
Connection conn = DriverManager.getConnection(url, "sa", "");
Connection conn = DriverManager.getConnection(url, user, password);
PreparedStatement prep = conn.prepareStatement("insert into employee values(?, ?, 0)");
int id = getNextId();
prep.setInt(1, id);
......@@ -148,7 +162,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
for (int i = 0; i < len; i++) {
threads[i].join();
}
conn = DriverManager.getConnection(url, "sa", "");
conn = DriverManager.getConnection(url, user, password);
ResultSet rs = conn.createStatement().executeQuery("select count(*) from employee");
rs.next();
assertEquals(rs.getInt(1), len);
......
......@@ -58,6 +58,8 @@ public class TestDataSource extends TestBase {
deleteDb("dataSource");
JdbcDataSource ds = new JdbcDataSource();
ds.setURL(getURL("dataSource", true));
ds.setUser(getUser());
ds.setPassword(getPassword());
XAConnection xaConn = ds.getXAConnection();
xaConn.addConnectionEventListener(new ConnectionEventListener() {
public void connectionClosed(ConnectionEvent event) {
......@@ -82,7 +84,8 @@ public class TestDataSource extends TestBase {
deleteDb("dataSource");
JdbcDataSource ds = new JdbcDataSource();
ds.setURL(getURL("dataSource", true));
ds.setUser("sa");
ds.setUser(getUser());
ds.setPassword(getPassword());
Connection conn = ds.getConnection();
Statement stat = conn.createStatement();
stat.execute("SELECT * FROM DUAL");
......
......@@ -38,12 +38,12 @@ public class TestXASimple extends TestBase {
// context.rebind(USER_TRANSACTION_JNDI_NAME, j.getUserTransaction());
JdbcDataSource ds1 = new JdbcDataSource();
ds1.setPassword("");
ds1.setPassword(getPassword());
ds1.setUser("sa");
ds1.setURL(getURL("xaSimple1", true));
JdbcDataSource ds2 = new JdbcDataSource();
ds2.setPassword("");
ds2.setPassword(getPassword());
ds2.setUser("sa");
ds2.setURL(getURL("xaSimple2", true));
......
......@@ -591,4 +591,5 @@ relocating smtps smtp osde joist catching guesses delimiters shortlist sheet
rowspan cheat partitioning datepart dreamsource toussi locates fred
longnvarchar collate localdb nan bootclasspath bcp retrotranslator iterable
ops jopr googlegroups fletcher prefer djava expires fffe polish articles
attachment transiently cleanup
\ No newline at end of file
attachment transiently cleanup dbsnmp olapsys wmsys tsmsys outln ctxsys mddata
ordsys ordplugins mgmt dmsys exfsys mdsys sysman informtn textarray tmzone
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论