提交 7de9aac9 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 6541cb14
...@@ -22,8 +22,8 @@ public class CsvSample { ...@@ -22,8 +22,8 @@ public class CsvSample {
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addColumn("EMAIL", Types.VARCHAR, 255, 0); rs.addColumn("EMAIL", Types.VARCHAR, 255, 0);
rs.addColumn("PHONE", Types.VARCHAR, 255, 0); rs.addColumn("PHONE", Types.VARCHAR, 255, 0);
rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.fgh", "+41123456789" }); rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.abc", "+41123456789" });
rs.addRow(new String[] { "John Jones", "johnjones@abcde.fgh", "+41976543210" }); rs.addRow(new String[] { "John Jones", "john.jones@abcde.abc", "+41976543210" });
Csv.getInstance().write("data/test.csv", rs, null); Csv.getInstance().write("data/test.csv", rs, null);
} }
......
...@@ -29,7 +29,7 @@ INSERT INTO ITEM VALUES(20, ...@@ -29,7 +29,7 @@ INSERT INTO ITEM VALUES(20,
<li>Fixed a problem where data in the log file was not written to the data file <li>Fixed a problem where data in the log file was not written to the data file
(recovery failure) after a crash, if an index was deleted previously. (recovery failure) after a crash, if an index was deleted previously.
<li>Setting the collation (SET COLLATOR) was very slow on some systems (up to 24 seconds). <li>Setting the collation (SET COLLATOR) was very slow on some systems (up to 24 seconds).
<li>Selecting a column using the syntax schemaName.tableName.columName did not work in all cases. <li>Selecting a column using the syntax schemaName.tableName.columnName did not work in all cases.
<li>When stopping the TCP server from an application and immediately afterwards starting <li>When stopping the TCP server from an application and immediately afterwards starting
it again using a different TCP password, an exception was thrown sometimes. it again using a different TCP password, an exception was thrown sometimes.
<li>Now PreparedStatement.setBigDecimal(..) can only be called with an object of <li>Now PreparedStatement.setBigDecimal(..) can only be called with an object of
...@@ -181,7 +181,7 @@ INSERT INTO ITEM VALUES(16, ...@@ -181,7 +181,7 @@ INSERT INTO ITEM VALUES(16,
<ul> <ul>
<li>New SQL statement SET SCHEMA to change the current schema of this session. <li>New SQL statement SET SCHEMA to change the current schema of this session.
<li>New system function SCHEMA() to get the current schema. <li>New system function SCHEMA() to get the current schema.
<li>SCRIPT: New option BLOCKSIZE to split BLOBs and CLOBs into separate blocks, to avoid OutOfMemory problems. <li>SCRIPT: New option BLOCKSIZE to split BLOB and CLOB data into separate blocks, to avoid OutOfMemory problems.
<li>CURRVAL and NEXTVAL functions: New optional sequence name parameter. <li>CURRVAL and NEXTVAL functions: New optional sequence name parameter.
<li>The default cache size is now 65536 pages instead of 32768. <li>The default cache size is now 65536 pages instead of 32768.
<li>New optimization to reuse subquery results. Can be disabled with SET OPTIMIZE_REUSE_RESULTS 0. <li>New optimization to reuse subquery results. Can be disabled with SET OPTIMIZE_REUSE_RESULTS 0.
...@@ -194,7 +194,7 @@ INSERT INTO ITEM VALUES(16, ...@@ -194,7 +194,7 @@ INSERT INTO ITEM VALUES(16,
<b>Bugfixes:</b> <b>Bugfixes:</b>
<ul> <ul>
<li>When using the READ_COMMITTED isolation level, a transaction now waits until there are no write locks. <li>When using the READ_COMMITTED isolation level, a transaction now waits until there are no write locks.
<li>INSERT INTO ... SELECT ... and ALTER TABLE with CLOBs and/or BLOBs did not work. <li>INSERT INTO ... SELECT ... and ALTER TABLE with CLOB and/or BLOB data did not work.
<li>CSV tool: the methods setFieldSeparatorWrite and setRowSeparatorWrite where not accessible. <li>CSV tool: the methods setFieldSeparatorWrite and setRowSeparatorWrite where not accessible.
<li>ALTER TABLE ADD did throw a strange message if the table contained views. Now the message is better, <li>ALTER TABLE ADD did throw a strange message if the table contained views. Now the message is better,
but it is still not possible to do that if views on this table exist. but it is still not possible to do that if views on this table exist.
...@@ -245,7 +245,7 @@ INSERT INTO ITEM VALUES(15, ...@@ -245,7 +245,7 @@ INSERT INTO ITEM VALUES(15,
<li>Subqueries with order by outside the column list didn''t work correctly. <li>Subqueries with order by outside the column list didn''t work correctly.
<li>Linked Tables: Only the first column was linked when linking to PostgreSQL. <li>Linked Tables: Only the first column was linked when linking to PostgreSQL.
<li>Sequences: When the database is not closed normally, the value was not set correctly. <li>Sequences: When the database is not closed normally, the value was not set correctly.
<li>The optimization for IN(SELECT...) was too agressive. <li>The optimization for IN(SELECT...) was too aggressive.
<li>Blob.getBytes skipped the wrong number of bytes. <li>Blob.getBytes skipped the wrong number of bytes.
<li>Group by a function didn''t work if a column alias was specified in the select list. <li>Group by a function didn''t work if a column alias was specified in the select list.
<li>LOCK_MODE 0 (READ_UNCOMMITTED) did not work when using multiple connections. <li>LOCK_MODE 0 (READ_UNCOMMITTED) did not work when using multiple connections.
...@@ -331,7 +331,7 @@ INSERT INTO ITEM VALUES(12, ...@@ -331,7 +331,7 @@ INSERT INTO ITEM VALUES(12,
<li>SET IGNORECASE is now supported for compatibility with HSQLDB. <li>SET IGNORECASE is now supported for compatibility with HSQLDB.
<li>New SQL statement DROP ALL OBJECTS [DELETE FILES] to drop all tables, sequences and so on. <li>New SQL statement DROP ALL OBJECTS [DELETE FILES] to drop all tables, sequences and so on.
<li>Improved OpenOffice compatibility. <li>Improved OpenOffice compatibility.
<li>New setting SET COMPRESS_LOB {NO|LZF|DEFLATE} to automatically compress BLOBs and CLOBs. <li>New setting SET COMPRESS_LOB {NO|LZF|DEFLATE} to automatically compress BLOB and CLOB data.
<li>The script can now be compressed. Syntax: SCRIPT TO ''file'' COMPRESSION {DEFLATE|LZF|ZIP|GZIP}. <li>The script can now be compressed. Syntax: SCRIPT TO ''file'' COMPRESSION {DEFLATE|LZF|ZIP|GZIP}.
<li>Now an exception is thrown when the an overflow occurs for mathematical operations (sum, multiply and so on) for the data type selected. <li>Now an exception is thrown when the an overflow occurs for mathematical operations (sum, multiply and so on) for the data type selected.
This was implemented in the previous version but is now enabled by default. This was implemented in the previous version but is now enabled by default.
...@@ -527,7 +527,7 @@ INSERT INTO ITEM VALUES(4, ...@@ -527,7 +527,7 @@ INSERT INTO ITEM VALUES(4,
<ul> <ul>
<li>The cache size is now measured in blocks and no longer in rows. <li>The cache size is now measured in blocks and no longer in rows.
Manually setting the cache size is no longer necessary in most cases. Manually setting the cache size is no longer necessary in most cases.
<li>CREATE VIEW now supports a column list: CREATE VIEW TESTV(A, B) AS ... <li>CREATE VIEW now supports a column list: CREATE VIEW TEST_V(A, B) AS ...
<li>New column IS_GENERATED in the metadata tables SEQUENCES and INDEXES. <li>New column IS_GENERATED in the metadata tables SEQUENCES and INDEXES.
<li>ResultSetMetaData.isNullable is now implemented. <li>ResultSetMetaData.isNullable is now implemented.
<li>Optimization: data conversion of constants was not optimized. <li>Optimization: data conversion of constants was not optimized.
......
...@@ -86,132 +86,16 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2 ...@@ -86,132 +86,16 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
TestAll test = new TestAll(); TestAll test = new TestAll();
test.printSystem(); test.printSystem();
// drop all objects delete files // h2
// // update FOO set a = dateadd('second', 4320000, a);
// java -cp .;%H2DRIVERS% org.h2.tools.RunScript -continueOnError -driver org.h2.Driver -url jdbc:h2:test -user sa -password sa -script c:/temp/test.sql // ms sql server
// java -cp .;%H2DRIVERS% org.h2.tools.RunScript -continueOnError -driver com.mysql.jdbc.Driver -url jdbc:mysql://localhost/test -user sa -password sa -script c:/temp/test.sql // update FOO set a = dateadd(s, 4320000, a);
// java -cp .;%H2DRIVERS% org.h2.tools.RunScript -continueOnError -driver org.apache.derby.jdbc.EmbeddedDriver -url jdbc:derby:test3;create=true -user sa -password sa -script c:/temp/test.sql // mysql
// java -cp .;%H2DRIVERS% org.h2.tools.RunScript -continueOnError -driver org.postgresql.Driver -url jdbc:postgresql:jpox2 -user sa -password sa -script c:/temp/test.sql // update FOO set a = date_add(a, interval 4320000 second);
// // postgresql
// Database URL: jdbc:h2:D:/workspace/DevExpPersistenceStudy/data/test // update FOO set a = a + interval '4320000 s';
// OS: Windows XP PRofessional // oracle
// VM: JDK 1.5_09 // update FOO set a = a + INTERVAL '4320000' SECOND;
// The database DDL statements are just these:
// create table DVXP_OBJECT (
// OBJECT_ID integer generated by default as identity (start with 1),
// OBJECT_HANDLE integer,
// OBJ_KEY varchar(255),
// OBJ_TYPE varchar(255),
// OBJ_CAPTION varchar(255),
// DVXP_ROWNUM integer,
// primary key (OBJECT_ID)
// )
// create table OBJ_PROPERTY (
// OBJECT_HANDLE integer not null,
// PROPERTY_VALUE varchar(255),
// PROPERTY_NAME varchar(255) not null,
// primary key (OBJECT_HANDLE, PROPERTY_NAME)
// )
// alter table OBJ_PROPERTY
// add constraint FK58DBD03D1DFF66BE
// foreign key (OBJECT_HANDLE)
// references DVXP_OBJECT
//
//
// Statck Trace:
// delete from DVXP_OBJECT where OBJECT_ID not in ( select min(OBJECT_ID) from DVXP_OBJECT group by OBJECT_HANDLE );
// General error: java.lang.ArrayIndexOutOfBoundsException: i=0 size=0 [HY000-40]
// org.h2.jdbc.JdbcSQLException: General error: java.lang.ArrayIndexOutOfBoundsException: i=0 size=0 [HY000-40]
// at org.h2.message.Message.getSQLException(Message.java:67)
// at org.h2.message.Message.convert(Message.java:371)
// at org.h2.message.TraceObject.logAndConvert(TraceObject.java:184)
// at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:164)
// at org.h2.server.web.AppThread.getResult(AppThread.java:935)
// at org.h2.server.web.AppThread.query(AppThread.java:609)
// at org.h2.server.web.AppThread.process(AppThread.java:71)
// at org.h2.server.web.WebServerThread.run(WebServerThread.java:127)
// java.lang.ArrayIndexOutOfBoundsException: i=0 size=0
// at org.h2.util.ObjectArray.get(ObjectArray.java:53)
// at org.h2.result.LocalResult.next(LocalResult.java:171)
// at org.h2.expression.ConditionInSelect.getValue(ConditionInSelect.java:48)
// at org.h2.expression.ConditionNot.getValue(ConditionNot.java:28)
// at org.h2.expression.Expression.getBooleanValue(Expression.java:51)
// at org.h2.command.dml.Delete.update(Delete.java:53)
// at org.h2.command.CommandContainer.update(CommandContainer.java:64)
// at org.h2.command.Command.executeUpdate(Command.java:120)
// at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:155)
// at org.h2.server.web.AppThread.getResult(AppThread.java:935)
// at org.h2.server.web.AppThread.query(AppThread.java:609)
// at org.h2.server.web.AppThread.process(AppThread.java:71)
// at org.h2.server.web.WebServerThread.run(WebServerThread.java:127)
//
// About data:
// First I created 100000 rows, and later a duplicated it -> getting 200000 rows.
//
// If you want, I can send to you the database files.
// --------------------------------
//
// Hi,
//
// I'm trying to setup a XAConnection with h2. The setup is done with the spring-framework and the atomikos Transaction Manager:
//
// CODE
//
// <bean id="ds1" class="com.atomikos.jdbc.SimpleDataSourceBean" init-method="init" destroy-method="close">
// <property name="uniqueResourceName">
// <value>XADBMS1</value>
// </property>
// <property name="xaDataSourceClassName">
// <value>org.h2.jdbcx.JdbcDataSource</value>
// </property>
// <property name="xaDataSourceProperties">
// <value>user=sa;password=ss;URL=jdbc:h2:tcp://localhost:9092/test</value>
// </property>
// <property name="exclusiveConnectionMode">
// <value>true</value>
// </property>
// <property name="connectionPoolSize" value="3"/>
// </bean>
//
//
// With that setup I get the following Exception:
//
// CODE
//
// Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds1' defined in class path resource [spring.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
// Caused by: java.lang.NullPointerException
// at org.h2.jdbcx.JdbcXAConnection.addConnectionEventListener(JdbcXAConnection.java:80)
// at com.atomikos.jdbc.ExternalXAPooledConnectionImp.<init>(Unknown Source)
// at com.atomikos.jdbc.ExternalXAPooledConnectionImp.<init>(Unknown Source)
// at com.atomikos.jdbc.ExclusiveExternalXAPooledConnectionImp.<init>(Unknown Source)
// at com.atomikos.jdbc.XAConnectionFactory.getPooledConnection(Unknown Source)
// at com.atomikos.jdbc.ConnectionPool.<init>(Unknown Source)
// at com.atomikos.jdbc.JtaDataSourceImp.<init>(Unknown Source)
// at com.atomikos.jdbc.SimpleDataSourceBean.checkSetup(Unknown Source)
//
//
// After a little debugging I see that the connection in the JdbcXAConnection class is null.
//
// Is it a configuration issue, or is XA not fully implemented in H2?
//
// Thanks
//
// Marc
// It would be nice if the donation link opened a new window. I could not see where I was at in the address bar while filling out the form.
// support % operator (modulo)
// java -cp .;%H2DRIVERS% org.h2.tools.RunScript -continueOnError -driver org.h2.Driver -url jdbc:h2:test -user sa -password sa -script c:/temp/test.sql
// java -cp .;%H2DRIVERS% org.h2.tools.RunScript -continueOnError -driver com.mysql.jdbc.Driver -url jdbc:mysql://localhost/test -user sa -password sa -script c:/temp/test.sql
// java -cp .;%H2DRIVERS% org.h2.tools.RunScript -continueOnError -driver org.apache.derby.jdbc.EmbeddedDriver -url jdbc:derby:test3;create=true -user sa -password sa -script c:/temp/test.sql
// java -cp .;%H2DRIVERS% org.h2.tools.RunScript -continueOnError -driver org.postgresql.Driver -url jdbc:postgresql:jpox2 -user sa -password sa -script c:/temp/test.sql
// http://monetdb.cwi.nl/Assets/DBtapestry100K.sql
// (delete all objects doesn't work for linux)
// Hi,
// Thanks for your feedback! Yes, this is a bug, it will be fixed in the next release.
// Thomas
// test backup // test backup
// backup: lobs, index // backup: lobs, index
...@@ -221,8 +105,7 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2 ...@@ -221,8 +105,7 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
// BACKUP: compare sql syntax with other databases // BACKUP: compare sql syntax with other databases
// Hot backup (incremental backup, online backup): backup data, log, index? files // Hot backup (incremental backup, online backup): backup data, log, index? files
// ESC/Java (http://secure.ucd.ie/products/opensource/ESCJava2/) // GroovyServlet
// GroovyServlet
// Cluster: hot deploy (adding a node on runtime) // Cluster: hot deploy (adding a node on runtime)
......
...@@ -247,8 +247,8 @@ public abstract class TestBase { ...@@ -247,8 +247,8 @@ public abstract class TestBase {
} }
protected static void printTime(String s) { protected static void printTime(String s) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(new java.util.Date()) + " " + s); System.out.println(dateFormat.format(new java.util.Date()) + " " + s);
} }
protected void deleteDb(String name) throws Exception { protected void deleteDb(String name) throws Exception {
...@@ -357,14 +357,14 @@ public abstract class TestBase { ...@@ -357,14 +357,14 @@ public abstract class TestBase {
checkFalse(rs.next()); checkFalse(rs.next());
} }
protected void testResultSetMeta(ResultSet rs, int columncount, String[] labels, protected void testResultSetMeta(ResultSet rs, int columnCount, String[] labels,
int[] datatypes, int[] precision, int[] scale) throws Exception { int[] datatypes, int[] precision, int[] scale) throws Exception {
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
int cc = meta.getColumnCount(); int cc = meta.getColumnCount();
if (cc != columncount) { if (cc != columnCount) {
error("result set contains " + cc + " columns not " + columncount); error("result set contains " + cc + " columns not " + columnCount);
} }
for (int i = 0; i < columncount; i++) { for (int i = 0; i < columnCount; i++) {
if (labels != null) { if (labels != null) {
String l = meta.getColumnLabel(i + 1); String l = meta.getColumnLabel(i + 1);
if (!labels[i].equals(l)) { if (!labels[i].equals(l)) {
...@@ -437,16 +437,16 @@ public abstract class TestBase { ...@@ -437,16 +437,16 @@ public abstract class TestBase {
if (rows == 0) { if (rows == 0) {
// special case: no rows // special case: no rows
if (rs.next()) { if (rs.next()) {
error("testResultSet expected rowcount:" + rows + " got:0"); error("testResultSet expected rowCount:" + rows + " got:0");
} }
} }
int len2 = data[0].length; int len2 = data[0].length;
if (len < len2) { if (len < len2) {
error("testResultSet expected columncount:" + len2 + " got:" + len); error("testResultSet expected columnCount:" + len2 + " got:" + len);
} }
for (int i = 0; i < rows; i++) { for (int i = 0; i < rows; i++) {
if (!rs.next()) { if (!rs.next()) {
error("testResultSet expected rowcount:" + rows + " got:" + i); error("testResultSet expected rowCount:" + rows + " got:" + i);
} }
String[] row = getData(rs, len); String[] row = getData(rs, len);
if (ordered) { if (ordered) {
...@@ -515,7 +515,7 @@ public abstract class TestBase { ...@@ -515,7 +515,7 @@ public abstract class TestBase {
((JdbcConnection)conn).setPowerOffCount(1); ((JdbcConnection)conn).setPowerOffCount(1);
try { try {
conn.createStatement().execute("SET WRITE_DELAY 0"); conn.createStatement().execute("SET WRITE_DELAY 0");
conn.createStatement().execute("CREATE TABLE AAA(ID INT)"); conn.createStatement().execute("CREATE TABLE TEST_A(ID INT)");
error("should be crashed already"); error("should be crashed already");
} catch(SQLException e) { } catch(SQLException e) {
// expected // expected
......
...@@ -7,7 +7,7 @@ package org.h2.test.bench; ...@@ -7,7 +7,7 @@ package org.h2.test.bench;
public interface Bench { public interface Bench {
void init(Database db, int size) throws Exception; void init(Database db, int size) throws Exception;
void run() throws Exception; void runTest() throws Exception;
String getName(); String getName();
} }
...@@ -36,7 +36,6 @@ public class BenchA implements Bench { ...@@ -36,7 +36,6 @@ public class BenchA implements Bench {
db.openConnection(); db.openConnection();
db.dropTable("BRANCHES");
db.dropTable("BRANCHES"); db.dropTable("BRANCHES");
db.dropTable("TELLERS"); db.dropTable("TELLERS");
db.dropTable("ACCOUNTS"); db.dropTable("ACCOUNTS");
...@@ -87,13 +86,13 @@ public class BenchA implements Bench { ...@@ -87,13 +86,13 @@ public class BenchA implements Bench {
db.closeConnection(); db.closeConnection();
db.end(); db.end();
db.start(this, "Open/Close"); // db.start(this, "Open/Close");
db.openConnection(); // db.openConnection();
db.closeConnection(); // db.closeConnection();
db.end(); // db.end();
} }
public void run() throws Exception { public void runTest() throws Exception {
db.start(this, "Transactions"); db.start(this, "Transactions");
db.openConnection(); db.openConnection();
......
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.bench;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Random;
/**
* See also http://www.tpc.org/tpcb
* Referential integrity is not implemented.
*/
public class BenchB implements Bench, Runnable {
// master data
private Database db;
private int scale = 1;
private int branches = 1;
private int tellers = 10;
private int accounts = 100000;
private int clients = 10;
private int transactionPerClient;
// client data
private BenchB master;
private Connection conn;
private PreparedStatement updateAccount;
private PreparedStatement selectAccount;
private PreparedStatement updateTeller;
private PreparedStatement updateBranch;
private PreparedStatement insertHistory;
private Random random;
public BenchB() {
}
public void init(Database db, int size) throws Exception {
this.db = db;
this.transactionPerClient = size;
db.start(this, "Init");
db.openConnection();
db.dropTable("BRANCHES");
db.dropTable("TELLERS");
db.dropTable("ACCOUNTS");
db.dropTable("HISTORY");
String[] create = { "CREATE TABLE BRANCHES(BID INT NOT NULL PRIMARY KEY, BBALANCE INT, FILLER VARCHAR(88))",
"CREATE TABLE TELLERS(TID INT NOT NULL PRIMARY KEY, BID INT, TBALANCE INT, FILLER VARCHAR(84))",
"CREATE TABLE ACCOUNTS(AID INT NOT NULL PRIMARY KEY, BID INT, ABALANCE INT, FILLER VARCHAR(84))",
"CREATE TABLE HISTORY(TID INT, BID INT, AID INT, DELTA INT, TIME DATETIME, FILLER VARCHAR(22))" };
for (int i = 0; i < create.length; i++) {
db.update(create[i]);
}
PreparedStatement prep;
db.setAutoCommit(false);
int commitEvery = 1000;
prep = db.prepare(
"INSERT INTO BRANCHES(BID, BBALANCE) VALUES(?, 0)");
for (int i = 0; i < branches * scale; i++) {
prep.setInt(1, i);
db.update(prep);
if(i%commitEvery==0) {
db.commit();
}
}
db.commit();
prep = db.prepare(
"INSERT INTO TELLERS(TID, BID, TBALANCE) VALUES(?, ?, 0)");
for (int i = 0; i < tellers * scale; i++) {
prep.setInt(1, i);
prep.setInt(2, i / tellers);
db.update(prep);
if(i%commitEvery==0) {
db.commit();
}
}
db.commit();
int len = accounts * scale;
prep = db.prepare(
"INSERT INTO ACCOUNTS(AID, BID, ABALANCE) VALUES(?, ?, 0)");
for (int i = 0; i < len; i++) {
prep.setInt(1, i);
prep.setInt(2, i / accounts);
db.update(prep);
if(i%commitEvery==0) {
db.commit();
}
}
db.commit();
db.closeConnection();
db.end();
// db.start(this, "Open/Close");
// db.openConnection();
// db.closeConnection();
// db.end();
}
private BenchB(BenchB master, int seed) throws Exception {
this.master = master;
random = new Random(seed);
conn = master.db.getConnection();
conn.setAutoCommit(false);
updateAccount = conn.prepareStatement(
"UPDATE ACCOUNTS SET ABALANCE=ABALANCE+? WHERE AID=?");
selectAccount = conn.prepareStatement(
"SELECT ABALANCE FROM ACCOUNTS WHERE AID=?");
updateTeller = conn.prepareStatement(
"UPDATE TELLERS SET TBALANCE=TBALANCE+? WHERE TID=?");
updateBranch = conn.prepareStatement(
"UPDATE BRANCHES SET BBALANCE=BBALANCE+? WHERE BID=?");
insertHistory = conn.prepareStatement(
"INSERT INTO HISTORY(TID, BID, AID, DELTA) VALUES(?, ?, ?, ?)");
}
public void run() {
int accountsPerBranch = accounts / branches;
for(int i=0; i<master.transactionPerClient; i++) {
int branch = random.nextInt(master.branches);
int teller = random.nextInt(master.tellers);
int account;
if (random.nextInt(100) < 85) {
account = random.nextInt(accountsPerBranch) + branch * accountsPerBranch;
} else {
account = random.nextInt(accounts);
}
int delta = random.nextInt(1000);
doOne(branch, teller, account, delta);
}
try {
conn.close();
} catch(SQLException e) {
// ignore
}
}
private void doOne(int branch, int teller, int account, int delta) {
try {
// UPDATE ACCOUNTS SET ABALANCE=ABALANCE+? WHERE AID=?
updateAccount.setInt(1, delta);
updateAccount.setInt(2, account);
updateAccount.executeUpdate();
// SELECT ABALANCE FROM ACCOUNTS WHERE AID=?
selectAccount.setInt(1, account);
ResultSet rs = selectAccount.executeQuery();
while(rs.next()) {
rs.getInt(1);
}
// UPDATE TELLERS SET TBALANCE=TABLANCE+? WHERE TID=?
updateTeller.setInt(1, delta);
updateTeller.setInt(2, teller);
updateTeller.executeUpdate();
// UPDATE BRANCHES SET BBALANCE=BBALANCE+? WHERE BID=?
updateBranch.setInt(1, delta);
updateBranch.setInt(2, branch);
updateBranch.executeUpdate();
// INSERT INTO HISTORY(TID, BID, AID, DELTA) VALUES(?, ?, ?, ?)
insertHistory.setInt(1, teller);
insertHistory.setInt(2, branch);
insertHistory.setInt(3, account);
insertHistory.setInt(4, delta);
insertHistory.executeUpdate();
conn.commit();
} catch(SQLException e) {
e.printStackTrace();
}
}
public void runTest() throws Exception {
db.start(this, "Transactions");
db.openConnection();
processTransactions();
db.closeConnection();
db.end();
db.openConnection();
processTransactions();
db.logMemory(this, "Memory Usage");
db.closeConnection();
}
private void processTransactions() throws Exception {
Thread[] threads = new Thread[clients];
for(int i=0; i<clients; i++) {
threads[i] = new Thread(new BenchB(this, i));
}
for(int i=0; i<clients; i++) {
threads[i].start();
}
for(int i=0; i<clients; i++) {
threads[i].join();
}
}
public String getName() {
return "BenchB";
}
}
...@@ -140,10 +140,10 @@ public class BenchC implements Bench { ...@@ -140,10 +140,10 @@ public class BenchC implements Bench {
db.closeConnection(); db.closeConnection();
db.end(); db.end();
db.start(this, "Open/Close"); // db.start(this, "Open/Close");
db.openConnection(); // db.openConnection();
db.closeConnection(); // db.closeConnection();
db.end(); // db.end();
} }
...@@ -484,7 +484,7 @@ public class BenchC implements Bench { ...@@ -484,7 +484,7 @@ public class BenchC implements Bench {
} }
} }
public void run() throws Exception { public void runTest() throws Exception {
db.start(this, "Transactions"); db.start(this, "Transactions");
db.openConnection(); db.openConnection();
for(int i=0; i<70; i++) { for(int i=0; i<70; i++) {
......
...@@ -257,14 +257,14 @@ public class BenchCThread { ...@@ -257,14 +257,14 @@ public class BenchCThread {
c_w_id = warehouseId; c_w_id = warehouseId;
c_d_id = d_id; c_d_id = d_id;
} }
boolean byname; boolean byName;
String c_last; String c_last;
int c_id = 1; int c_id = 1;
if (random.getInt(1, 100) <= 60) { if (random.getInt(1, 100) <= 60) {
byname = true; byName = true;
c_last = random.getLastname(random.getNonUniform(255, 0, 999)); c_last = random.getLastname(random.getNonUniform(255, 0, 999));
} else { } else {
byname = false; byName = false;
c_last = ""; c_last = "";
c_id = random.getNonUniform(1023, 1, bench.customersPerDistrict); c_id = random.getNonUniform(1023, 1, bench.customersPerDistrict);
} }
...@@ -311,7 +311,7 @@ public class BenchCThread { ...@@ -311,7 +311,7 @@ public class BenchCThread {
rs.close(); rs.close();
BigDecimal c_balance; BigDecimal c_balance;
String c_credit; String c_credit;
if (byname) { if (byName) {
prep = prepare("SELECT COUNT(C_ID) FROM CUSTOMER " prep = prepare("SELECT COUNT(C_ID) FROM CUSTOMER "
+ "WHERE C_LAST=? AND C_D_ID=? AND C_W_ID=?"); + "WHERE C_LAST=? AND C_D_ID=? AND C_W_ID=?");
prep.setString(1, c_last); prep.setString(1, c_last);
...@@ -439,14 +439,14 @@ public class BenchCThread { ...@@ -439,14 +439,14 @@ public class BenchCThread {
private void processOrderStatus() throws Exception { private void processOrderStatus() throws Exception {
int d_id = random.getInt(1, bench.districtsPerWarehouse); int d_id = random.getInt(1, bench.districtsPerWarehouse);
boolean byname; boolean byName;
String c_last = null; String c_last = null;
int c_id = -1; int c_id = -1;
if (random.getInt(1, 100) <= 60) { if (random.getInt(1, 100) <= 60) {
byname = true; byName = true;
c_last = random.getLastname(random.getNonUniform(255, 0, 999)); c_last = random.getLastname(random.getNonUniform(255, 0, 999));
} else { } else {
byname = false; byName = false;
c_id = random.getNonUniform(1023, 1, bench.customersPerDistrict); c_id = random.getNonUniform(1023, 1, bench.customersPerDistrict);
} }
PreparedStatement prep; PreparedStatement prep;
...@@ -454,7 +454,7 @@ public class BenchCThread { ...@@ -454,7 +454,7 @@ public class BenchCThread {
prep = prepare("UPDATE DISTRICT SET D_NEXT_O_ID=-1 WHERE D_ID=-1"); prep = prepare("UPDATE DISTRICT SET D_NEXT_O_ID=-1 WHERE D_ID=-1");
db.update(prep); db.update(prep);
if (byname) { if (byName) {
prep = prepare("SELECT COUNT(C_ID) FROM CUSTOMER " prep = prepare("SELECT COUNT(C_ID) FROM CUSTOMER "
+ "WHERE C_LAST=? AND C_D_ID=? AND C_W_ID=?"); + "WHERE C_LAST=? AND C_D_ID=? AND C_W_ID=?");
prep.setString(1, c_last); prep.setString(1, c_last);
......
...@@ -36,14 +36,14 @@ public class BenchSimple implements Bench { ...@@ -36,14 +36,14 @@ public class BenchSimple implements Bench {
db.closeConnection(); db.closeConnection();
db.end(); db.end();
db.start(this, "Open/Close"); // db.start(this, "Open/Close");
db.openConnection(); // db.openConnection();
db.closeConnection(); // db.closeConnection();
db.end(); // db.end();
} }
public void run() throws Exception { public void runTest() throws Exception {
PreparedStatement prep; PreparedStatement prep;
Random random = db.getRandom(); Random random = db.getRandom();
......
...@@ -214,11 +214,11 @@ class Database { ...@@ -214,11 +214,11 @@ class Database {
public void update(String sql) throws Exception { public void update(String sql) throws Exception {
sql = getSQL(sql); sql = getSQL(sql);
if(sql.trim().length()>0) { if(sql.trim().length()>0) {
executedStatements++;
stat.execute(sql); stat.execute(sql);
} else { } else {
System.out.println("?"); System.out.println("?");
} }
executedStatements++;
} }
public void setAutoCommit(boolean b) throws Exception { public void setAutoCommit(boolean b) throws Exception {
......
...@@ -212,7 +212,7 @@ public class TestPerformance { ...@@ -212,7 +212,7 @@ public class TestPerformance {
private void runTest(Database db, Bench bench, int size) throws Exception { private void runTest(Database db, Bench bench, int size) throws Exception {
bench.init(db, size); bench.init(db, size);
bench.run(); bench.runTest();
} }
} }
db1 = H2, org.h2.Driver, jdbc:h2:data/test, sa, sa db1 = H2, org.h2.Driver, jdbc:h2:data/test;LOCK_TIMEOUT=10000, sa, sa
db2 = HSQLDB, org.hsqldb.jdbcDriver, jdbc:hsqldb:data/test;hsqldb.default_table_type=cached, sa db2 = HSQLDB, org.hsqldb.jdbcDriver, jdbc:hsqldb:data/test;hsqldb.default_table_type=cached, sa
db3 = Derby, org.apache.derby.jdbc.EmbeddedDriver, jdbc:derby:data/test;create=true, sa, sa db3 = Derby, org.apache.derby.jdbc.EmbeddedDriver, jdbc:derby:data/test;create=true, sa, sa
db4 = H2, org.h2.Driver, jdbc:h2:tcp://localhost/data/testServ, sa, sa db4 = H2, org.h2.Driver, jdbc:h2:tcp://localhost/data/testServer;LOCK_TIMEOUT=10000, sa, sa
db5 = HSQLDB, org.hsqldb.jdbcDriver, jdbc:hsqldb:hsql://localhost/xdb, sa db5 = HSQLDB, org.hsqldb.jdbcDriver, jdbc:hsqldb:hsql://localhost/xdb, sa
db6 = Derby, org.apache.derby.jdbc.ClientDriver, jdbc:derby://localhost/data/testServ;create=true, sa, sa db6 = Derby, org.apache.derby.jdbc.ClientDriver, jdbc:derby://localhost/data/testServer;create=true, sa, sa
db7 = PostgreSQL, org.postgresql.Driver, jdbc:postgresql:test, sa, sa db7 = PostgreSQL, org.postgresql.Driver, jdbc:postgresql:test, sa, sa
db8 = MySQL, com.mysql.jdbc.Driver, jdbc:mysql://localhost/test?jdbcCompliantTruncation=false, sa, sa db8 = MySQL, com.mysql.jdbc.Driver, jdbc:mysql://localhost/test?jdbcCompliantTruncation=false, sa, sa
...@@ -21,13 +21,7 @@ oracle.datetime = TIMESTAMP ...@@ -21,13 +21,7 @@ oracle.datetime = TIMESTAMP
test1 = org.h2.test.bench.BenchSimple test1 = org.h2.test.bench.BenchSimple
test2 = org.h2.test.bench.BenchA test2 = org.h2.test.bench.BenchA
test3 = org.h2.test.bench.BenchC test3 = org.h2.test.bench.BenchB
test4 = org.h2.test.bench.BenchC
xsize = 500
xsize = 20
xsize=200
#bug with hsqldb (newest version) and size = 400
xsize = 200
#officialsize = 250
size = 400 size = 400
...@@ -65,29 +65,29 @@ public class TestCollation { ...@@ -65,29 +65,29 @@ public class TestCollation {
// This problem also happen if there are date parameters; // This problem also happen if there are date parameters;
Statement stm = conn.createStatement(); Statement stat = conn.createStatement();
stm.executeUpdate( stat.executeUpdate(
"DROP TABLE IF EXISTS test"); "DROP TABLE IF EXISTS test");
stm.executeUpdate( stat.executeUpdate(
"SET COLLATION OFF"); "SET COLLATION OFF");
stm.executeUpdate( stat.executeUpdate(
"CREATE TABLE test (id INT IDENTITY, code VARCHAR(20) NOT NULL, parentId INT)"); "CREATE TABLE test (id INT IDENTITY, code VARCHAR(20) NOT NULL, parentId INT)");
stm.executeUpdate( stat.executeUpdate(
"CREATE INDEX test_code ON test(code)"); "CREATE INDEX test_code ON test(code)");
PreparedStatement pstm = conn.prepareStatement( PreparedStatement prep2 = conn.prepareStatement(
"INSERT INTO test (code,parentId) VALUES (?,NULL)"); "INSERT INTO test (code,parentId) VALUES (?,NULL)");
PreparedStatement pstm2 = conn.prepareStatement( PreparedStatement prep3 = conn.prepareStatement(
"INSERT INTO test (code,parentId) SELECT ?,id FROM test WHERE code=?"); "INSERT INTO test (code,parentId) SELECT ?,id FROM test WHERE code=?");
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
for (int i = 1; i < TOTAL; ++i) { for (int i = 1; i < TOTAL; ++i) {
if (i < ROOT) { if (i < ROOT) {
pstm.setString(1, Integer.toBinaryString(i)); prep2.setString(1, Integer.toBinaryString(i));
pstm.executeUpdate(); prep2.executeUpdate();
} else { } else {
pstm2.setString(1, Integer.toBinaryString(i)); prep3.setString(1, Integer.toBinaryString(i));
pstm2.setString(2, Integer.toBinaryString(i % 100 + 1)); prep3.setString(2, Integer.toBinaryString(i % 100 + 1));
pstm2.executeUpdate(); prep3.executeUpdate();
} }
} }
System.out.println("INSERT w/o Collation: " + (System.currentTimeMillis()-time)); System.out.println("INSERT w/o Collation: " + (System.currentTimeMillis()-time));
...@@ -98,29 +98,29 @@ public class TestCollation { ...@@ -98,29 +98,29 @@ public class TestCollation {
public void testWithCollation() throws Exception { public void testWithCollation() throws Exception {
Statement stm = conn.createStatement(); Statement stat = conn.createStatement();
stm.executeUpdate( stat.executeUpdate(
"DROP TABLE IF EXISTS test"); "DROP TABLE IF EXISTS test");
stm.executeUpdate( stat.executeUpdate(
"SET COLLATION ENGLISH STRENGTH PRIMARY"); "SET COLLATION ENGLISH STRENGTH PRIMARY");
stm.executeUpdate( stat.executeUpdate(
"CREATE TABLE test (id INT IDENTITY, code VARCHAR(20) NOT NULL, parentId INT)"); "CREATE TABLE test (id INT IDENTITY, code VARCHAR(20) NOT NULL, parentId INT)");
stm.executeUpdate( stat.executeUpdate(
"CREATE INDEX test_code ON test(code)"); "CREATE INDEX test_code ON test(code)");
PreparedStatement pstm = conn.prepareStatement( PreparedStatement prep = conn.prepareStatement(
"INSERT INTO test (code,parentId) VALUES (?,NULL)"); "INSERT INTO test (code,parentId) VALUES (?,NULL)");
PreparedStatement pstm2 = conn.prepareStatement( PreparedStatement prep2 = conn.prepareStatement(
"INSERT INTO test (code,parentId) SELECT ?,id FROM test WHERE code=?"); "INSERT INTO test (code,parentId) SELECT ?,id FROM test WHERE code=?");
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
for (int i = 1; i < TOTAL; ++i) { for (int i = 1; i < TOTAL; ++i) {
if (i < ROOT) { if (i < ROOT) {
pstm.setString(1, Integer.toBinaryString(i)); prep.setString(1, Integer.toBinaryString(i));
pstm.executeUpdate(); prep.executeUpdate();
} else { } else {
pstm2.setString(1, Integer.toBinaryString(i)); prep2.setString(1, Integer.toBinaryString(i));
pstm2.setString(2, Integer.toBinaryString(i % 100 + 1)); prep2.setString(2, Integer.toBinaryString(i % 100 + 1));
pstm2.executeUpdate(); prep2.executeUpdate();
} }
} }
System.out.println("INSERT with Collation: " + (System.currentTimeMillis()-time)); System.out.println("INSERT with Collation: " + (System.currentTimeMillis()-time));
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
package org.h2.test.cases; package org.h2.test.cases;
import java.sql.*; import java.sql.*;
public class TestCompatibiliyMySQL { public class TestCompatibilityMySQL {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
testWith("org.postgresql.Driver", "jdbc:postgresql:jpox2", "sa", "sa"); testWith("org.postgresql.Driver", "jdbc:postgresql:jpox2", "sa", "sa");
......
...@@ -21,18 +21,18 @@ public class TestDate { ...@@ -21,18 +21,18 @@ public class TestDate {
try { try {
stat.execute("DROP TABLE ts_trial"); stat.execute("DROP TABLE ts_trial");
} catch (SQLException e) { } } catch (SQLException e) { }
stat.execute("CREATE TABLE ts_trial(myts TIMESTAMP)"); stat.execute("CREATE TABLE ts_trial(TS TIMESTAMP)");
PreparedStatement prep = conn.prepareStatement( PreparedStatement prep = conn.prepareStatement(
"INSERT INTO ts_trial(myts) VALUES (?)"); "INSERT INTO ts_trial(TS) VALUES (?)");
prep.setTimestamp(1, new java.sql.Timestamp(System.currentTimeMillis())); prep.setTimestamp(1, new java.sql.Timestamp(System.currentTimeMillis()));
prep.execute(); prep.execute();
prep.setDate(1, new java.sql.Date(System.currentTimeMillis())); prep.setDate(1, new java.sql.Date(System.currentTimeMillis()));
prep.execute(); prep.execute();
ResultSet rs = stat.executeQuery("SELECT myts FROM ts_trial"); ResultSet rs = stat.executeQuery("SELECT TS FROM ts_trial");
rs.next(); rs.next();
System.out.println("Timestamp: " + rs.getTimestamp("myts")); System.out.println("Timestamp: " + rs.getTimestamp("TS"));
rs.next(); rs.next();
System.out.println("Date: " + rs.getTimestamp("myts")); System.out.println("Date: " + rs.getTimestamp("TS"));
System.out.println(); System.out.println();
} }
} }
...@@ -56,7 +56,7 @@ public class TestHibernateClob { ...@@ -56,7 +56,7 @@ public class TestHibernateClob {
conn.createStatement(); conn.createStatement();
stat0.executeUpdate("drop table CLOB_ENTITY if exists"); stat0.executeUpdate("drop table CLOB_ENTITY if exists");
stat0.getWarnings(); stat0.getWarnings();
stat0.executeUpdate("create table CLOB_ENTITY (ID bigint not null, SER_DATA clob, CLOB_DATA clob, primary key (ID))"); stat0.executeUpdate("create table CLOB_ENTITY (ID bigint not null, DATA clob, CLOB_DATA clob, primary key (ID))");
stat0.getWarnings(); stat0.getWarnings();
stat0.close(); stat0.close();
conn.getWarnings(); conn.getWarnings();
...@@ -75,7 +75,7 @@ public class TestHibernateClob { ...@@ -75,7 +75,7 @@ public class TestHibernateClob {
prep0.close(); prep0.close();
conn.getAutoCommit(); conn.getAutoCommit();
PreparedStatement prep1 = PreparedStatement prep1 =
conn.prepareStatement("insert into CLOB_ENTITY (SER_DATA, CLOB_DATA, ID) values (?, ?, ?)"); conn.prepareStatement("insert into CLOB_ENTITY (DATA, CLOB_DATA, ID) values (?, ?, ?)");
prep1.setNull(1, 2005); prep1.setNull(1, 2005);
StringBuffer buff = new StringBuffer(20000); StringBuffer buff = new StringBuffer(20000);
for(int i=0; i<10000; i++) { for(int i=0; i<10000; i++) {
...@@ -96,12 +96,12 @@ public class TestHibernateClob { ...@@ -96,12 +96,12 @@ public class TestHibernateClob {
conn.getAutoCommit(); conn.getAutoCommit();
conn.getAutoCommit(); conn.getAutoCommit();
PreparedStatement prep2 = PreparedStatement prep2 =
conn.prepareStatement("select clobholdin0_.ID as ID0_0_, clobholdin0_.SER_DATA as SER2_0_0_, clobholdin0_.CLOB_DATA as CLOB3_0_0_ from CLOB_ENTITY clobholdin0_ where clobholdin0_.ID=?"); conn.prepareStatement("select c_.ID as ID0_0_, c_.DATA as S2, c_.CLOB_DATA as CLOB3_0_0_ from CLOB_ENTITY c_ where c_.ID=?");
prep2.setLong(1, 1); prep2.setLong(1, 1);
ResultSet rs1 = ResultSet rs1 =
prep2.executeQuery(); prep2.executeQuery();
rs1.next(); rs1.next();
System.out.println("ser: " + rs1.getCharacterStream("SER2_0_0_")); System.out.println("s2: " + rs1.getCharacterStream("S2"));
Clob clob0 = Clob clob0 =
rs1.getClob("CLOB3_0_0_"); rs1.getClob("CLOB3_0_0_");
System.out.println("wasNull: " + rs1.wasNull()); System.out.println("wasNull: " + rs1.wasNull());
......
...@@ -55,14 +55,14 @@ public class TestKiller { ...@@ -55,14 +55,14 @@ public class TestKiller {
} }
stmt.execute("CREATE TABLE TESTTAB(VL DECIMAL(16,6) PRIMARY KEY)"); stmt.execute("CREATE TABLE TESTTAB(VL DECIMAL(16,6) PRIMARY KEY)");
stmt.close(); stmt.close();
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO TESTTAB VALUES (?)"); PreparedStatement prep = conn.prepareStatement("INSERT INTO TESTTAB VALUES (?)");
pstmt.setBigDecimal(1, new TestBigDecimal("1")); prep.setBigDecimal(1, new TestBigDecimal("1"));
pstmt.execute(); prep.execute();
pstmt.setBigDecimal(1, new TestBigDecimal("2")); prep.setBigDecimal(1, new TestBigDecimal("2"));
pstmt.execute(); prep.execute();
pstmt.setBigDecimal(1, new TestBigDecimal("3")); prep.setBigDecimal(1, new TestBigDecimal("3"));
pstmt.execute(); prep.execute();
pstmt.close(); prep.close();
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TESTTAB ORDER BY VL"); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TESTTAB ORDER BY VL");
while(rs.next()) { while(rs.next()) {
System.out.println("VL:" + rs.getString("VL")); System.out.println("VL:" + rs.getString("VL"));
......
...@@ -16,7 +16,7 @@ import org.h2.util.MemoryUtils; ...@@ -16,7 +16,7 @@ import org.h2.util.MemoryUtils;
public class TestLinearIndex { public class TestLinearIndex {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
// stat.execute("create unique index idxid on test(id)"); // stat.execute("create unique index idx_id on test(id)");
int len = 1000; int len = 1000;
for(int a=0; ; a++) { for(int a=0; ; a++) {
testLoop(true, len); testLoop(true, len);
...@@ -35,9 +35,9 @@ public class TestLinearIndex { ...@@ -35,9 +35,9 @@ public class TestLinearIndex {
stat.execute("drop table if exists test"); stat.execute("drop table if exists test");
stat.execute("create table test(id int, name varchar)"); stat.execute("create table test(id int, name varchar)");
if(hashIndex) { if(hashIndex) {
stat.execute("create unique hash index idxid on test(id)"); stat.execute("create unique hash index idx_id on test(id)");
} else { } else {
stat.execute("create unique index idxid on test(id)"); stat.execute("create unique index idx_id on test(id)");
} }
stat.execute("insert into test select x, 'Hello World' from system_range(1, "+len+")"); stat.execute("insert into test select x, 'Hello World' from system_range(1, "+len+")");
PreparedStatement prep = conn.prepareStatement("select * from test where id=?"); PreparedStatement prep = conn.prepareStatement("select * from test where id=?");
......
...@@ -12,7 +12,7 @@ import java.sql.Types; ...@@ -12,7 +12,7 @@ import java.sql.Types;
public class TestOther { public class TestOther {
public static void main(String[] args) { public static void main(String[] args) {
Object[] tos = { Object[] list = {
// new int[] {1, 2, 3, 4, 5}, // new int[] {1, 2, 3, 4, 5},
// new Integer(122), // Uncomment to see a "Hexadecimal string with odd number of characters" // new Integer(122), // Uncomment to see a "Hexadecimal string with odd number of characters"
new String[] {"hello", "world"}, // Uncomment to see a "Deserialization failed" new String[] {"hello", "world"}, // Uncomment to see a "Deserialization failed"
...@@ -21,22 +21,22 @@ public class TestOther { ...@@ -21,22 +21,22 @@ public class TestOther {
try { try {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
Connection con = DriverManager.getConnection("jdbc:h2:mem:", "sa", ""); Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
con.setAutoCommit(true); conn.setAutoCommit(true);
con.createStatement().executeUpdate("CREATE TABLE TestOtherJDBC (tstData OTHER)"); conn.createStatement().executeUpdate("CREATE TABLE TestOtherJDBC (testData OTHER)");
System.out.println("table created"); System.out.println("table created");
PreparedStatement stmt = con.prepareStatement("INSERT INTO TestOtherJDBC (tstData) VALUES (?)"); PreparedStatement stmt = conn.prepareStatement("INSERT INTO TestOtherJDBC (testData) VALUES (?)");
for (int i = 0; i < tos.length; i++) { for (int i = 0; i < list.length; i++) {
System.out.println(tos[i].getClass().getName() + "\t" + tos[i]); System.out.println(list[i].getClass().getName() + "\t" + list[i]);
stmt.setObject(1, tos[i], Types.OTHER); stmt.setObject(1, list[i], Types.OTHER);
stmt.executeUpdate(); stmt.executeUpdate();
} }
System.out.println("inserted"); System.out.println("inserted");
ResultSet rs = con.createStatement().executeQuery("SELECT tstData FROM TestOtherJDBC"); ResultSet rs = conn.createStatement().executeQuery("SELECT testData FROM TestOtherJDBC");
while(rs.next()) { while(rs.next()) {
Object obj = rs.getObject(1); Object obj = rs.getObject(1);
......
...@@ -33,7 +33,7 @@ public class TestRebuildIndex { ...@@ -33,7 +33,7 @@ public class TestRebuildIndex {
} }
} else { } else {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
stat.execute("CREATE INDEX IDXDATA ON TEST(DATA)"); stat.execute("CREATE INDEX idx_data ON TEST(DATA)");
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
System.out.println("time: " + time); System.out.println("time: " + time);
// lzf: 5688 / 11944 kb // lzf: 5688 / 11944 kb
......
...@@ -40,12 +40,12 @@ public class Coverage { ...@@ -40,12 +40,12 @@ public class Coverage {
System.out System.out
.println("Usage:\n" .println("Usage:\n"
+ "- copy all your source files to another directory\n" + "- copy all your source files to another directory\n"
+ " (be carefull, they will be modified - don't take originals!)\n" + " (be careful, they will be modified - don't take originals!)\n"
+ "- java " + getClass().getName() + " <directory>\n" + "- java " + getClass().getName() + " <directory>\n"
+ " this will modified the source code and create 'profile.txt'\n" + " this will modified the source code and create 'profile.txt'\n"
+ "- compile the modified source files\n" + "- compile the modified source files\n"
+ "- run your main application\n" + "- run your main application\n"
+ "- after the application exits, a file 'notcovered.txt' is created,\n" + "- after the application exits, a file 'notCovered.txt' is created,\n"
+ " which contains the class names, function names and line numbers\n" + " which contains the class names, function names and line numbers\n"
+ " of code that has not been covered\n\n" + " of code that has not been covered\n\n"
+ "Options:\n" + "Options:\n"
...@@ -154,9 +154,9 @@ public class Coverage { ...@@ -154,9 +154,9 @@ public class Coverage {
return; return;
} }
File f = new File(name); File f = new File(name);
File fnew = new File(name + ".new"); File fileNew = new File(name + ".new");
try { try {
writer = new BufferedWriter(new FileWriter(fnew)); writer = new BufferedWriter(new FileWriter(fileNew));
Reader r = new BufferedReader(new FileReader(f)); Reader r = new BufferedReader(new FileReader(f));
tokenizer = new Tokenizer(r); tokenizer = new Tokenizer(r);
indent = 0; indent = 0;
...@@ -171,11 +171,11 @@ public class Coverage { ...@@ -171,11 +171,11 @@ public class Coverage {
} }
r.close(); r.close();
writer.close(); writer.close();
File fbak = new File(name + ".bak"); File backup = new File(name + ".bak");
fbak.delete(); backup.delete();
f.renameTo(fbak); f.renameTo(backup);
File fcopy = new File(name); File copy = new File(name);
fnew.renameTo(fcopy); fileNew.renameTo(copy);
if (perClass) { if (perClass) {
nextDebug(); nextDebug();
} }
...@@ -320,11 +320,11 @@ public class Coverage { ...@@ -320,11 +320,11 @@ public class Coverage {
} }
} }
void processBraket() throws Exception { void processBracket() throws Exception {
do { do {
if (token.equals("(")) { if (token.equals("(")) {
read(); read();
processBraket(); processBracket();
} else if (token.equals(")")) { } else if (token.equals(")")) {
read(); read();
return; return;
...@@ -365,7 +365,7 @@ public class Coverage { ...@@ -365,7 +365,7 @@ public class Coverage {
|| token.equals("synchronized")) { || token.equals("synchronized")) {
read(); read();
readThis("("); readThis("(");
processBraket(); processBracket();
indent++; indent++;
processBlockOrStatement(); processBlockOrStatement();
indent--; indent--;
...@@ -373,7 +373,7 @@ public class Coverage { ...@@ -373,7 +373,7 @@ public class Coverage {
} else if (token.equals("if")) { } else if (token.equals("if")) {
read(); read();
readThis("("); readThis("(");
processBraket(); processBracket();
indent++; indent++;
processBlockOrStatement(); processBlockOrStatement();
indent--; indent--;
...@@ -393,7 +393,7 @@ public class Coverage { ...@@ -393,7 +393,7 @@ public class Coverage {
if (token.equals("catch")) { if (token.equals("catch")) {
read(); read();
readThis("("); readThis("(");
processBraket(); processBracket();
indent++; indent++;
processBlockOrStatement(); processBlockOrStatement();
indent--; indent--;
...@@ -431,7 +431,7 @@ public class Coverage { ...@@ -431,7 +431,7 @@ public class Coverage {
processBlockOrStatement(); processBlockOrStatement();
readThis("while"); readThis("while");
readThis("("); readThis("(");
processBraket(); processBracket();
readThis(";"); readThis(";");
setLine(); setLine();
indent--; indent--;
...@@ -452,7 +452,7 @@ public class Coverage { ...@@ -452,7 +452,7 @@ public class Coverage {
} else if (token.equals("switch")) { } else if (token.equals("switch")) {
read(); read();
readThis("("); readThis("(");
processBraket(); processBracket();
indent++; indent++;
processBlockOrStatement(); processBlockOrStatement();
indent--; indent--;
...@@ -463,7 +463,7 @@ public class Coverage { ...@@ -463,7 +463,7 @@ public class Coverage {
return; return;
} else if (token.equals("(")) { } else if (token.equals("(")) {
read(); read();
processBraket(); processBracket();
} else if (token.equals("=")) { } else if (token.equals("=")) {
read(); read();
if (token.equals("{")) { if (token.equals("{")) {
...@@ -493,8 +493,8 @@ public class Coverage { ...@@ -493,8 +493,8 @@ public class Coverage {
String func = i<0 ? function : function.substring(0, i); String func = i<0 ? function : function.substring(0, i);
String fileLine = file + "." + func +"("; String fileLine = file + "." + func +"(";
i = file.lastIndexOf('.'); i = file.lastIndexOf('.');
String fil = i<0 ? file : file.substring(i+1); String className = i<0 ? file : file.substring(i+1);
fileLine += fil + ".java:" + line + ")"; fileLine += className + ".java:" + line + ")";
data.write(fileLine + " " + last + "\r\n"); data.write(fileLine + " " + last + "\r\n");
} else { } else {
data.write(file + " " + line + "\r\n"); data.write(file + " " + line + "\r\n");
......
...@@ -121,14 +121,14 @@ public class Profile extends Thread { ...@@ -121,14 +121,14 @@ public class Profile extends Thread {
print("NOT COVERED"); print("NOT COVERED");
printLine('-'); printLine('-');
FileReader reader = null; FileReader reader = null;
FileWriter fwriter = null; FileWriter fileWriter = null;
try { try {
reader = new FileReader("profile.txt"); reader = new FileReader("profile.txt");
LineNumberReader r = new LineNumberReader(reader); LineNumberReader r = new LineNumberReader(reader);
fwriter = new FileWriter("notcovered.txt"); fileWriter = new FileWriter("notCovered.txt");
BufferedWriter writer = new BufferedWriter(fwriter); BufferedWriter writer = new BufferedWriter(fileWriter);
int unvisited = 0; int unvisited = 0;
int unvisitedthrow = 0; int unvisitedThrow = 0;
for (int i = 0; i < maxIndex; i++) { for (int i = 0; i < maxIndex; i++) {
String line = r.readLine(); String line = r.readLine();
if (count[i] == 0) { if (count[i] == 0) {
...@@ -139,15 +139,15 @@ public class Profile extends Thread { ...@@ -139,15 +139,15 @@ public class Profile extends Thread {
} }
unvisited++; unvisited++;
} else { } else {
unvisitedthrow++; unvisitedThrow++;
} }
} }
} }
int percent = (100 * unvisited / maxIndex); int percent = (100 * unvisited / maxIndex);
print("Not covered: " + percent + " % " + " (" + unvisited + " of " print("Not covered: " + percent + " % " + " (" + unvisited + " of "
+ maxIndex + "; throw=" + unvisitedthrow + ")"); + maxIndex + "; throw=" + unvisitedThrow + ")");
} finally { } finally {
IOUtils.closeSilently(fwriter); IOUtils.closeSilently(fileWriter);
IOUtils.closeSilently(reader); IOUtils.closeSilently(reader);
} }
} }
...@@ -155,16 +155,16 @@ public class Profile extends Thread { ...@@ -155,16 +155,16 @@ public class Profile extends Thread {
void listTop(String title, int[] list, int max) throws Exception { void listTop(String title, int[] list, int max) throws Exception {
printLine('-'); printLine('-');
int total = 0; int total = 0;
int totallines = 0; int totalLines = 0;
for (int j = 0; j < maxIndex; j++) { for (int j = 0; j < maxIndex; j++) {
int l = list[j]; int l = list[j];
if (l > 0) { if (l > 0) {
total += list[j]; total += list[j];
totallines++; totalLines++;
} }
} }
if (max == 0) { if (max == 0) {
max = totallines; max = totalLines;
} }
print(title); print(title);
print("Total: " + total); print("Total: " + total);
......
...@@ -16,8 +16,8 @@ public class Tokenizer { ...@@ -16,8 +16,8 @@ public class Tokenizer {
private Reader reader; private Reader reader;
private char[] buf = new char[20]; private char[] chars = new char[20];
private int peekc; private int peekChar;
private int line = 1; private int line = 1;
private byte[] charTypes = new byte[256]; private byte[] charTypes = new byte[256];
...@@ -98,7 +98,7 @@ public class Tokenizer { ...@@ -98,7 +98,7 @@ public class Tokenizer {
type = c; type = c;
} }
} else { } else {
c = peekc; c = peekChar;
if (c < 0) { if (c < 0) {
try { try {
c = read(); c = read();
...@@ -114,8 +114,8 @@ public class Tokenizer { ...@@ -114,8 +114,8 @@ public class Tokenizer {
if (c < 0) { if (c < 0) {
return type = TYPE_EOF; return type = TYPE_EOF;
} }
int ctype = c < 256 ? ct[c] : ALPHA; int charType = c < 256 ? ct[c] : ALPHA;
while ((ctype & WHITESPACE) != 0) { while ((charType & WHITESPACE) != 0) {
if (c == '\r') { if (c == '\r') {
line++; line++;
c = read(); c = read();
...@@ -131,36 +131,36 @@ public class Tokenizer { ...@@ -131,36 +131,36 @@ public class Tokenizer {
if (c < 0) { if (c < 0) {
return type = TYPE_EOF; return type = TYPE_EOF;
} }
ctype = c < 256 ? ct[c] : ALPHA; charType = c < 256 ? ct[c] : ALPHA;
} }
if ((ctype & ALPHA) != 0) { if ((charType & ALPHA) != 0) {
initToken(); initToken();
append(c); append(c);
int i = 0; int i = 0;
do { do {
if (i >= buf.length) { if (i >= chars.length) {
char[] nb = new char[buf.length * 2]; char[] nb = new char[chars.length * 2];
System.arraycopy(buf, 0, nb, 0, buf.length); System.arraycopy(chars, 0, nb, 0, chars.length);
buf = nb; chars = nb;
} }
buf[i++] = (char) c; chars[i++] = (char) c;
c = read(); c = read();
ctype = c < 0 ? WHITESPACE : c < 256 ? ct[c] : ALPHA; charType = c < 0 ? WHITESPACE : c < 256 ? ct[c] : ALPHA;
} while ((ctype & ALPHA) != 0); } while ((charType & ALPHA) != 0);
peekc = c; peekChar = c;
value = String.copyValueOf(buf, 0, i); value = String.copyValueOf(chars, 0, i);
return type = TYPE_WORD; return type = TYPE_WORD;
} }
if ((ctype & QUOTE) != 0) { if ((charType & QUOTE) != 0) {
initToken(); initToken();
append(c); append(c);
type = c; type = c;
int i = 0; int i = 0;
// \octal needs a lookahead // \octal needs a lookahead
peekc = read(); peekChar = read();
while (peekc >= 0 && peekc != type && peekc != '\n' while (peekChar >= 0 && peekChar != type && peekChar != '\n'
&& peekc != '\r') { && peekChar != '\r') {
if (peekc == '\\') { if (peekChar == '\\') {
c = read(); c = read();
int first = c; // to allow \377, but not \477 int first = c; // to allow \377, but not \477
if (c >= '0' && c <= '7') { if (c >= '0' && c <= '7') {
...@@ -171,12 +171,12 @@ public class Tokenizer { ...@@ -171,12 +171,12 @@ public class Tokenizer {
c2 = read(); c2 = read();
if ('0' <= c2 && c2 <= '7' && first <= '3') { if ('0' <= c2 && c2 <= '7' && first <= '3') {
c = (c << 3) + (c2 - '0'); c = (c << 3) + (c2 - '0');
peekc = read(); peekChar = read();
} else { } else {
peekc = c2; peekChar = c2;
} }
} else { } else {
peekc = c2; peekChar = c2;
} }
} else { } else {
switch (c) { switch (c) {
...@@ -196,32 +196,32 @@ public class Tokenizer { ...@@ -196,32 +196,32 @@ public class Tokenizer {
c = '\t'; c = '\t';
break; break;
} }
peekc = read(); peekChar = read();
} }
} else { } else {
c = peekc; c = peekChar;
peekc = read(); peekChar = read();
} }
if (i >= buf.length) { if (i >= chars.length) {
char[] nb = new char[buf.length * 2]; char[] nb = new char[chars.length * 2];
System.arraycopy(buf, 0, nb, 0, buf.length); System.arraycopy(chars, 0, nb, 0, chars.length);
buf = nb; chars = nb;
} }
buf[i++] = (char) c; chars[i++] = (char) c;
} }
if (peekc == type) { if (peekChar == type) {
// keep \n or \r intact in peekc // keep \n or \r intact in peekChar
peekc = read(); peekChar = read();
} }
value = String.copyValueOf(buf, 0, i); value = String.copyValueOf(chars, 0, i);
return type; return type;
} }
if (c == '/') { if (c == '/') {
c = read(); c = read();
if (c == '*') { if (c == '*') {
int prevc = 0; int prevChar = 0;
while ((c = read()) != '/' || prevc != '*') { while ((c = read()) != '/' || prevChar != '*') {
if (c == '\r') { if (c == '\r') {
line++; line++;
c = read(); c = read();
...@@ -237,22 +237,22 @@ public class Tokenizer { ...@@ -237,22 +237,22 @@ public class Tokenizer {
if (c < 0) { if (c < 0) {
return type = TYPE_EOF; return type = TYPE_EOF;
} }
prevc = c; prevChar = c;
} }
peekc = read(); peekChar = read();
return nextToken(); return nextToken();
} else if (c == '/') { } else if (c == '/') {
while ((c = read()) != '\n' && c != '\r' && c >= 0) { while ((c = read()) != '\n' && c != '\r' && c >= 0) {
// nothing // nothing
} }
peekc = c; peekChar = c;
return nextToken(); return nextToken();
} else { } else {
peekc = c; peekChar = c;
return type = '/'; return type = '/';
} }
} }
peekc = read(); peekChar = read();
return type = c; return type = c;
} }
......
...@@ -12,14 +12,14 @@ public class TestBatchUpdates extends TestBase { ...@@ -12,14 +12,14 @@ public class TestBatchUpdates extends TestBase {
static final String COFFEE_UPDATE = "UPDATE TEST SET PRICE=PRICE*20 WHERE TYPE_ID=?"; static final String COFFEE_UPDATE = "UPDATE TEST SET PRICE=PRICE*20 WHERE TYPE_ID=?";
static final String COFFEE_SELECT = "SELECT PRICE FROM TEST WHERE KEY_ID=?"; static final String COFFEE_SELECT = "SELECT PRICE FROM TEST WHERE KEY_ID=?";
static final String COFFEE_QUERY = "SELECT COF_NAME,PRICE FROM TEST WHERE TYPE_ID=?"; static final String COFFEE_QUERY = "SELECT C_NAME,PRICE FROM TEST WHERE TYPE_ID=?";
static final String COFFEE_DELETE = "DELETE FROM TEST WHERE KEY_ID=?"; static final String COFFEE_DELETE = "DELETE FROM TEST WHERE KEY_ID=?";
static final String COFFEE_INSERT1 = "INSERT INTO TEST VALUES(9,'COFFEE-9',9.0,5)"; static final String COFFEE_INSERT1 = "INSERT INTO TEST VALUES(9,'COFFEE-9',9.0,5)";
static final String COFFEE_DELETE1 = "DELETE FROM TEST WHERE KEY_ID=9"; static final String COFFEE_DELETE1 = "DELETE FROM TEST WHERE KEY_ID=9";
static final String COFFEE_UPDATE1 = "UPDATE TEST SET PRICE=PRICE*20 WHERE TYPE_ID=1"; static final String COFFEE_UPDATE1 = "UPDATE TEST SET PRICE=PRICE*20 WHERE TYPE_ID=1";
static final String COFFEE_SELECT1 = "SELECT PRICE FROM TEST WHERE KEY_ID>4"; static final String COFFEE_SELECT1 = "SELECT PRICE FROM TEST WHERE KEY_ID>4";
static final String COFFEE_UPDATE_SET = "UPDATE TEST SET KEY_ID=?, COF_NAME=? WHERE COF_NAME=?"; static final String COFFEE_UPDATE_SET = "UPDATE TEST SET KEY_ID=?, C_NAME=? WHERE C_NAME=?";
static final String COFFEE_SELECT_CONTINUED = "SELECT COUNT(*) FROM TEST WHERE COF_NAME='Continue-1'"; static final String COFFEE_SELECT_CONTINUED = "SELECT COUNT(*) FROM TEST WHERE C_NAME='Continue-1'";
int coffeeSize = 10; int coffeeSize = 10;
int coffeeType = 11; int coffeeType = 11;
...@@ -36,7 +36,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -36,7 +36,7 @@ public class TestBatchUpdates extends TestBase {
error("does not support BatchUpdates"); error("does not support BatchUpdates");
} }
stat.executeUpdate("CREATE TABLE TEST(KEY_ID INT PRIMARY KEY," stat.executeUpdate("CREATE TABLE TEST(KEY_ID INT PRIMARY KEY,"
+ "COF_NAME VARCHAR(255),PRICE DECIMAL(20,2),TYPE_ID INT)"); + "C_NAME VARCHAR(255),PRICE DECIMAL(20,2),TYPE_ID INT)");
String newName = null; String newName = null;
float newPrice = 0; float newPrice = 0;
int newType = 0; int newType = 0;
...@@ -86,7 +86,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -86,7 +86,7 @@ public class TestBatchUpdates extends TestBase {
prep.setInt(1, 4); prep.setInt(1, 4);
prep.addBatch(); prep.addBatch();
int[] updateCount = prep.executeBatch(); int[] updateCount = prep.executeBatch();
int updateCountlen = updateCount.length; int updateCountLen = updateCount.length;
// PreparedStatement p; // PreparedStatement p;
// p = conn.prepareStatement(COFFEE_UPDATE); // p = conn.prepareStatement(COFFEE_UPDATE);
...@@ -98,8 +98,8 @@ public class TestBatchUpdates extends TestBase { ...@@ -98,8 +98,8 @@ public class TestBatchUpdates extends TestBase {
// System.out.println("upc="+p.executeUpdate()); // System.out.println("upc="+p.executeUpdate());
trace("updateCount length:" + updateCountlen); trace("updateCount length:" + updateCountLen);
if (updateCountlen != 3) { if (updateCountLen != 3) {
error("addBatch"); error("addBatch");
} else { } else {
trace("addBatch add the SQL statements to Batch "); trace("addBatch add the SQL statements to Batch ");
...@@ -239,10 +239,10 @@ public class TestBatchUpdates extends TestBase { ...@@ -239,10 +239,10 @@ public class TestBatchUpdates extends TestBase {
rs = stat.executeQuery(query3); rs = stat.executeQuery(query3);
rs.next(); rs.next();
retValue[i++] = rs.getInt(1); retValue[i++] = rs.getInt(1);
trace("retvalue length : " + retValue.length); trace("retValue length : " + retValue.length);
for (int j = 0; j < updateCount.length; j++) { for (int j = 0; j < updateCount.length; j++) {
trace("UpdateCount Value:" + updateCount[j]); trace("UpdateCount Value:" + updateCount[j]);
trace("Retvalue : " + retValue[j]); trace("RetValue : " + retValue[j]);
if (updateCount[j] != retValue[j]) { if (updateCount[j] != retValue[j]) {
error("j=" + j + " right:" + retValue[j]); error("j=" + j + " right:" + retValue[j]);
} }
...@@ -269,7 +269,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -269,7 +269,7 @@ public class TestBatchUpdates extends TestBase {
public void testExecuteBatch03() throws Exception { public void testExecuteBatch03() throws Exception {
trace("testExecuteBatch03"); trace("testExecuteBatch03");
boolean bexpflag = false; boolean batchExceptionFlag = false;
String sPrepStmt = COFFEE_SELECT; String sPrepStmt = COFFEE_SELECT;
trace("Prepared Statement String :" + sPrepStmt); trace("Prepared Statement String :" + sPrepStmt);
prep = conn.prepareStatement(sPrepStmt); prep = conn.prepareStatement(sPrepStmt);
...@@ -279,9 +279,9 @@ public class TestBatchUpdates extends TestBase { ...@@ -279,9 +279,9 @@ public class TestBatchUpdates extends TestBase {
int[] updateCount = prep.executeBatch(); int[] updateCount = prep.executeBatch();
trace("Update Count" + updateCount.length); trace("Update Count" + updateCount.length);
} catch (BatchUpdateException b) { } catch (BatchUpdateException b) {
bexpflag = true; batchExceptionFlag = true;
} }
if (bexpflag) { if (batchExceptionFlag) {
trace("select not allowed; correct"); trace("select not allowed; correct");
} else { } else {
error("executeBatch select"); error("executeBatch select");
...@@ -339,7 +339,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -339,7 +339,7 @@ public class TestBatchUpdates extends TestBase {
public void testExecuteBatch06() throws Exception { public void testExecuteBatch06() throws Exception {
trace("testExecuteBatch06"); trace("testExecuteBatch06");
boolean bexpflag = false; boolean batchExceptionFlag = false;
//Insert a row which is already Present //Insert a row which is already Present
String sInsCoffee = COFFEE_INSERT1; String sInsCoffee = COFFEE_INSERT1;
String sDelCoffee = COFFEE_DELETE1; String sDelCoffee = COFFEE_DELETE1;
...@@ -349,13 +349,13 @@ public class TestBatchUpdates extends TestBase { ...@@ -349,13 +349,13 @@ public class TestBatchUpdates extends TestBase {
try { try {
stat.executeBatch(); stat.executeBatch();
} catch (BatchUpdateException b) { } catch (BatchUpdateException b) {
bexpflag = true; batchExceptionFlag = true;
int[] updCounts = b.getUpdateCounts(); int[] updCounts = b.getUpdateCounts();
for (int i = 0; i < updCounts.length; i++) { for (int i = 0; i < updCounts.length; i++) {
trace("Update counts:" + updCounts[i]); trace("Update counts:" + updCounts[i]);
} }
} }
if (bexpflag) { if (batchExceptionFlag) {
trace("executeBatch insert duplicate; correct"); trace("executeBatch insert duplicate; correct");
} else { } else {
error("executeBatch"); error("executeBatch");
...@@ -364,18 +364,18 @@ public class TestBatchUpdates extends TestBase { ...@@ -364,18 +364,18 @@ public class TestBatchUpdates extends TestBase {
public void testExecuteBatch07() throws Exception { public void testExecuteBatch07() throws Exception {
trace("testExecuteBatch07"); trace("testExecuteBatch07");
boolean bexpflag = false; boolean batchExceptionFlag = false;
String sSelCoffee = COFFEE_SELECT1; String selectCoffee = COFFEE_SELECT1;
trace("sSelCoffee = " + sSelCoffee); trace("selectCoffee = " + selectCoffee);
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.addBatch(sSelCoffee); stmt.addBatch(selectCoffee);
try { try {
int[] updateCount = stmt.executeBatch(); int[] updateCount = stmt.executeBatch();
trace("updateCount Length : " + updateCount.length); trace("updateCount Length : " + updateCount.length);
} catch (BatchUpdateException be) { } catch (BatchUpdateException be) {
bexpflag = true; batchExceptionFlag = true;
} }
if (bexpflag) { if (batchExceptionFlag) {
trace("executeBatch select"); trace("executeBatch select");
} else { } else {
error("executeBatch"); error("executeBatch");
...@@ -385,7 +385,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -385,7 +385,7 @@ public class TestBatchUpdates extends TestBase {
public void testContinueBatch01() throws Exception { public void testContinueBatch01() throws Exception {
trace("testContinueBatch01"); trace("testContinueBatch01");
int[] batchUpdates = { 0, 0, 0}; int[] batchUpdates = { 0, 0, 0};
int buCountlen = 0; int buCountLen = 0;
try { try {
String sPrepStmt = COFFEE_UPDATE_SET; String sPrepStmt = COFFEE_UPDATE_SET;
trace("Prepared Statement String:" + sPrepStmt); trace("Prepared Statement String:" + sPrepStmt);
...@@ -416,12 +416,12 @@ public class TestBatchUpdates extends TestBase { ...@@ -416,12 +416,12 @@ public class TestBatchUpdates extends TestBase {
} catch (BatchUpdateException b) { } catch (BatchUpdateException b) {
trace("expected BatchUpdateException"); trace("expected BatchUpdateException");
batchUpdates = b.getUpdateCounts(); batchUpdates = b.getUpdateCounts();
buCountlen = batchUpdates.length; buCountLen = batchUpdates.length;
} }
if (buCountlen == 1) { if (buCountLen == 1) {
trace("no continued updates - OK"); trace("no continued updates - OK");
return; return;
} else if (buCountlen == 3) { } else if (buCountLen == 3) {
trace("Driver supports continued updates."); trace("Driver supports continued updates.");
// Check to see if the third row from the batch was added // Check to see if the third row from the batch was added
String query = COFFEE_SELECT_CONTINUED; String query = COFFEE_SELECT_CONTINUED;
......
...@@ -31,45 +31,45 @@ public class TestBigDb extends TestBase { ...@@ -31,45 +31,45 @@ public class TestBigDb extends TestBase {
Connection conn = getConnection("bigDb"); Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute( stat.execute(
"CREATE CACHED TABLE PAB_ARTLEV("+ "CREATE CACHED TABLE TEST("+
"MUTATIECODE CHAR(1) DEFAULT CAST(RAND()*9 AS INT),"+ "M_CODE CHAR(1) DEFAULT CAST(RAND()*9 AS INT),"+
"PRDCODE CHAR(20) DEFAULT SECURE_RAND(10),"+ "PRD_CODE CHAR(20) DEFAULT SECURE_RAND(10),"+
"ORGCODESUPPLIER CHAR(13) DEFAULT SECURE_RAND(6),"+ "ORG_CODE_SUPPLIER CHAR(13) DEFAULT SECURE_RAND(6),"+
"PRDCODEGTIN CHAR(14) DEFAULT SECURE_RAND(7),"+ "PRD_CODE_1 CHAR(14) DEFAULT SECURE_RAND(7),"+
"PRDCODEMF CHAR(20) DEFAULT SECURE_RAND(10),"+ "PRD_CODE_2 CHAR(20) DEFAULT SECURE_RAND(10),"+
"ORGCODEMF CHAR(13) DEFAULT SECURE_RAND(6),"+ "ORG_CODE CHAR(13) DEFAULT SECURE_RAND(6),"+
"SUBSTITUTEDBY CHAR(20) DEFAULT SECURE_RAND(10),"+ "SUBSTITUTED_BY CHAR(20) DEFAULT SECURE_RAND(10),"+
"SUBSTITUTEDBYGTIN CHAR(14) DEFAULT SECURE_RAND(7),"+ "SUBSTITUTED_BY_2 CHAR(14) DEFAULT SECURE_RAND(7),"+
"SUBSTITUTIONFOR CHAR(20) DEFAULT SECURE_RAND(10),"+ "SUBSTITUTION_FOR CHAR(20) DEFAULT SECURE_RAND(10),"+
"SUBSTITUTIONFORGTIN CHAR(14) DEFAULT SECURE_RAND(7),"+ "SUBSTITUTION_FOR_2 CHAR(14) DEFAULT SECURE_RAND(7),"+
"VERWERKBAAR CHAR(2) DEFAULT SECURE_RAND(1),"+ "TEST CHAR(2) DEFAULT SECURE_RAND(1),"+
"BESTELBAAR CHAR(2) DEFAULT SECURE_RAND(1),"+ "TEST_2 CHAR(2) DEFAULT SECURE_RAND(1),"+
"AANTALGEBRUIKSEENHEDEN DECIMAL(7,2) DEFAULT RAND(),"+ "TEST_3 DECIMAL(7,2) DEFAULT RAND(),"+
"PRIMARYUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+ "PRIMARY_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"RATEPRICEORDERUNIT DECIMAL(9,3) DEFAULT RAND(),"+ "RATE_PRICE_ORDER_UNIT DECIMAL(9,3) DEFAULT RAND(),"+
"ORDERUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+ "ORDER_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"ORDERQTYMIN DECIMAL(6,1) DEFAULT RAND(),"+ "ORDER_QTY_MIN DECIMAL(6,1) DEFAULT RAND(),"+
"ORDERQTYLOTSIZE DECIMAL(6,1) DEFAULT RAND(),"+ "ORDER_QTY_LOT_SIZE DECIMAL(6,1) DEFAULT RAND(),"+
"ORDERUNITCODE2 CHAR(3) DEFAULT SECURE_RAND(1),"+ "ORDER_UNIT_CODE_2 CHAR(3) DEFAULT SECURE_RAND(1),"+
"PRICEGROUP CHAR(20) DEFAULT SECURE_RAND(10),"+ "PRICE_GROUP CHAR(20) DEFAULT SECURE_RAND(10),"+
"LEADTIME INTEGER DEFAULT RAND(),"+ "LEAD_TIME INTEGER DEFAULT RAND(),"+
"LEADTIMEUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+ "LEAD_TIME_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"PRDGROUP CHAR(10) DEFAULT SECURE_RAND(5),"+ "PRD_GROUP CHAR(10) DEFAULT SECURE_RAND(5),"+
"WEIGHTGROSS DECIMAL(7,3) DEFAULT RAND(),"+ "WEIGHT_GROSS DECIMAL(7,3) DEFAULT RAND(),"+
"WEIGHTUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+ "WEIGHT_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"PACKUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+ "PACK_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"PACKLENGTH DECIMAL(7,3) DEFAULT RAND(),"+ "PACK_LENGTH DECIMAL(7,3) DEFAULT RAND(),"+
"PACKWIDTH DECIMAL(7,3) DEFAULT RAND(),"+ "PACK_WIDTH DECIMAL(7,3) DEFAULT RAND(),"+
"PACKHEIGHT DECIMAL(7,3) DEFAULT RAND(),"+ "PACK_HEIGHT DECIMAL(7,3) DEFAULT RAND(),"+
"SIZEUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+ "SIZE_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"STATUCCODE CHAR(3) DEFAULT SECURE_RAND(1),"+ "STATUS_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"INTRASTATCODE CHAR(12) DEFAULT SECURE_RAND(6),"+ "INTRA_STAT_CODE CHAR(12) DEFAULT SECURE_RAND(6),"+
"PRDTITLE CHAR(50) DEFAULT SECURE_RAND(25),"+ "PRD_TITLE CHAR(50) DEFAULT SECURE_RAND(25),"+
"VALIDFROM DATE DEFAULT NOW(),"+ "VALID_FROM DATE DEFAULT NOW(),"+
"MUTATIEDATUM DATE DEFAULT NOW())"); "MOD_DATUM DATE DEFAULT NOW())");
int len = getSize(10, 50000); int len = getSize(10, 50000);
try { try {
PreparedStatement prep = conn.prepareStatement("INSERT INTO PAB_ARTLEV(PRDCODE) VALUES('abc' || ?)"); PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST(PRD_CODE) VALUES('abc' || ?)");
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
for(int i=0; i<len; i++) { for(int i=0; i<len; i++) {
if((i % 1000) == 0) { if((i % 1000) == 0) {
...@@ -83,8 +83,8 @@ public class TestBigDb extends TestBase { ...@@ -83,8 +83,8 @@ public class TestBigDb extends TestBase {
prep.setInt(1, i); prep.setInt(1, i);
prep.execute(); prep.execute();
} }
stat.execute("CREATE INDEX IDX_PAB_ARTLEV_PRDCODE ON PAB_ARTLEV(PRDCODE)"); stat.execute("CREATE INDEX IDX_TEST_PRD_CODE ON TEST(PRD_CODE)");
ResultSet rs = stat.executeQuery("SELECT * FROM PAB_ARTLEV"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
int columns = rs.getMetaData().getColumnCount(); int columns = rs.getMetaData().getColumnCount();
while(rs.next()) { while(rs.next()) {
for(int i=0; i<columns; i++) { for(int i=0; i<columns; i++) {
...@@ -104,7 +104,7 @@ public class TestBigDb extends TestBase { ...@@ -104,7 +104,7 @@ public class TestBigDb extends TestBase {
Connection conn = getConnection("bigDb"); Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT, NEG INT AS -ID, NAME VARCHAR, PRIMARY KEY(ID, NAME))"); stat.execute("CREATE TABLE TEST(ID INT, NEG INT AS -ID, NAME VARCHAR, PRIMARY KEY(ID, NAME))");
stat.execute("CREATE INDEX IDXNEG ON TEST(NEG, NAME)"); stat.execute("CREATE INDEX IDX_NEG ON TEST(NEG, NAME)");
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST(ID, NAME) VALUES(?, '1234567890')"); PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST(ID, NAME) VALUES(?, '1234567890')");
int len = getSize(10, 1000); int len = getSize(10, 1000);
int block = getSize(3, 10); int block = getSize(3, 10);
......
...@@ -22,6 +22,7 @@ public class TestCases extends TestBase { ...@@ -22,6 +22,7 @@ public class TestCases extends TestBase {
public void test() throws Exception { public void test() throws Exception {
testDeleteGroup();
testDisconnect(); testDisconnect();
testExecuteTrace(); testExecuteTrace();
if(config.memory || config.logMode == 0) { if(config.memory || config.logMode == 0) {
...@@ -49,6 +50,17 @@ public class TestCases extends TestBase { ...@@ -49,6 +50,17 @@ public class TestCases extends TestBase {
testCollation(); testCollation();
} }
private void testDeleteGroup() throws Exception {
deleteDb("cases");
Connection conn=getConnection("cases");
Statement stat = conn.createStatement();
stat.execute("set max_memory_rows 2");
stat.execute("create table test(id int primary key, x int)");
stat.execute("insert into test values(0, 0), (1, 1), (2, 2)");
stat.execute("delete from test where id not in (select min(x) from test group by id)");
conn.close();
}
private void testSpecialSQL() throws Exception { private void testSpecialSQL() throws Exception {
deleteDb("cases"); deleteDb("cases");
Connection conn=getConnection("cases"); Connection conn=getConnection("cases");
...@@ -305,13 +317,13 @@ public class TestCases extends TestBase { ...@@ -305,13 +317,13 @@ public class TestCases extends TestBase {
ps.setTimestamp(2, orderDate); ps.setTimestamp(2, orderDate);
ps.setInt(3, 2222); ps.setInt(3, 2222);
ps.setString(4, "test desc"); ps.setString(4, "test desc");
ps.setString(5, "teststate"); ps.setString(5, "test_state");
ps.setString(6, "testid"); ps.setString(6, "testid");
ps.setInt(7, 5556); ps.setInt(7, 5556);
ps.setTimestamp(8, orderDate); ps.setTimestamp(8, orderDate);
ps.setInt(9, 2222); ps.setInt(9, 2222);
ps.setString(10, "test desc"); ps.setString(10, "test desc");
ps.setString(11, "teststate"); ps.setString(11, "test_state");
ps.setString(12, "testid"); ps.setString(12, "testid");
check(ps.executeUpdate(), 2); check(ps.executeUpdate(), 2);
ps.close(); ps.close();
...@@ -582,7 +594,7 @@ public class TestCases extends TestBase { ...@@ -582,7 +594,7 @@ public class TestCases extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute( stat.execute(
"create table employee(id int, " "create table employee(id int, "
+"firstname VARCHAR(50), " +"firstName VARCHAR(50), "
+"salary decimal(10, 2), " +"salary decimal(10, 2), "
+"superior_id int, " +"superior_id int, "
+"CONSTRAINT PK_employee PRIMARY KEY (id), " +"CONSTRAINT PK_employee PRIMARY KEY (id), "
...@@ -600,13 +612,13 @@ public class TestCases extends TestBase { ...@@ -600,13 +612,13 @@ public class TestCases extends TestBase {
Connection c0=getConnection("cases"); Connection c0=getConnection("cases");
c0.createStatement().executeUpdate("SET AUTOCOMMIT FALSE"); c0.createStatement().executeUpdate("SET AUTOCOMMIT FALSE");
c0.createStatement().executeUpdate("create table australia (ID INTEGER NOT NULL, Name VARCHAR(100), FirstName VARCHAR(100), Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))"); c0.createStatement().executeUpdate("create table australia (ID INTEGER NOT NULL, Name VARCHAR(100), firstName VARCHAR(100), Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))");
c0.createStatement().executeUpdate("COMMIT"); c0.createStatement().executeUpdate("COMMIT");
c0.close(); c0.close();
c0=getConnection("cases"); c0=getConnection("cases");
c0.createStatement().executeUpdate("SET AUTOCOMMIT FALSE"); c0.createStatement().executeUpdate("SET AUTOCOMMIT FALSE");
PreparedStatement p15=c0.prepareStatement("insert into australia (id,Name,FirstName,Points,LicenseID) values (?,?,?,?,?)"); PreparedStatement p15=c0.prepareStatement("insert into australia (id,Name,firstName,Points,LicenseID) values (?,?,?,?,?)");
int len = getSize(1, 1000); int len = getSize(1, 1000);
for(int i=0; i<len; i++) { for(int i=0; i<len; i++) {
p15.setInt(1, i); p15.setString(2, "Pilot_"+i); p15.setString(3, "Herkules"); p15.setInt(4, i); p15.setInt(5, i); p15.executeUpdate(); p15.setInt(1, i); p15.setString(2, "Pilot_"+i); p15.setString(3, "Herkules"); p15.setInt(4, i); p15.setInt(5, i); p15.executeUpdate();
...@@ -630,7 +642,7 @@ public class TestCases extends TestBase { ...@@ -630,7 +642,7 @@ public class TestCases extends TestBase {
c0=getConnection("cases"); c0=getConnection("cases");
c0.createStatement().executeUpdate("SET AUTOCOMMIT FALSE"); c0.createStatement().executeUpdate("SET AUTOCOMMIT FALSE");
c0.createStatement().executeUpdate("drop table australia"); c0.createStatement().executeUpdate("drop table australia");
c0.createStatement().executeUpdate("create table australia (ID INTEGER NOT NULL, Name VARCHAR(100), FirstName VARCHAR(100), Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))"); c0.createStatement().executeUpdate("create table australia (ID INTEGER NOT NULL, Name VARCHAR(100), firstName VARCHAR(100), Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))");
c0.createStatement().executeUpdate("COMMIT"); c0.createStatement().executeUpdate("COMMIT");
c0.close(); c0.close();
......
...@@ -30,9 +30,9 @@ public class TestFunctions extends TestBase { ...@@ -30,9 +30,9 @@ public class TestFunctions extends TestBase {
test("abs(1)", "1"); test("abs(1)", "1");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
stat.execute("CREATE ALIAS ADDROW FOR \"" + getClass().getName() + ".addRow\""); stat.execute("CREATE ALIAS ADD_ROW FOR \"" + getClass().getName() + ".addRow\"");
ResultSet rs; ResultSet rs;
rs = stat.executeQuery("CALL ADDROW(1, 'Hello')"); rs = stat.executeQuery("CALL ADD_ROW(1, 'Hello')");
rs.next(); rs.next();
check(rs.getInt(1), 1); check(rs.getInt(1), 1);
rs = stat.executeQuery("SELECT * FROM TEST"); rs = stat.executeQuery("SELECT * FROM TEST");
...@@ -41,10 +41,10 @@ public class TestFunctions extends TestBase { ...@@ -41,10 +41,10 @@ public class TestFunctions extends TestBase {
check(rs.getString(2), "Hello"); check(rs.getString(2), "Hello");
checkFalse(rs.next()); checkFalse(rs.next());
rs = stat.executeQuery("CALL ADDROW(2, 'World')"); rs = stat.executeQuery("CALL ADD_ROW(2, 'World')");
stat.execute("CREATE ALIAS SEL FOR \"" + getClass().getName() + ".select\""); stat.execute("CREATE ALIAS SELECT_F FOR \"" + getClass().getName() + ".select\"");
rs = stat.executeQuery("CALL SEL('SELECT * FROM TEST ORDER BY ID')"); rs = stat.executeQuery("CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')");
check(rs.getMetaData().getColumnCount(), 2); check(rs.getMetaData().getColumnCount(), 2);
rs.next(); rs.next();
check(rs.getInt(1), 1); check(rs.getInt(1), 1);
...@@ -54,7 +54,7 @@ public class TestFunctions extends TestBase { ...@@ -54,7 +54,7 @@ public class TestFunctions extends TestBase {
check(rs.getString(2), "World"); check(rs.getString(2), "World");
checkFalse(rs.next()); checkFalse(rs.next());
rs = stat.executeQuery("SELECT NAME FROM SEL('SELECT * FROM TEST ORDER BY NAME') ORDER BY NAME DESC"); rs = stat.executeQuery("SELECT NAME FROM SELECT_F('SELECT * FROM TEST ORDER BY NAME') ORDER BY NAME DESC");
check(rs.getMetaData().getColumnCount(), 1); check(rs.getMetaData().getColumnCount(), 1);
rs.next(); rs.next();
check(rs.getString(1), "World"); check(rs.getString(1), "World");
...@@ -62,7 +62,7 @@ public class TestFunctions extends TestBase { ...@@ -62,7 +62,7 @@ public class TestFunctions extends TestBase {
check(rs.getString(1), "Hello"); check(rs.getString(1), "Hello");
checkFalse(rs.next()); checkFalse(rs.next());
rs = stat.executeQuery("SELECT SEL('SELECT * FROM TEST WHERE ID=' || ID) FROM TEST ORDER BY ID"); rs = stat.executeQuery("SELECT SELECT_F('SELECT * FROM TEST WHERE ID=' || ID) FROM TEST ORDER BY ID");
check(rs.getMetaData().getColumnCount(), 1); check(rs.getMetaData().getColumnCount(), 1);
rs.next(); rs.next();
check("((1, Hello))", rs.getString(1)); check("((1, Hello))", rs.getString(1));
...@@ -70,14 +70,14 @@ public class TestFunctions extends TestBase { ...@@ -70,14 +70,14 @@ public class TestFunctions extends TestBase {
check("((2, World))", rs.getString(1)); check("((2, World))", rs.getString(1));
checkFalse(rs.next()); checkFalse(rs.next());
rs = stat.executeQuery("SELECT SEL('SELECT * FROM TEST ORDER BY ID') FROM DUAL"); rs = stat.executeQuery("SELECT SELECT_F('SELECT * FROM TEST ORDER BY ID') FROM DUAL");
check(rs.getMetaData().getColumnCount(), 1); check(rs.getMetaData().getColumnCount(), 1);
rs.next(); rs.next();
check("((1, Hello), (2, World))", rs.getString(1)); check("((1, Hello), (2, World))", rs.getString(1));
checkFalse(rs.next()); checkFalse(rs.next());
try { try {
rs = stat.executeQuery("CALL SEL('ERROR')"); rs = stat.executeQuery("CALL SELECT_F('ERROR')");
error("expected error"); error("expected error");
} catch (SQLException e) { } catch (SQLException e) {
check("42001", e.getSQLState()); check("42001", e.getSQLState());
...@@ -115,13 +115,13 @@ public class TestFunctions extends TestBase { ...@@ -115,13 +115,13 @@ public class TestFunctions extends TestBase {
check(rs.getInt(1), 3); check(rs.getInt(1), 3);
checkFalse(rs.next()); checkFalse(rs.next());
stat.execute("CREATE ALIAS MAXID FOR \"" + getClass().getName() + ".selectMaxId\""); stat.execute("CREATE ALIAS MAX_ID FOR \"" + getClass().getName() + ".selectMaxId\"");
rs = stat.executeQuery("CALL MAXID()"); rs = stat.executeQuery("CALL MAX_ID()");
rs.next(); rs.next();
check(rs.getInt(1), 2); check(rs.getInt(1), 2);
checkFalse(rs.next()); checkFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM MAXID()"); rs = stat.executeQuery("SELECT * FROM MAX_ID()");
rs.next(); rs.next();
check(rs.getInt(1), 2); check(rs.getInt(1), 2);
checkFalse(rs.next()); checkFalse(rs.next());
...@@ -145,8 +145,8 @@ public class TestFunctions extends TestBase { ...@@ -145,8 +145,8 @@ public class TestFunctions extends TestBase {
// ignore // ignore
} }
stat.execute("CREATE ALIAS NULLRESULT FOR \"" + getClass().getName() + ".nullResultSet\""); stat.execute("CREATE ALIAS NULL_RESULT FOR \"" + getClass().getName() + ".nullResultSet\"");
rs = stat.executeQuery("CALL NULLRESULT()"); rs = stat.executeQuery("CALL NULL_RESULT()");
check(rs.getMetaData().getColumnCount(), 1); check(rs.getMetaData().getColumnCount(), 1);
rs.next(); rs.next();
check(rs.getString(1), null); check(rs.getString(1), null);
...@@ -204,17 +204,17 @@ public class TestFunctions extends TestBase { ...@@ -204,17 +204,17 @@ public class TestFunctions extends TestBase {
return statement.executeQuery(); return statement.executeQuery();
} }
public static ResultSet simpleResultSet(Integer count, int ip, boolean bp, float fp, double dp, long lp, byte byp, short sp) throws SQLException { public static ResultSet simpleResultSet(Integer count, int ip, boolean bp, float fp, double dp, long lp, byte byParam, short sp) throws SQLException {
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("ID", Types.INTEGER, 10, 0); rs.addColumn("ID", Types.INTEGER, 10, 0);
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
if (count == null) { if (count == null) {
if (ip != 0 || bp || fp != 0.0 || dp != 0.0 || sp != 0 || lp != 0 || byp != 0) { if (ip != 0 || bp || fp != 0.0 || dp != 0.0 || sp != 0 || lp != 0 || byParam != 0) {
throw new Error("params not 0/false"); throw new Error("params not 0/false");
} }
} }
if (count != null) { if (count != null) {
if (ip != 1 || !bp || fp != 1.0 || dp != 1.0 || sp != 1 || lp != 1 || byp != 1) { if (ip != 1 || !bp || fp != 1.0 || dp != 1.0 || sp != 1 || lp != 1 || byParam != 1) {
throw new Error("params not 1/true"); throw new Error("params not 1/true");
} }
if (count.intValue() >= 1) { if (count.intValue() >= 1) {
......
...@@ -213,7 +213,7 @@ public class TestIndex extends TestBase { ...@@ -213,7 +213,7 @@ public class TestIndex extends TestBase {
stat.execute("DROP TABLE IF EXISTS TEST"); stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("CREATE TABLE TEST(A INT, B INT, DATA VARCHAR(255))"); stat.execute("CREATE TABLE TEST(A INT, B INT, DATA VARCHAR(255))");
stat.execute("CREATE UNIQUE HASH INDEX IDXAB ON TEST(A, B)"); stat.execute("CREATE UNIQUE HASH INDEX IDX_AB ON TEST(A, B)");
PreparedStatement prep; PreparedStatement prep;
prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?, ?)"); prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?, ?)");
// speed is quadratic (len*len) // speed is quadratic (len*len)
......
...@@ -192,7 +192,7 @@ public class TestLob extends TestBase { ...@@ -192,7 +192,7 @@ public class TestLob extends TestBase {
conn0.createStatement(); conn0.createStatement();
stat0.executeUpdate("drop table CLOB_ENTITY if exists"); stat0.executeUpdate("drop table CLOB_ENTITY if exists");
stat0.getWarnings(); stat0.getWarnings();
stat0.executeUpdate("create table CLOB_ENTITY (ID bigint not null, SER_DATA clob, CLOB_DATA clob, primary key (ID))"); stat0.executeUpdate("create table CLOB_ENTITY (ID bigint not null, DATA clob, CLOB_DATA clob, primary key (ID))");
stat0.getWarnings(); stat0.getWarnings();
stat0.close(); stat0.close();
conn0.getWarnings(); conn0.getWarnings();
...@@ -211,7 +211,7 @@ public class TestLob extends TestBase { ...@@ -211,7 +211,7 @@ public class TestLob extends TestBase {
prep0.close(); prep0.close();
conn0.getAutoCommit(); conn0.getAutoCommit();
PreparedStatement prep1 = PreparedStatement prep1 =
conn0.prepareStatement("insert into CLOB_ENTITY (SER_DATA, CLOB_DATA, ID) values (?, ?, ?)"); conn0.prepareStatement("insert into CLOB_ENTITY (DATA, CLOB_DATA, ID) values (?, ?, ?)");
prep1.setNull(1, 2005); prep1.setNull(1, 2005);
StringBuffer buff = new StringBuffer(10000); StringBuffer buff = new StringBuffer(10000);
for(int i=0; i<10000; i++) { for(int i=0; i<10000; i++) {
...@@ -232,12 +232,12 @@ public class TestLob extends TestBase { ...@@ -232,12 +232,12 @@ public class TestLob extends TestBase {
conn0.getAutoCommit(); conn0.getAutoCommit();
conn0.getAutoCommit(); conn0.getAutoCommit();
PreparedStatement prep2 = PreparedStatement prep2 =
conn0.prepareStatement("select clobholdin0_.ID as ID0_0_, clobholdin0_.SER_DATA as SER2_0_0_, clobholdin0_.CLOB_DATA as CLOB3_0_0_ from CLOB_ENTITY clobholdin0_ where clobholdin0_.ID=?"); conn0.prepareStatement("select c_.ID as ID0_0_, c_.DATA as S_, c_.CLOB_DATA as CLOB3_0_0_ from CLOB_ENTITY c_ where c_.ID=?");
prep2.setLong(1, 1); prep2.setLong(1, 1);
ResultSet rs1 = ResultSet rs1 =
prep2.executeQuery(); prep2.executeQuery();
rs1.next(); rs1.next();
rs1.getCharacterStream("SER2_0_0_"); rs1.getCharacterStream("S_");
Clob clob0 = Clob clob0 =
rs1.getClob("CLOB3_0_0_"); rs1.getClob("CLOB3_0_0_");
rs1.wasNull(); rs1.wasNull();
......
...@@ -72,7 +72,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -72,7 +72,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
PreparedStatement prep = conn.prepareStatement("insert into employee values(?, ?, 0)"); PreparedStatement prep = conn.prepareStatement("insert into employee values(?, ?, 0)");
int id = getNextId(); int id = getNextId();
prep.setInt(1, id); prep.setInt(1, id);
prep.setString(2, "emp " + id); prep.setString(2, "employee " + id);
prep.execute(); prep.execute();
conn.close(); conn.close();
} catch(Throwable e) { } catch(Throwable e) {
......
...@@ -104,7 +104,7 @@ public class TestOptimizations extends TestBase { ...@@ -104,7 +104,7 @@ public class TestOptimizations extends TestBase {
Connection conn=getConnection("optimizations"); Connection conn=getConnection("optimizations");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create "+(memory?"memory":"") +" table test(id int primary key, value int)"); stat.execute("create "+(memory?"memory":"") +" table test(id int primary key, value int)");
stat.execute("create index idxvalueid on test(value, id);"); stat.execute("create index idx_value_id on test(value, id);");
int len = getSize(1000, 10000); int len = getSize(1000, 10000);
HashMap map = new HashMap(); HashMap map = new HashMap();
TreeSet set = new TreeSet(); TreeSet set = new TreeSet();
......
...@@ -25,13 +25,13 @@ public class TestRights extends TestBase { ...@@ -25,13 +25,13 @@ public class TestRights extends TestBase {
testTableType(conn, "CACHED"); testTableType(conn, "CACHED");
// rights on tables and views // rights on tables and views
executeSuccess("CREATE USER PASSREADER PASSWORD 'abc'"); executeSuccess("CREATE USER PASS_READER PASSWORD 'abc'");
executeSuccess("CREATE TABLE PASS(ID INT PRIMARY KEY, NAME VARCHAR, PASSWORD VARCHAR)"); executeSuccess("CREATE TABLE PASS(ID INT PRIMARY KEY, NAME VARCHAR, PASSWORD VARCHAR)");
executeSuccess("CREATE VIEW PASS_NAME AS SELECT ID, NAME FROM PASS"); executeSuccess("CREATE VIEW PASS_NAME AS SELECT ID, NAME FROM PASS");
executeSuccess("GRANT SELECT ON PASS_NAME TO PASSREADER"); executeSuccess("GRANT SELECT ON PASS_NAME TO PASS_READER");
conn.close(); conn.close();
conn = getConnection("rights", "PASSREADER", "abc"); conn = getConnection("rights", "PASS_READER", "abc");
stat = conn.createStatement(); stat = conn.createStatement();
executeSuccess("SELECT * FROM PASS_NAME"); executeSuccess("SELECT * FROM PASS_NAME");
executeError("SELECT * FROM PASS"); executeError("SELECT * FROM PASS");
...@@ -47,21 +47,21 @@ public class TestRights extends TestBase { ...@@ -47,21 +47,21 @@ public class TestRights extends TestBase {
executeSuccess("CREATE TABLE SCHEMA_A.TABLE_B(ID INT)"); executeSuccess("CREATE TABLE SCHEMA_A.TABLE_B(ID INT)");
executeSuccess("GRANT ALL ON SCHEMA_A.TABLE_B TO TEST"); executeSuccess("GRANT ALL ON SCHEMA_A.TABLE_B TO TEST");
executeSuccess("CREATE TABLE HIDDEN(ID INT)"); executeSuccess("CREATE TABLE HIDDEN(ID INT)");
executeSuccess("CREATE TABLE PUBTABLE(ID INT)"); executeSuccess("CREATE TABLE PUB_TABLE(ID INT)");
executeSuccess("CREATE TABLE ROLETABLE(ID INT)"); executeSuccess("CREATE TABLE ROLE_TABLE(ID INT)");
executeSuccess("CREATE ROLE TESTROLE"); executeSuccess("CREATE ROLE TEST_ROLE");
executeSuccess("GRANT SELECT ON ROLETABLE TO TESTROLE"); executeSuccess("GRANT SELECT ON ROLE_TABLE TO TEST_ROLE");
executeSuccess("GRANT UPDATE ON ROLETABLE TO TESTROLE"); executeSuccess("GRANT UPDATE ON ROLE_TABLE TO TEST_ROLE");
executeSuccess("REVOKE UPDATE ON ROLETABLE FROM TESTROLE"); executeSuccess("REVOKE UPDATE ON ROLE_TABLE FROM TEST_ROLE");
executeError("REVOKE SELECT, SUB1 ON ROLETABLE FROM TESTROLE"); executeError("REVOKE SELECT, SUB1 ON ROLE_TABLE FROM TEST_ROLE");
executeSuccess("GRANT TESTROLE TO TEST"); executeSuccess("GRANT TEST_ROLE TO TEST");
executeSuccess("GRANT SELECT ON PUBTABLE TO PUBLIC"); executeSuccess("GRANT SELECT ON PUB_TABLE TO PUBLIC");
executeSuccess("GRANT SELECT ON TEST TO TEST"); executeSuccess("GRANT SELECT ON TEST TO TEST");
executeSuccess("CREATE ROLE SUB1"); executeSuccess("CREATE ROLE SUB1");
executeSuccess("CREATE ROLE SUB2"); executeSuccess("CREATE ROLE SUB2");
executeSuccess("CREATE TABLE SUBTABLE(ID INT)"); executeSuccess("CREATE TABLE SUB_TABLE(ID INT)");
executeSuccess("GRANT ALL ON SUBTABLE TO SUB2"); executeSuccess("GRANT ALL ON SUB_TABLE TO SUB2");
executeSuccess("REVOKE UPDATE, DELETE ON SUBTABLE FROM SUB2"); executeSuccess("REVOKE UPDATE, DELETE ON SUB_TABLE FROM SUB2");
executeSuccess("GRANT SUB2 TO SUB1"); executeSuccess("GRANT SUB2 TO SUB1");
executeSuccess("GRANT SUB1 TO TEST"); executeSuccess("GRANT SUB1 TO TEST");
...@@ -97,16 +97,16 @@ public class TestRights extends TestBase { ...@@ -97,16 +97,16 @@ public class TestRights extends TestBase {
executeSuccess("SELECT * FROM TEST"); executeSuccess("SELECT * FROM TEST");
executeSuccess("SELECT * FROM SYSTEM_RANGE(1,2)"); executeSuccess("SELECT * FROM SYSTEM_RANGE(1,2)");
executeSuccess("SELECT * FROM SCHEMA_A.TABLE_B"); executeSuccess("SELECT * FROM SCHEMA_A.TABLE_B");
executeSuccess("SELECT * FROM PUBTABLE"); executeSuccess("SELECT * FROM PUB_TABLE");
executeSuccess("SELECT * FROM ROLETABLE"); executeSuccess("SELECT * FROM ROLE_TABLE");
executeError("UPDATE ROLETABLE SET ID=0"); executeError("UPDATE ROLE_TABLE SET ID=0");
executeError("DELETE FROM ROLETABLE"); executeError("DELETE FROM ROLE_TABLE");
executeError("SELECT * FROM HIDDEN"); executeError("SELECT * FROM HIDDEN");
executeError("UPDATE TEST SET ID=0"); executeError("UPDATE TEST SET ID=0");
executeSuccess("SELECT * FROM SUBTABLE"); executeSuccess("SELECT * FROM SUB_TABLE");
executeSuccess("INSERT INTO SUBTABLE VALUES(1)"); executeSuccess("INSERT INTO SUB_TABLE VALUES(1)");
executeError("DELETE FROM SUBTABLE"); executeError("DELETE FROM SUB_TABLE");
executeError("UPDATE FROM SUBTABLE"); executeError("UPDATE FROM SUB_TABLE");
executeError("CREATE USER TEST3 PASSWORD 'def'"); executeError("CREATE USER TEST3 PASSWORD 'def'");
executeError("ALTER USER TEST2 ADMIN FALSE"); executeError("ALTER USER TEST2 ADMIN FALSE");
...@@ -120,7 +120,7 @@ public class TestRights extends TestBase { ...@@ -120,7 +120,7 @@ public class TestRights extends TestBase {
conn = getConnection("rights"); conn = getConnection("rights");
stat = conn.createStatement(); stat = conn.createStatement();
executeSuccess("DROP ROLE SUB1"); executeSuccess("DROP ROLE SUB1");
executeSuccess("DROP TABLE ROLETABLE"); executeSuccess("DROP TABLE ROLE_TABLE");
executeSuccess("DROP USER TEST"); executeSuccess("DROP USER TEST");
conn.close(); conn.close();
...@@ -159,7 +159,7 @@ public class TestRights extends TestBase { ...@@ -159,7 +159,7 @@ public class TestRights extends TestBase {
if(stat.execute(sql)) { if(stat.execute(sql)) {
ResultSet rs = stat.getResultSet(); ResultSet rs = stat.getResultSet();
// this will check if the resultset is updatable // this will check if the result set is updatable
rs.getConcurrency(); rs.getConcurrency();
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
......
...@@ -33,20 +33,20 @@ public class TestRunscript extends TestBase implements Trigger { ...@@ -33,20 +33,20 @@ public class TestRunscript extends TestBase implements Trigger {
stat1 = conn1.createStatement(); stat1 = conn1.createStatement();
stat1.execute("create table test (id identity, name varchar(12))"); stat1.execute("create table test (id identity, name varchar(12))");
stat1.execute("insert into test (name) values ('first'), ('second')"); stat1.execute("insert into test (name) values ('first'), ('second')");
stat1.execute("create sequence testseq start with 100 increment by 10"); stat1.execute("create sequence testSeq start with 100 increment by 10");
stat1.execute("create alias mytest for \""+getClass().getName()+".test\""); stat1.execute("create alias myTest for \""+getClass().getName()+".test\"");
stat1.execute("create trigger mytrigger before insert on test nowait call \""+getClass().getName()+"\""); stat1.execute("create trigger myTrigger before insert on test nowait call \""+getClass().getName()+"\"");
stat1.execute("create view testview as select * from test where 1=0 union all select * from test where 0=1"); stat1.execute("create view testView as select * from test where 1=0 union all select * from test where 0=1");
stat1.execute("create user testadmin salt '00' hash '01' admin"); stat1.execute("create user testAdmin salt '00' hash '01' admin");
stat1.execute("create schema testschema authorization testadmin"); stat1.execute("create schema testSchema authorization testAdmin");
stat1.execute("create table testschema.parent(id int primary key, name varchar)"); stat1.execute("create table testSchema.parent(id int primary key, name varchar)");
stat1.execute("create index idxname on testschema.parent(name)"); stat1.execute("create index idxname on testSchema.parent(name)");
stat1.execute("create table testschema.child(id int primary key, parentId int, name varchar, foreign key(parentId) references parent(id))"); stat1.execute("create table testSchema.child(id int primary key, parentId int, name varchar, foreign key(parentId) references parent(id))");
stat1.execute("create user testuser salt '02' hash '03'"); stat1.execute("create user testUser salt '02' hash '03'");
stat1.execute("create role testrole"); stat1.execute("create role testRole");
stat1.execute("grant all on testschema.child to testuser"); stat1.execute("grant all on testSchema.child to testUser");
stat1.execute("grant select, insert on testschema.parent to testrole"); stat1.execute("grant select, insert on testSchema.parent to testRole");
stat1.execute("grant testrole to testuser"); stat1.execute("grant testRole to testUser");
String sql = "script to '"+BASE_DIR+"/backup.2.sql'"; String sql = "script to '"+BASE_DIR+"/backup.2.sql'";
if(password) { if(password) {
...@@ -59,7 +59,7 @@ public class TestRunscript extends TestBase implements Trigger { ...@@ -59,7 +59,7 @@ public class TestRunscript extends TestBase implements Trigger {
stat2 = conn2.createStatement(); stat2 = conn2.createStatement();
sql = "runscript from '"+BASE_DIR+"/backup.2.sql'"; sql = "runscript from '"+BASE_DIR+"/backup.2.sql'";
if(password) { if(password) {
sql += " CIPHER AES PASSWORD 'wrongpassword'"; sql += " CIPHER AES PASSWORD 'wrongPassword'";
} }
if(password) { if(password) {
try { try {
......
...@@ -18,8 +18,8 @@ public class TestSQLInjection extends TestBase { ...@@ -18,8 +18,8 @@ public class TestSQLInjection extends TestBase {
Statement stat; Statement stat;
public void test() throws Exception { public void test() throws Exception {
deleteDb("sqlinjection"); deleteDb("sqlInjection");
reconnect("sqlinjection"); reconnect("sqlInjection");
stat.execute("DROP TABLE IF EXISTS USERS"); stat.execute("DROP TABLE IF EXISTS USERS");
stat.execute("CREATE TABLE USERS(NAME VARCHAR PRIMARY KEY, PASSWORD VARCHAR, TYPE VARCHAR)"); stat.execute("CREATE TABLE USERS(NAME VARCHAR PRIMARY KEY, PASSWORD VARCHAR, TYPE VARCHAR)");
stat.execute("CREATE SCHEMA CONST"); stat.execute("CREATE SCHEMA CONST");
...@@ -47,7 +47,7 @@ public class TestSQLInjection extends TestBase { ...@@ -47,7 +47,7 @@ public class TestSQLInjection extends TestBase {
return; return;
} }
reconnect("sqlinjection"); reconnect("sqlInjection");
try { try {
check(checkPasswordInsecure("123456")); check(checkPasswordInsecure("123456"));
......
...@@ -34,7 +34,7 @@ public class TestScript extends TestBase { ...@@ -34,7 +34,7 @@ public class TestScript extends TestBase {
private int line; private int line;
private PrintStream out; private PrintStream out;
private ArrayList result = new ArrayList(); private ArrayList result = new ArrayList();
private String putback; private String putBack;
private StringBuffer errors; private StringBuffer errors;
private ArrayList statements; private ArrayList statements;
private String fileName = "org/h2/test/test.in.txt"; private String fileName = "org/h2/test/test.in.txt";
...@@ -63,26 +63,26 @@ public class TestScript extends TestBase { ...@@ -63,26 +63,26 @@ public class TestScript extends TestBase {
public void testScript() throws Exception { public void testScript() throws Exception {
deleteDb("script"); deleteDb("script");
String outfile = "test.out.txt"; String outFile = "test.out.txt";
String infile = fileName; String inFile = fileName;
conn = getConnection("script"); conn = getConnection("script");
stat = conn.createStatement(); stat = conn.createStatement();
out = new PrintStream(new FileOutputStream(outfile)); out = new PrintStream(new FileOutputStream(outFile));
errors = new StringBuffer(); errors = new StringBuffer();
testFile(infile); testFile(inFile);
conn.close(); conn.close();
out.close(); out.close();
if(errors.length()>0) { if(errors.length()>0) {
throw new Exception("errors:\n" + errors.toString()); throw new Exception("errors:\n" + errors.toString());
} else { } else {
new File(outfile).delete(); new File(outFile).delete();
} }
} }
private String readLine() throws IOException { private String readLine() throws IOException {
if (putback != null) { if (putBack != null) {
String s = putback; String s = putBack;
putback = null; putBack = null;
return s; return s;
} }
while(true) { while(true) {
...@@ -97,8 +97,8 @@ public class TestScript extends TestBase { ...@@ -97,8 +97,8 @@ public class TestScript extends TestBase {
} }
} }
private void testFile(String infile) throws Exception { private void testFile(String inFile) throws Exception {
InputStream is = getClass().getClassLoader().getResourceAsStream(infile); InputStream is = getClass().getClassLoader().getResourceAsStream(inFile);
in = new LineNumberReader(new InputStreamReader(is, "Cp1252")); in = new LineNumberReader(new InputStreamReader(is, "Cp1252"));
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
while (true) { while (true) {
...@@ -320,9 +320,9 @@ public class TestScript extends TestBase { ...@@ -320,9 +320,9 @@ public class TestScript extends TestBase {
if (!compare.equals(s)) { if (!compare.equals(s)) {
errors.append("line: "); errors.append("line: ");
errors.append(line); errors.append(line);
errors.append("\nexp: "); errors.append("\n" + "exp: ");
errors.append(compare); errors.append(compare);
errors.append("\ngot: "); errors.append("\n" + "got: ");
errors.append(s); errors.append(s);
errors.append("\n"); errors.append("\n");
if(e != null) { if(e != null) {
...@@ -335,7 +335,7 @@ public class TestScript extends TestBase { ...@@ -335,7 +335,7 @@ public class TestScript extends TestBase {
} }
} }
} else { } else {
putback = compare; putBack = compare;
} }
write(s); write(s);
......
...@@ -22,8 +22,8 @@ public class TestScriptSimple extends TestBase { ...@@ -22,8 +22,8 @@ public class TestScriptSimple extends TestBase {
} }
deleteDb("scriptSimple"); deleteDb("scriptSimple");
reconnect(); reconnect();
String infile = "org/h2/test/testSimple.in.txt"; String inFile = "org/h2/test/testSimple.in.txt";
InputStream is = getClass().getClassLoader().getResourceAsStream(infile); InputStream is = getClass().getClassLoader().getResourceAsStream(inFile);
LineNumberReader lineReader = new LineNumberReader(new InputStreamReader(is, "Cp1252")); LineNumberReader lineReader = new LineNumberReader(new InputStreamReader(is, "Cp1252"));
ScriptReader reader = new ScriptReader(lineReader); ScriptReader reader = new ScriptReader(lineReader);
while(true) { while(true) {
......
...@@ -16,7 +16,7 @@ public class TestSequence extends TestBase { ...@@ -16,7 +16,7 @@ public class TestSequence extends TestBase {
deleteDb("sequence"); deleteDb("sequence");
Connection conn=getConnection("sequence"); Connection conn=getConnection("sequence");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create sequence testseq"); stat.execute("create sequence testSequence");
conn.setAutoCommit(false); conn.setAutoCommit(false);
Connection conn2=getConnection("sequence"); Connection conn2=getConnection("sequence");
...@@ -40,7 +40,7 @@ public class TestSequence extends TestBase { ...@@ -40,7 +40,7 @@ public class TestSequence extends TestBase {
} }
private long getNext(Statement stat) throws Exception { private long getNext(Statement stat) throws Exception {
ResultSet rs = stat.executeQuery("call next value for testseq"); ResultSet rs = stat.executeQuery("call next value for testSequence");
rs.next(); rs.next();
long value = rs.getLong(1); long value = rs.getLong(1);
return value; return value;
......
...@@ -18,7 +18,6 @@ public class TestSpeed extends TestBase { ...@@ -18,7 +18,6 @@ public class TestSpeed extends TestBase {
// java -cp .;..\..\hsqldb\lib\hsqldb.jar -Xrunhprof:heap=sites,depth=6 org.h2.test.TestAll // java -cp .;..\..\hsqldb\lib\hsqldb.jar -Xrunhprof:heap=sites,depth=6 org.h2.test.TestAll
// java -Xrunhprof:heap=sites org.h2.test.TestAll // java -Xrunhprof:heap=sites org.h2.test.TestAll
// java -Xprof org.h2.test.TestAll
// TODO test: here is more code, currently untested! // TODO test: here is more code, currently untested!
...@@ -52,16 +51,16 @@ public class TestSpeed extends TestBase { ...@@ -52,16 +51,16 @@ public class TestSpeed extends TestBase {
// for(int i=0; i<1000; i++) { // for(int i=0; i<1000; i++) {
// stat.execute("INSERT INTO TEST VALUES("+i+", 'Hello')"); // stat.execute("INSERT INTO TEST VALUES("+i+", 'Hello')");
// } // }
// stat.execute("CREATE TABLE TESTA(ID INT PRIMARY KEY, NAME VARCHAR(255))"); // stat.execute("CREATE TABLE TEST_A(ID INT PRIMARY KEY, NAME VARCHAR(255))");
// stat.execute("INSERT INTO TESTA VALUES(0, 'Hello')"); // stat.execute("INSERT INTO TEST_A VALUES(0, 'Hello')");
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
// for(int i=1; i<8000; i*=2) { // for(int i=1; i<8000; i*=2) {
// stat.execute("INSERT INTO TESTA SELECT ID+"+i+", NAME FROM TESTA"); // stat.execute("INSERT INTO TEST_A SELECT ID+"+i+", NAME FROM TEST_A");
// //
//// stat.execute("INSERT INTO TESTA VALUES("+i+", 'Hello')"); //// stat.execute("INSERT INTO TEST_A VALUES("+i+", 'Hello')");
// } // }
// for(int i=0; i<4; i++) { // for(int i=0; i<4; i++) {
// ResultSet rs = stat.executeQuery("SELECT * FROM TESTA"); // ResultSet rs = stat.executeQuery("SELECT * FROM TEST_A");
// while(rs.next()) { // while(rs.next()) {
// rs.getInt(1); // rs.getInt(1);
// rs.getString(2); // rs.getString(2);
...@@ -70,9 +69,9 @@ public class TestSpeed extends TestBase { ...@@ -70,9 +69,9 @@ public class TestSpeed extends TestBase {
// System.out.println(System.currentTimeMillis()-time); // System.out.println(System.currentTimeMillis()-time);
// //
// stat.execute("CREATE TABLE TESTB(ID INT PRIMARY KEY, NAME VARCHAR(255))"); // stat.execute("CREATE TABLE TEST_B(ID INT PRIMARY KEY, NAME VARCHAR(255))");
// for(int i=0; i<80000; i++) { // for(int i=0; i<80000; i++) {
// stat.execute("INSERT INTO TESTB VALUES("+i+", 'Hello')"); // stat.execute("INSERT INTO TEST_B VALUES("+i+", 'Hello')");
// } // }
// conn.close(); // conn.close();
...@@ -82,7 +81,7 @@ public class TestSpeed extends TestBase { ...@@ -82,7 +81,7 @@ public class TestSpeed extends TestBase {
// //
// stat.execute("CREATE TABLE TEST(ID INT)"); // stat.execute("CREATE TABLE TEST(ID INT)");
// stat.execute("INSERT INTO TEST VALUES(1)"); // stat.execute("INSERT INTO TEST VALUES(1)");
// ResultSet rs = stat.executeQuery("SELECT ID OTHERID FROM TEST"); // ResultSet rs = stat.executeQuery("SELECT ID OTHER_ID FROM TEST");
// rs.next(); // rs.next();
// rs.getString("ID"); // rs.getString("ID");
// stat.execute("DROP TABLE TEST"); // stat.execute("DROP TABLE TEST");
...@@ -96,11 +95,11 @@ public class TestSpeed extends TestBase { ...@@ -96,11 +95,11 @@ public class TestSpeed extends TestBase {
int max = getSize(1, 10000); int max = getSize(1, 10000);
for(int i=0; i<max; i++) { for(int i=0; i<max; i++) {
prep.setInt(1, i); prep.setInt(1, i);
prep.setString(2, "Helloasdfaldsjflajdflajdslfoajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd" + i); prep.setString(2, "abchelloasdfaldsjflajdflajdslfoajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd" + i);
//prep.setString(2, "Helloasdfaldsjflajdflajdslfoajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd"); //prep.setString(2, "abchelloasdfaldsjflajdflajdslfoajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd");
prep.execute(); prep.execute();
// System.out.println("i="+i); // System.out.println("i="+i);
// stat.execute("INSERT INTO TEST VALUES("+i+", 'Helloasdfaldsjflajdflajdslfaajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd"+i+"')"); // stat.execute("INSERT INTO TEST VALUES("+i+", 'abchelloasdfaldsjflajdflajdslfaajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd"+i+"')");
// ResultSet rs = stat.executeQuery("SELECT * FROM TEST WHERE ID="+i); // ResultSet rs = stat.executeQuery("SELECT * FROM TEST WHERE ID="+i);
// if(!rs.next()) { // if(!rs.next()) {
// throw new Error("hey! i="+i); // throw new Error("hey! i="+i);
......
...@@ -39,23 +39,23 @@ public class TestTempTables extends TestBase { ...@@ -39,23 +39,23 @@ public class TestTempTables extends TestBase {
// (this features are here for compatibility only) // (this features are here for compatibility only)
ResultSet rs; ResultSet rs;
c1.setAutoCommit(false); c1.setAutoCommit(false);
s1.execute("create local temporary table testtemp(id int) on commit delete rows"); s1.execute("create local temporary table test_temp(id int) on commit delete rows");
s1.execute("insert into testtemp values(1)"); s1.execute("insert into test_temp values(1)");
rs = s1.executeQuery("select * from testtemp"); rs = s1.executeQuery("select * from test_temp");
checkResultRowCount(rs, 1); checkResultRowCount(rs, 1);
c1.commit(); c1.commit();
rs = s1.executeQuery("select * from testtemp"); rs = s1.executeQuery("select * from test_temp");
checkResultRowCount(rs, 0); checkResultRowCount(rs, 0);
s1.execute("drop table testtemp"); s1.execute("drop table test_temp");
s1.execute("create local temporary table testtemp(id int) on commit drop"); s1.execute("create local temporary table test_temp(id int) on commit drop");
s1.execute("insert into testtemp values(1)"); s1.execute("insert into test_temp values(1)");
rs = s1.executeQuery("select * from testtemp"); rs = s1.executeQuery("select * from test_temp");
checkResultRowCount(rs, 1); checkResultRowCount(rs, 1);
c1.commit(); c1.commit();
try { try {
rs = s1.executeQuery("select * from testtemp"); rs = s1.executeQuery("select * from test_temp");
error("testtemp should have been dropped automatically"); error("test_temp should have been dropped automatically");
} catch(SQLException e) { } catch(SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -88,8 +88,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -88,8 +88,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
} }
stat.execute("DROP TRIGGER INS_AFTER"); stat.execute("DROP TRIGGER INS_AFTER");
stat.execute("DROP TRIGGER UPD_BEFORE"); stat.execute("DROP TRIGGER UPD_BEFORE");
stat.execute("UPDATE TEST SET NAME=NAME||'-upd-notrigger'"); stat.execute("UPDATE TEST SET NAME=NAME||'-upd-no_trigger'");
stat.execute("INSERT INTO TEST VALUES(100, 'Insert-notrigger')"); stat.execute("INSERT INTO TEST VALUES(100, 'Insert-no_trigger')");
conn.close(); conn.close();
conn = getConnection("trigger"); conn = getConnection("trigger");
......
...@@ -124,8 +124,8 @@ public class TestUpdatableResultSet extends TestBase { ...@@ -124,8 +124,8 @@ public class TestUpdatableResultSet extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255), " + stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255), " +
"DEC DECIMAL(10,2), BOO BIT, BYE TINYINT, BIN BINARY(100), "+ "DEC DECIMAL(10,2), BOO BIT, BYE TINYINT, BIN BINARY(100), "+
"D DATE, T TIME, TS TIMESTAMP, DOU DOUBLE, REA REAL, LON BIGINT, "+ "D DATE, T TIME, TS TIMESTAMP, DB DOUBLE, R REAL, L BIGINT, "+
"OBI INT, SHO SMALLINT, CLO CLOB, BLO BLOB)"); "O_I INT, SH SMALLINT, CL CLOB, BL BLOB)");
ResultSet rs = stat.executeQuery("SELECT * FROM TEST"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
check(meta.getColumnClassName(1), "java.lang.Integer"); check(meta.getColumnClassName(1), "java.lang.Integer");
...@@ -181,13 +181,13 @@ public class TestUpdatableResultSet extends TestBase { ...@@ -181,13 +181,13 @@ public class TestUpdatableResultSet extends TestBase {
rs.updateDate("D", Date.valueOf("2005-09-21")); rs.updateDate("D", Date.valueOf("2005-09-21"));
rs.updateTime("T", Time.valueOf("21:46:28")); rs.updateTime("T", Time.valueOf("21:46:28"));
rs.updateTimestamp("TS", Timestamp.valueOf("2005-09-21 21:47:09.567890123")); rs.updateTimestamp("TS", Timestamp.valueOf("2005-09-21 21:47:09.567890123"));
rs.updateDouble("DOU", 1.725); rs.updateDouble("DB", 1.725);
rs.updateFloat("REA", (float)2.5); rs.updateFloat("R", (float)2.5);
rs.updateLong("LON", Long.MAX_VALUE); rs.updateLong("L", Long.MAX_VALUE);
rs.updateObject("OBI", new Integer(10)); rs.updateObject("O_I", new Integer(10));
rs.updateShort("SHO", Short.MIN_VALUE); rs.updateShort("SH", Short.MIN_VALUE);
rs.updateCharacterStream("CLO", new StringReader("\u00ef\u00f6\u00fc"), 0); // auml ouml uuml rs.updateCharacterStream("CL", new StringReader("\u00ef\u00f6\u00fc"), 0); // auml ouml uuml
rs.updateBinaryStream("BLO", new ByteArrayInputStream(new byte[]{(byte)0xab, 0x12}), 0); rs.updateBinaryStream("BL", new ByteArrayInputStream(new byte[]{(byte)0xab, 0x12}), 0);
rs.insertRow(); rs.insertRow();
rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID NULLS FIRST"); rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID NULLS FIRST");
......
...@@ -27,7 +27,7 @@ public class TestMultiOrder extends TestMultiThread { ...@@ -27,7 +27,7 @@ public class TestMultiOrder extends TestMultiThread {
} }
void begin() throws SQLException { void begin() throws SQLException {
insertLine = conn.prepareStatement("insert into orderLine(orderid, lineid, text, amount) values(?, ?, ?, ?)"); insertLine = conn.prepareStatement("insert into orderLine(order_id, line_id, text, amount) values(?, ?, ?, ?)");
insertCustomer(); insertCustomer();
} }
...@@ -117,7 +117,7 @@ public class TestMultiOrder extends TestMultiThread { ...@@ -117,7 +117,7 @@ public class TestMultiOrder extends TestMultiThread {
conn.createStatement().execute("drop table orderLine if exists"); conn.createStatement().execute("drop table orderLine if exists");
conn.createStatement().execute("create table customer(id int primary key, name varchar, account decimal)"); conn.createStatement().execute("create table customer(id int primary key, name varchar, account decimal)");
conn.createStatement().execute("create table orders(id int identity primary key, customer_id int, total decimal)"); conn.createStatement().execute("create table orders(id int identity primary key, customer_id int, total decimal)");
conn.createStatement().execute("create table orderLine(orderid int, lineid int, text varchar, amount decimal, primary key(orderid, lineid))"); conn.createStatement().execute("create table orderLine(order_id int, line_id int, text varchar, amount decimal, primary key(order_id, line_id))");
conn.close(); conn.close();
} }
......
create table FOO (ID int, A number(18, 2));
insert into FOO (ID, A) values (1, 10.0), (2, 20.0);
select SUM (CASE when ID=1 then A ELSE 0 END) col0 from Foo;
> 10.00;
drop table FOO;
create table A ( ID integer, a1 varchar(20) ); create table A ( ID integer, a1 varchar(20) );
create table B ( ID integer, AID integer, b1 varchar(20)); create table B ( ID integer, AID integer, b1 varchar(20));
create table C ( ID integer, BId integer, c1 varchar(20)); create table C ( ID integer, BId integer, c1 varchar(20));
...@@ -35,32 +41,34 @@ select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00 ...@@ -35,32 +41,34 @@ select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00
select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00:00-02:00'); select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00:00-02:00');
> 3; > 3;
create schema testschema; create schema TEST_SCHEMA;
create table testschema.test(id int); create table TEST_SCHEMA.test(id int);
create sequence testschema.testseq; create sequence TEST_SCHEMA.TEST_SEQ;
select testschema.testseq.nextval; select TEST_SCHEMA.TEST_SEQ.CURRVAL;
> 0;
select TEST_SCHEMA.TEST_SEQ.nextval;
> 1; > 1;
drop schema testschema; drop schema TEST_SCHEMA;
create table test(id int); create table test(id int);
create trigger testtrigger before insert on test call "org.h2.test.db.TestTriggersConstraints"; create trigger TEST_TRIGGER before insert on test call "org.h2.test.db.TestTriggersConstraints";
comment on trigger testtrigger is 'just testing'; comment on trigger TEST_TRIGGER is 'just testing';
select remarks from information_schema.triggers where trigger_name = 'TESTTRIGGER'; select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER';
> just testing; > just testing;
@reconnect; @reconnect;
select remarks from information_schema.triggers where trigger_name = 'TESTTRIGGER'; select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER';
> just testing; > just testing;
drop trigger testtrigger; drop trigger TEST_TRIGGER;
@reconnect; @reconnect;
create alias parselong for "java.lang.Long.parseLong"; create alias parse_long for "java.lang.Long.parseLong";
comment on alias parselong is 'Parse a long with base'; comment on alias parse_long is 'Parse a long with base';
select remarks from information_schema.function_aliases where alias_name = 'PARSELONG'; select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG';
> Parse a long with base; > Parse a long with base;
@reconnect; @reconnect;
select remarks from information_schema.function_aliases where alias_name = 'PARSELONG'; select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG';
> Parse a long with base; > Parse a long with base;
drop alias parselong; drop alias parse_long;
@reconnect; @reconnect;
create role hr; create role hr;
...@@ -116,18 +124,18 @@ drop table test; ...@@ -116,18 +124,18 @@ drop table test;
create table test(id int); create table test(id int);
alter table test add constraint const1 unique(id); alter table test add constraint const1 unique(id);
create index idxid on test(id); create index IDX_ID on test(id);
comment on constraint const1 is 'unique id'; comment on constraint const1 is 'unique id';
comment on index idxid is 'idindex'; comment on index IDX_ID is 'id_index';
select remarks from information_schema.constraints where constraint_name = 'CONST1'; select remarks from information_schema.constraints where constraint_name = 'CONST1';
> unique id; > unique id;
select remarks from information_schema.indexes where index_name = 'IDXID'; select remarks from information_schema.indexes where index_name = 'IDX_ID';
> idindex; > id_index;
@reconnect; @reconnect;
select remarks from information_schema.constraints where constraint_name = 'CONST1'; select remarks from information_schema.constraints where constraint_name = 'CONST1';
> unique id; > unique id;
select remarks from information_schema.indexes where index_name = 'IDXID'; select remarks from information_schema.indexes where index_name = 'IDX_ID';
> idindex; > id_index;
drop table test; drop table test;
@reconnect; @reconnect;
...@@ -138,46 +146,46 @@ select remarks from information_schema.users where name = 'SALES'; ...@@ -138,46 +146,46 @@ select remarks from information_schema.users where name = 'SALES';
@reconnect; @reconnect;
select remarks from information_schema.users where name = 'SALES'; select remarks from information_schema.users where name = 'SALES';
> mr. money; > mr. money;
alter user sales rename to salesuser; alter user sales rename to SALES_USER;
select remarks from information_schema.users where name = 'SALESUSER'; select remarks from information_schema.users where name = 'SALES_USER';
> mr. money; > mr. money;
@reconnect; @reconnect;
select remarks from information_schema.users where name = 'SALESUSER'; select remarks from information_schema.users where name = 'SALES_USER';
> mr. money; > mr. money;
create table test(id int); create table test(id int);
create linked table testlink('org.h2.Driver', 'jdbc:h2:mem:', 'sa', 'sa', 'DUAL'); create linked table test_link('org.h2.Driver', 'jdbc:h2:mem:', 'sa', 'sa', 'DUAL');
comment on table testlink is '123'; comment on table test_link is '123';
select remarks from information_schema.tables where table_name = 'TESTLINK'; select remarks from information_schema.tables where table_name = 'TEST_LINK';
> 123; > 123;
@reconnect; @reconnect;
select remarks from information_schema.tables where table_name = 'TESTLINK'; select remarks from information_schema.tables where table_name = 'TEST_LINK';
> 123; > 123;
comment on table testlink is 'xyz'; comment on table test_link is 'xyz';
select remarks from information_schema.tables where table_name = 'TESTLINK'; select remarks from information_schema.tables where table_name = 'TEST_LINK';
> xyz; > xyz;
alter table testlink rename to testl; alter table test_link rename to test_l;
select remarks from information_schema.tables where table_name = 'TESTL'; select remarks from information_schema.tables where table_name = 'TEST_L';
> xyz; > xyz;
@reconnect; @reconnect;
select remarks from information_schema.tables where table_name = 'TESTL'; select remarks from information_schema.tables where table_name = 'TEST_L';
> xyz; > xyz;
drop table test; drop table test;
@reconnect; @reconnect;
create table test(id int); create table test(id int);
create view testv as select * from test; create view test_v as select * from test;
comment on table testv is 'abc'; comment on table test_v is 'abc';
select remarks from information_schema.tables where table_name = 'TESTV'; select remarks from information_schema.tables where table_name = 'TEST_V';
> abc; > abc;
@reconnect; @reconnect;
select remarks from information_schema.tables where table_name = 'TESTV'; select remarks from information_schema.tables where table_name = 'TEST_V';
> abc; > abc;
alter table testv rename to testview; alter table test_v rename to TEST_VIEW;
select remarks from information_schema.tables where table_name = 'TESTVIEW'; select remarks from information_schema.tables where table_name = 'TEST_VIEW';
> abc; > abc;
@reconnect; @reconnect;
select remarks from information_schema.tables where table_name = 'TESTVIEW'; select remarks from information_schema.tables where table_name = 'TEST_VIEW';
> abc; > abc;
drop table test; drop table test;
@reconnect; @reconnect;
......
...@@ -134,4 +134,8 @@ public class TestDataPage extends TestBase implements DataHandler { ...@@ -134,4 +134,8 @@ public class TestDataPage extends TestBase implements DataHandler {
throw new Error(); throw new Error();
} }
public Object getLobSyncObject() {
return this;
}
} }
...@@ -128,4 +128,8 @@ public class TestValueHashMap extends TestBase implements DataHandler { ...@@ -128,4 +128,8 @@ public class TestValueHashMap extends TestBase implements DataHandler {
return null; return null;
} }
public Object getLobSyncObject() {
return this;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论