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

--no commit message

--no commit message
上级 6541cb14
......@@ -22,8 +22,8 @@ public class CsvSample {
rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addColumn("EMAIL", 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[] { "John Jones", "johnjones@abcde.fgh", "+41976543210" });
rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.abc", "+41123456789" });
rs.addRow(new String[] { "John Jones", "john.jones@abcde.abc", "+41976543210" });
Csv.getInstance().write("data/test.csv", rs, null);
}
......
......@@ -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
(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>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
it again using a different TCP password, an exception was thrown sometimes.
<li>Now PreparedStatement.setBigDecimal(..) can only be called with an object of
......@@ -181,7 +181,7 @@ INSERT INTO ITEM VALUES(16,
<ul>
<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>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>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.
......@@ -194,7 +194,7 @@ INSERT INTO ITEM VALUES(16,
<b>Bugfixes:</b>
<ul>
<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>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.
......@@ -245,7 +245,7 @@ INSERT INTO ITEM VALUES(15,
<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>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>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.
......@@ -331,7 +331,7 @@ INSERT INTO ITEM VALUES(12,
<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>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>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.
......@@ -527,7 +527,7 @@ INSERT INTO ITEM VALUES(4,
<ul>
<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.
<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>ResultSetMetaData.isNullable is now implemented.
<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
TestAll test = new TestAll();
test.printSystem();
// drop all objects delete files
//
// 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
//
// Database URL: jdbc:h2:D:/workspace/DevExpPersistenceStudy/data/test
// OS: Windows XP PRofessional
// VM: JDK 1.5_09
// 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
// h2
// update FOO set a = dateadd('second', 4320000, a);
// ms sql server
// update FOO set a = dateadd(s, 4320000, a);
// mysql
// update FOO set a = date_add(a, interval 4320000 second);
// postgresql
// update FOO set a = a + interval '4320000 s';
// oracle
// update FOO set a = a + INTERVAL '4320000' SECOND;
// test backup
// backup: lobs, index
......@@ -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
// 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)
......
......@@ -247,8 +247,8 @@ public abstract class TestBase {
}
protected static void printTime(String s) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(new java.util.Date()) + " " + s);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(dateFormat.format(new java.util.Date()) + " " + s);
}
protected void deleteDb(String name) throws Exception {
......@@ -357,14 +357,14 @@ public abstract class TestBase {
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 {
ResultSetMetaData meta = rs.getMetaData();
int cc = meta.getColumnCount();
if (cc != columncount) {
error("result set contains " + cc + " columns not " + columncount);
if (cc != 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) {
String l = meta.getColumnLabel(i + 1);
if (!labels[i].equals(l)) {
......@@ -437,16 +437,16 @@ public abstract class TestBase {
if (rows == 0) {
// special case: no rows
if (rs.next()) {
error("testResultSet expected rowcount:" + rows + " got:0");
error("testResultSet expected rowCount:" + rows + " got:0");
}
}
int len2 = data[0].length;
if (len < len2) {
error("testResultSet expected columncount:" + len2 + " got:" + len);
error("testResultSet expected columnCount:" + len2 + " got:" + len);
}
for (int i = 0; i < rows; i++) {
if (!rs.next()) {
error("testResultSet expected rowcount:" + rows + " got:" + i);
error("testResultSet expected rowCount:" + rows + " got:" + i);
}
String[] row = getData(rs, len);
if (ordered) {
......@@ -515,7 +515,7 @@ public abstract class TestBase {
((JdbcConnection)conn).setPowerOffCount(1);
try {
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");
} catch(SQLException e) {
// expected
......
......@@ -7,7 +7,7 @@ package org.h2.test.bench;
public interface Bench {
void init(Database db, int size) throws Exception;
void run() throws Exception;
void runTest() throws Exception;
String getName();
}
......@@ -36,7 +36,6 @@ public class BenchA implements Bench {
db.openConnection();
db.dropTable("BRANCHES");
db.dropTable("BRANCHES");
db.dropTable("TELLERS");
db.dropTable("ACCOUNTS");
......@@ -87,13 +86,13 @@ public class BenchA implements Bench {
db.closeConnection();
db.end();
db.start(this, "Open/Close");
db.openConnection();
db.closeConnection();
db.end();
// db.start(this, "Open/Close");
// db.openConnection();
// db.closeConnection();
// db.end();
}
public void run() throws Exception {
public void runTest() throws Exception {
db.start(this, "Transactions");
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 {
db.closeConnection();
db.end();
db.start(this, "Open/Close");
db.openConnection();
db.closeConnection();
db.end();
// db.start(this, "Open/Close");
// db.openConnection();
// db.closeConnection();
// db.end();
}
......@@ -484,7 +484,7 @@ public class BenchC implements Bench {
}
}
public void run() throws Exception {
public void runTest() throws Exception {
db.start(this, "Transactions");
db.openConnection();
for(int i=0; i<70; i++) {
......
......@@ -257,14 +257,14 @@ public class BenchCThread {
c_w_id = warehouseId;
c_d_id = d_id;
}
boolean byname;
boolean byName;
String c_last;
int c_id = 1;
if (random.getInt(1, 100) <= 60) {
byname = true;
byName = true;
c_last = random.getLastname(random.getNonUniform(255, 0, 999));
} else {
byname = false;
byName = false;
c_last = "";
c_id = random.getNonUniform(1023, 1, bench.customersPerDistrict);
}
......@@ -311,7 +311,7 @@ public class BenchCThread {
rs.close();
BigDecimal c_balance;
String c_credit;
if (byname) {
if (byName) {
prep = prepare("SELECT COUNT(C_ID) FROM CUSTOMER "
+ "WHERE C_LAST=? AND C_D_ID=? AND C_W_ID=?");
prep.setString(1, c_last);
......@@ -439,14 +439,14 @@ public class BenchCThread {
private void processOrderStatus() throws Exception {
int d_id = random.getInt(1, bench.districtsPerWarehouse);
boolean byname;
boolean byName;
String c_last = null;
int c_id = -1;
if (random.getInt(1, 100) <= 60) {
byname = true;
byName = true;
c_last = random.getLastname(random.getNonUniform(255, 0, 999));
} else {
byname = false;
byName = false;
c_id = random.getNonUniform(1023, 1, bench.customersPerDistrict);
}
PreparedStatement prep;
......@@ -454,7 +454,7 @@ public class BenchCThread {
prep = prepare("UPDATE DISTRICT SET D_NEXT_O_ID=-1 WHERE D_ID=-1");
db.update(prep);
if (byname) {
if (byName) {
prep = prepare("SELECT COUNT(C_ID) FROM CUSTOMER "
+ "WHERE C_LAST=? AND C_D_ID=? AND C_W_ID=?");
prep.setString(1, c_last);
......
......@@ -36,14 +36,14 @@ public class BenchSimple implements Bench {
db.closeConnection();
db.end();
db.start(this, "Open/Close");
db.openConnection();
db.closeConnection();
db.end();
// db.start(this, "Open/Close");
// db.openConnection();
// db.closeConnection();
// db.end();
}
public void run() throws Exception {
public void runTest() throws Exception {
PreparedStatement prep;
Random random = db.getRandom();
......
......@@ -214,11 +214,11 @@ class Database {
public void update(String sql) throws Exception {
sql = getSQL(sql);
if(sql.trim().length()>0) {
executedStatements++;
stat.execute(sql);
} else {
System.out.println("?");
}
executedStatements++;
}
public void setAutoCommit(boolean b) throws Exception {
......
......@@ -212,7 +212,7 @@ public class TestPerformance {
private void runTest(Database db, Bench bench, int size) throws Exception {
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
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
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
db8 = MySQL, com.mysql.jdbc.Driver, jdbc:mysql://localhost/test?jdbcCompliantTruncation=false, sa, sa
......@@ -21,13 +21,7 @@ oracle.datetime = TIMESTAMP
test1 = org.h2.test.bench.BenchSimple
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
......@@ -65,29 +65,29 @@ public class TestCollation {
// This problem also happen if there are date parameters;
Statement stm = conn.createStatement();
stm.executeUpdate(
Statement stat = conn.createStatement();
stat.executeUpdate(
"DROP TABLE IF EXISTS test");
stm.executeUpdate(
stat.executeUpdate(
"SET COLLATION OFF");
stm.executeUpdate(
stat.executeUpdate(
"CREATE TABLE test (id INT IDENTITY, code VARCHAR(20) NOT NULL, parentId INT)");
stm.executeUpdate(
stat.executeUpdate(
"CREATE INDEX test_code ON test(code)");
PreparedStatement pstm = conn.prepareStatement(
PreparedStatement prep2 = conn.prepareStatement(
"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=?");
long time = System.currentTimeMillis();
for (int i = 1; i < TOTAL; ++i) {
if (i < ROOT) {
pstm.setString(1, Integer.toBinaryString(i));
pstm.executeUpdate();
prep2.setString(1, Integer.toBinaryString(i));
prep2.executeUpdate();
} else {
pstm2.setString(1, Integer.toBinaryString(i));
pstm2.setString(2, Integer.toBinaryString(i % 100 + 1));
pstm2.executeUpdate();
prep3.setString(1, Integer.toBinaryString(i));
prep3.setString(2, Integer.toBinaryString(i % 100 + 1));
prep3.executeUpdate();
}
}
System.out.println("INSERT w/o Collation: " + (System.currentTimeMillis()-time));
......@@ -98,29 +98,29 @@ public class TestCollation {
public void testWithCollation() throws Exception {
Statement stm = conn.createStatement();
stm.executeUpdate(
Statement stat = conn.createStatement();
stat.executeUpdate(
"DROP TABLE IF EXISTS test");
stm.executeUpdate(
stat.executeUpdate(
"SET COLLATION ENGLISH STRENGTH PRIMARY");
stm.executeUpdate(
stat.executeUpdate(
"CREATE TABLE test (id INT IDENTITY, code VARCHAR(20) NOT NULL, parentId INT)");
stm.executeUpdate(
stat.executeUpdate(
"CREATE INDEX test_code ON test(code)");
PreparedStatement pstm = conn.prepareStatement(
PreparedStatement prep = conn.prepareStatement(
"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=?");
long time = System.currentTimeMillis();
for (int i = 1; i < TOTAL; ++i) {
if (i < ROOT) {
pstm.setString(1, Integer.toBinaryString(i));
pstm.executeUpdate();
prep.setString(1, Integer.toBinaryString(i));
prep.executeUpdate();
} else {
pstm2.setString(1, Integer.toBinaryString(i));
pstm2.setString(2, Integer.toBinaryString(i % 100 + 1));
pstm2.executeUpdate();
prep2.setString(1, Integer.toBinaryString(i));
prep2.setString(2, Integer.toBinaryString(i % 100 + 1));
prep2.executeUpdate();
}
}
System.out.println("INSERT with Collation: " + (System.currentTimeMillis()-time));
......
......@@ -5,7 +5,7 @@
package org.h2.test.cases;
import java.sql.*;
public class TestCompatibiliyMySQL {
public class TestCompatibilityMySQL {
public static void main(String[] args) throws Exception {
testWith("org.postgresql.Driver", "jdbc:postgresql:jpox2", "sa", "sa");
......
......@@ -21,18 +21,18 @@ public class TestDate {
try {
stat.execute("DROP TABLE ts_trial");
} catch (SQLException e) { }
stat.execute("CREATE TABLE ts_trial(myts TIMESTAMP)");
stat.execute("CREATE TABLE ts_trial(TS TIMESTAMP)");
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.execute();
prep.setDate(1, new java.sql.Date(System.currentTimeMillis()));
prep.execute();
ResultSet rs = stat.executeQuery("SELECT myts FROM ts_trial");
ResultSet rs = stat.executeQuery("SELECT TS FROM ts_trial");
rs.next();
System.out.println("Timestamp: " + rs.getTimestamp("myts"));
System.out.println("Timestamp: " + rs.getTimestamp("TS"));
rs.next();
System.out.println("Date: " + rs.getTimestamp("myts"));
System.out.println("Date: " + rs.getTimestamp("TS"));
System.out.println();
}
}
......@@ -56,7 +56,7 @@ public class TestHibernateClob {
conn.createStatement();
stat0.executeUpdate("drop table CLOB_ENTITY if exists");
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.close();
conn.getWarnings();
......@@ -75,7 +75,7 @@ public class TestHibernateClob {
prep0.close();
conn.getAutoCommit();
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);
StringBuffer buff = new StringBuffer(20000);
for(int i=0; i<10000; i++) {
......@@ -96,12 +96,12 @@ public class TestHibernateClob {
conn.getAutoCommit();
conn.getAutoCommit();
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);
ResultSet rs1 =
prep2.executeQuery();
rs1.next();
System.out.println("ser: " + rs1.getCharacterStream("SER2_0_0_"));
System.out.println("s2: " + rs1.getCharacterStream("S2"));
Clob clob0 =
rs1.getClob("CLOB3_0_0_");
System.out.println("wasNull: " + rs1.wasNull());
......
......@@ -55,14 +55,14 @@ public class TestKiller {
}
stmt.execute("CREATE TABLE TESTTAB(VL DECIMAL(16,6) PRIMARY KEY)");
stmt.close();
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO TESTTAB VALUES (?)");
pstmt.setBigDecimal(1, new TestBigDecimal("1"));
pstmt.execute();
pstmt.setBigDecimal(1, new TestBigDecimal("2"));
pstmt.execute();
pstmt.setBigDecimal(1, new TestBigDecimal("3"));
pstmt.execute();
pstmt.close();
PreparedStatement prep = conn.prepareStatement("INSERT INTO TESTTAB VALUES (?)");
prep.setBigDecimal(1, new TestBigDecimal("1"));
prep.execute();
prep.setBigDecimal(1, new TestBigDecimal("2"));
prep.execute();
prep.setBigDecimal(1, new TestBigDecimal("3"));
prep.execute();
prep.close();
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TESTTAB ORDER BY VL");
while(rs.next()) {
System.out.println("VL:" + rs.getString("VL"));
......
......@@ -16,7 +16,7 @@ import org.h2.util.MemoryUtils;
public class TestLinearIndex {
public static void main(String[] args) throws Exception {
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;
for(int a=0; ; a++) {
testLoop(true, len);
......@@ -35,9 +35,9 @@ public class TestLinearIndex {
stat.execute("drop table if exists test");
stat.execute("create table test(id int, name varchar)");
if(hashIndex) {
stat.execute("create unique hash index idxid on test(id)");
stat.execute("create unique hash index idx_id on test(id)");
} 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+")");
PreparedStatement prep = conn.prepareStatement("select * from test where id=?");
......
......@@ -12,7 +12,7 @@ import java.sql.Types;
public class TestOther {
public static void main(String[] args) {
Object[] tos = {
Object[] list = {
// new int[] {1, 2, 3, 4, 5},
// new Integer(122), // Uncomment to see a "Hexadecimal string with odd number of characters"
new String[] {"hello", "world"}, // Uncomment to see a "Deserialization failed"
......@@ -21,22 +21,22 @@ public class TestOther {
try {
Class.forName("org.h2.Driver");
Connection con = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
con.setAutoCommit(true);
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
conn.setAutoCommit(true);
con.createStatement().executeUpdate("CREATE TABLE TestOtherJDBC (tstData OTHER)");
conn.createStatement().executeUpdate("CREATE TABLE TestOtherJDBC (testData OTHER)");
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++) {
System.out.println(tos[i].getClass().getName() + "\t" + tos[i]);
stmt.setObject(1, tos[i], Types.OTHER);
for (int i = 0; i < list.length; i++) {
System.out.println(list[i].getClass().getName() + "\t" + list[i]);
stmt.setObject(1, list[i], Types.OTHER);
stmt.executeUpdate();
}
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()) {
Object obj = rs.getObject(1);
......
......@@ -33,7 +33,7 @@ public class TestRebuildIndex {
}
} else {
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;
System.out.println("time: " + time);
// lzf: 5688 / 11944 kb
......
......@@ -40,12 +40,12 @@ public class Coverage {
System.out
.println("Usage:\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"
+ " this will modified the source code and create 'profile.txt'\n"
+ "- compile the modified source files\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"
+ " of code that has not been covered\n\n"
+ "Options:\n"
......@@ -154,9 +154,9 @@ public class Coverage {
return;
}
File f = new File(name);
File fnew = new File(name + ".new");
File fileNew = new File(name + ".new");
try {
writer = new BufferedWriter(new FileWriter(fnew));
writer = new BufferedWriter(new FileWriter(fileNew));
Reader r = new BufferedReader(new FileReader(f));
tokenizer = new Tokenizer(r);
indent = 0;
......@@ -171,11 +171,11 @@ public class Coverage {
}
r.close();
writer.close();
File fbak = new File(name + ".bak");
fbak.delete();
f.renameTo(fbak);
File fcopy = new File(name);
fnew.renameTo(fcopy);
File backup = new File(name + ".bak");
backup.delete();
f.renameTo(backup);
File copy = new File(name);
fileNew.renameTo(copy);
if (perClass) {
nextDebug();
}
......@@ -320,11 +320,11 @@ public class Coverage {
}
}
void processBraket() throws Exception {
void processBracket() throws Exception {
do {
if (token.equals("(")) {
read();
processBraket();
processBracket();
} else if (token.equals(")")) {
read();
return;
......@@ -365,7 +365,7 @@ public class Coverage {
|| token.equals("synchronized")) {
read();
readThis("(");
processBraket();
processBracket();
indent++;
processBlockOrStatement();
indent--;
......@@ -373,7 +373,7 @@ public class Coverage {
} else if (token.equals("if")) {
read();
readThis("(");
processBraket();
processBracket();
indent++;
processBlockOrStatement();
indent--;
......@@ -393,7 +393,7 @@ public class Coverage {
if (token.equals("catch")) {
read();
readThis("(");
processBraket();
processBracket();
indent++;
processBlockOrStatement();
indent--;
......@@ -431,7 +431,7 @@ public class Coverage {
processBlockOrStatement();
readThis("while");
readThis("(");
processBraket();
processBracket();
readThis(";");
setLine();
indent--;
......@@ -452,7 +452,7 @@ public class Coverage {
} else if (token.equals("switch")) {
read();
readThis("(");
processBraket();
processBracket();
indent++;
processBlockOrStatement();
indent--;
......@@ -463,7 +463,7 @@ public class Coverage {
return;
} else if (token.equals("(")) {
read();
processBraket();
processBracket();
} else if (token.equals("=")) {
read();
if (token.equals("{")) {
......@@ -493,8 +493,8 @@ public class Coverage {
String func = i<0 ? function : function.substring(0, i);
String fileLine = file + "." + func +"(";
i = file.lastIndexOf('.');
String fil = i<0 ? file : file.substring(i+1);
fileLine += fil + ".java:" + line + ")";
String className = i<0 ? file : file.substring(i+1);
fileLine += className + ".java:" + line + ")";
data.write(fileLine + " " + last + "\r\n");
} else {
data.write(file + " " + line + "\r\n");
......
......@@ -121,14 +121,14 @@ public class Profile extends Thread {
print("NOT COVERED");
printLine('-');
FileReader reader = null;
FileWriter fwriter = null;
FileWriter fileWriter = null;
try {
reader = new FileReader("profile.txt");
LineNumberReader r = new LineNumberReader(reader);
fwriter = new FileWriter("notcovered.txt");
BufferedWriter writer = new BufferedWriter(fwriter);
fileWriter = new FileWriter("notCovered.txt");
BufferedWriter writer = new BufferedWriter(fileWriter);
int unvisited = 0;
int unvisitedthrow = 0;
int unvisitedThrow = 0;
for (int i = 0; i < maxIndex; i++) {
String line = r.readLine();
if (count[i] == 0) {
......@@ -139,15 +139,15 @@ public class Profile extends Thread {
}
unvisited++;
} else {
unvisitedthrow++;
unvisitedThrow++;
}
}
}
int percent = (100 * unvisited / maxIndex);
print("Not covered: " + percent + " % " + " (" + unvisited + " of "
+ maxIndex + "; throw=" + unvisitedthrow + ")");
+ maxIndex + "; throw=" + unvisitedThrow + ")");
} finally {
IOUtils.closeSilently(fwriter);
IOUtils.closeSilently(fileWriter);
IOUtils.closeSilently(reader);
}
}
......@@ -155,16 +155,16 @@ public class Profile extends Thread {
void listTop(String title, int[] list, int max) throws Exception {
printLine('-');
int total = 0;
int totallines = 0;
int totalLines = 0;
for (int j = 0; j < maxIndex; j++) {
int l = list[j];
if (l > 0) {
total += list[j];
totallines++;
totalLines++;
}
}
if (max == 0) {
max = totallines;
max = totalLines;
}
print(title);
print("Total: " + total);
......
......@@ -16,8 +16,8 @@ public class Tokenizer {
private Reader reader;
private char[] buf = new char[20];
private int peekc;
private char[] chars = new char[20];
private int peekChar;
private int line = 1;
private byte[] charTypes = new byte[256];
......@@ -98,7 +98,7 @@ public class Tokenizer {
type = c;
}
} else {
c = peekc;
c = peekChar;
if (c < 0) {
try {
c = read();
......@@ -114,8 +114,8 @@ public class Tokenizer {
if (c < 0) {
return type = TYPE_EOF;
}
int ctype = c < 256 ? ct[c] : ALPHA;
while ((ctype & WHITESPACE) != 0) {
int charType = c < 256 ? ct[c] : ALPHA;
while ((charType & WHITESPACE) != 0) {
if (c == '\r') {
line++;
c = read();
......@@ -131,36 +131,36 @@ public class Tokenizer {
if (c < 0) {
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();
append(c);
int i = 0;
do {
if (i >= buf.length) {
char[] nb = new char[buf.length * 2];
System.arraycopy(buf, 0, nb, 0, buf.length);
buf = nb;
if (i >= chars.length) {
char[] nb = new char[chars.length * 2];
System.arraycopy(chars, 0, nb, 0, chars.length);
chars = nb;
}
buf[i++] = (char) c;
chars[i++] = (char) c;
c = read();
ctype = c < 0 ? WHITESPACE : c < 256 ? ct[c] : ALPHA;
} while ((ctype & ALPHA) != 0);
peekc = c;
value = String.copyValueOf(buf, 0, i);
charType = c < 0 ? WHITESPACE : c < 256 ? ct[c] : ALPHA;
} while ((charType & ALPHA) != 0);
peekChar = c;
value = String.copyValueOf(chars, 0, i);
return type = TYPE_WORD;
}
if ((ctype & QUOTE) != 0) {
if ((charType & QUOTE) != 0) {
initToken();
append(c);
type = c;
int i = 0;
// \octal needs a lookahead
peekc = read();
while (peekc >= 0 && peekc != type && peekc != '\n'
&& peekc != '\r') {
if (peekc == '\\') {
peekChar = read();
while (peekChar >= 0 && peekChar != type && peekChar != '\n'
&& peekChar != '\r') {
if (peekChar == '\\') {
c = read();
int first = c; // to allow \377, but not \477
if (c >= '0' && c <= '7') {
......@@ -171,12 +171,12 @@ public class Tokenizer {
c2 = read();
if ('0' <= c2 && c2 <= '7' && first <= '3') {
c = (c << 3) + (c2 - '0');
peekc = read();
peekChar = read();
} else {
peekc = c2;
peekChar = c2;
}
} else {
peekc = c2;
peekChar = c2;
}
} else {
switch (c) {
......@@ -196,32 +196,32 @@ public class Tokenizer {
c = '\t';
break;
}
peekc = read();
peekChar = read();
}
} else {
c = peekc;
peekc = read();
c = peekChar;
peekChar = read();
}
if (i >= buf.length) {
char[] nb = new char[buf.length * 2];
System.arraycopy(buf, 0, nb, 0, buf.length);
buf = nb;
if (i >= chars.length) {
char[] nb = new char[chars.length * 2];
System.arraycopy(chars, 0, nb, 0, chars.length);
chars = nb;
}
buf[i++] = (char) c;
chars[i++] = (char) c;
}
if (peekc == type) {
// keep \n or \r intact in peekc
peekc = read();
if (peekChar == type) {
// keep \n or \r intact in peekChar
peekChar = read();
}
value = String.copyValueOf(buf, 0, i);
value = String.copyValueOf(chars, 0, i);
return type;
}
if (c == '/') {
c = read();
if (c == '*') {
int prevc = 0;
while ((c = read()) != '/' || prevc != '*') {
int prevChar = 0;
while ((c = read()) != '/' || prevChar != '*') {
if (c == '\r') {
line++;
c = read();
......@@ -237,22 +237,22 @@ public class Tokenizer {
if (c < 0) {
return type = TYPE_EOF;
}
prevc = c;
prevChar = c;
}
peekc = read();
peekChar = read();
return nextToken();
} else if (c == '/') {
while ((c = read()) != '\n' && c != '\r' && c >= 0) {
// nothing
}
peekc = c;
peekChar = c;
return nextToken();
} else {
peekc = c;
peekChar = c;
return type = '/';
}
}
peekc = read();
peekChar = read();
return type = c;
}
......
......@@ -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_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_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_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_UPDATE_SET = "UPDATE TEST SET KEY_ID=?, COF_NAME=? WHERE COF_NAME=?";
static final String COFFEE_SELECT_CONTINUED = "SELECT COUNT(*) FROM TEST WHERE COF_NAME='Continue-1'";
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 C_NAME='Continue-1'";
int coffeeSize = 10;
int coffeeType = 11;
......@@ -36,7 +36,7 @@ public class TestBatchUpdates extends TestBase {
error("does not support BatchUpdates");
}
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;
float newPrice = 0;
int newType = 0;
......@@ -86,7 +86,7 @@ public class TestBatchUpdates extends TestBase {
prep.setInt(1, 4);
prep.addBatch();
int[] updateCount = prep.executeBatch();
int updateCountlen = updateCount.length;
int updateCountLen = updateCount.length;
// PreparedStatement p;
// p = conn.prepareStatement(COFFEE_UPDATE);
......@@ -98,8 +98,8 @@ public class TestBatchUpdates extends TestBase {
// System.out.println("upc="+p.executeUpdate());
trace("updateCount length:" + updateCountlen);
if (updateCountlen != 3) {
trace("updateCount length:" + updateCountLen);
if (updateCountLen != 3) {
error("addBatch");
} else {
trace("addBatch add the SQL statements to Batch ");
......@@ -239,10 +239,10 @@ public class TestBatchUpdates extends TestBase {
rs = stat.executeQuery(query3);
rs.next();
retValue[i++] = rs.getInt(1);
trace("retvalue length : " + retValue.length);
trace("retValue length : " + retValue.length);
for (int j = 0; j < updateCount.length; j++) {
trace("UpdateCount Value:" + updateCount[j]);
trace("Retvalue : " + retValue[j]);
trace("RetValue : " + retValue[j]);
if (updateCount[j] != retValue[j]) {
error("j=" + j + " right:" + retValue[j]);
}
......@@ -269,7 +269,7 @@ public class TestBatchUpdates extends TestBase {
public void testExecuteBatch03() throws Exception {
trace("testExecuteBatch03");
boolean bexpflag = false;
boolean batchExceptionFlag = false;
String sPrepStmt = COFFEE_SELECT;
trace("Prepared Statement String :" + sPrepStmt);
prep = conn.prepareStatement(sPrepStmt);
......@@ -279,9 +279,9 @@ public class TestBatchUpdates extends TestBase {
int[] updateCount = prep.executeBatch();
trace("Update Count" + updateCount.length);
} catch (BatchUpdateException b) {
bexpflag = true;
batchExceptionFlag = true;
}
if (bexpflag) {
if (batchExceptionFlag) {
trace("select not allowed; correct");
} else {
error("executeBatch select");
......@@ -339,7 +339,7 @@ public class TestBatchUpdates extends TestBase {
public void testExecuteBatch06() throws Exception {
trace("testExecuteBatch06");
boolean bexpflag = false;
boolean batchExceptionFlag = false;
//Insert a row which is already Present
String sInsCoffee = COFFEE_INSERT1;
String sDelCoffee = COFFEE_DELETE1;
......@@ -349,13 +349,13 @@ public class TestBatchUpdates extends TestBase {
try {
stat.executeBatch();
} catch (BatchUpdateException b) {
bexpflag = true;
batchExceptionFlag = true;
int[] updCounts = b.getUpdateCounts();
for (int i = 0; i < updCounts.length; i++) {
trace("Update counts:" + updCounts[i]);
}
}
if (bexpflag) {
if (batchExceptionFlag) {
trace("executeBatch insert duplicate; correct");
} else {
error("executeBatch");
......@@ -364,18 +364,18 @@ public class TestBatchUpdates extends TestBase {
public void testExecuteBatch07() throws Exception {
trace("testExecuteBatch07");
boolean bexpflag = false;
String sSelCoffee = COFFEE_SELECT1;
trace("sSelCoffee = " + sSelCoffee);
boolean batchExceptionFlag = false;
String selectCoffee = COFFEE_SELECT1;
trace("selectCoffee = " + selectCoffee);
Statement stmt = conn.createStatement();
stmt.addBatch(sSelCoffee);
stmt.addBatch(selectCoffee);
try {
int[] updateCount = stmt.executeBatch();
trace("updateCount Length : " + updateCount.length);
} catch (BatchUpdateException be) {
bexpflag = true;
batchExceptionFlag = true;
}
if (bexpflag) {
if (batchExceptionFlag) {
trace("executeBatch select");
} else {
error("executeBatch");
......@@ -385,7 +385,7 @@ public class TestBatchUpdates extends TestBase {
public void testContinueBatch01() throws Exception {
trace("testContinueBatch01");
int[] batchUpdates = { 0, 0, 0};
int buCountlen = 0;
int buCountLen = 0;
try {
String sPrepStmt = COFFEE_UPDATE_SET;
trace("Prepared Statement String:" + sPrepStmt);
......@@ -416,12 +416,12 @@ public class TestBatchUpdates extends TestBase {
} catch (BatchUpdateException b) {
trace("expected BatchUpdateException");
batchUpdates = b.getUpdateCounts();
buCountlen = batchUpdates.length;
buCountLen = batchUpdates.length;
}
if (buCountlen == 1) {
if (buCountLen == 1) {
trace("no continued updates - OK");
return;
} else if (buCountlen == 3) {
} else if (buCountLen == 3) {
trace("Driver supports continued updates.");
// Check to see if the third row from the batch was added
String query = COFFEE_SELECT_CONTINUED;
......
......@@ -31,45 +31,45 @@ public class TestBigDb extends TestBase {
Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement();
stat.execute(
"CREATE CACHED TABLE PAB_ARTLEV("+
"MUTATIECODE CHAR(1) DEFAULT CAST(RAND()*9 AS INT),"+
"PRDCODE CHAR(20) DEFAULT SECURE_RAND(10),"+
"ORGCODESUPPLIER CHAR(13) DEFAULT SECURE_RAND(6),"+
"PRDCODEGTIN CHAR(14) DEFAULT SECURE_RAND(7),"+
"PRDCODEMF CHAR(20) DEFAULT SECURE_RAND(10),"+
"ORGCODEMF CHAR(13) DEFAULT SECURE_RAND(6),"+
"SUBSTITUTEDBY CHAR(20) DEFAULT SECURE_RAND(10),"+
"SUBSTITUTEDBYGTIN CHAR(14) DEFAULT SECURE_RAND(7),"+
"SUBSTITUTIONFOR CHAR(20) DEFAULT SECURE_RAND(10),"+
"SUBSTITUTIONFORGTIN CHAR(14) DEFAULT SECURE_RAND(7),"+
"VERWERKBAAR CHAR(2) DEFAULT SECURE_RAND(1),"+
"BESTELBAAR CHAR(2) DEFAULT SECURE_RAND(1),"+
"AANTALGEBRUIKSEENHEDEN DECIMAL(7,2) DEFAULT RAND(),"+
"PRIMARYUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"RATEPRICEORDERUNIT DECIMAL(9,3) DEFAULT RAND(),"+
"ORDERUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"ORDERQTYMIN DECIMAL(6,1) DEFAULT RAND(),"+
"ORDERQTYLOTSIZE DECIMAL(6,1) DEFAULT RAND(),"+
"ORDERUNITCODE2 CHAR(3) DEFAULT SECURE_RAND(1),"+
"PRICEGROUP CHAR(20) DEFAULT SECURE_RAND(10),"+
"LEADTIME INTEGER DEFAULT RAND(),"+
"LEADTIMEUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"PRDGROUP CHAR(10) DEFAULT SECURE_RAND(5),"+
"WEIGHTGROSS DECIMAL(7,3) DEFAULT RAND(),"+
"WEIGHTUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"PACKUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"PACKLENGTH DECIMAL(7,3) DEFAULT RAND(),"+
"PACKWIDTH DECIMAL(7,3) DEFAULT RAND(),"+
"PACKHEIGHT DECIMAL(7,3) DEFAULT RAND(),"+
"SIZEUNITCODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"STATUCCODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"INTRASTATCODE CHAR(12) DEFAULT SECURE_RAND(6),"+
"PRDTITLE CHAR(50) DEFAULT SECURE_RAND(25),"+
"VALIDFROM DATE DEFAULT NOW(),"+
"MUTATIEDATUM DATE DEFAULT NOW())");
"CREATE CACHED TABLE TEST("+
"M_CODE CHAR(1) DEFAULT CAST(RAND()*9 AS INT),"+
"PRD_CODE CHAR(20) DEFAULT SECURE_RAND(10),"+
"ORG_CODE_SUPPLIER CHAR(13) DEFAULT SECURE_RAND(6),"+
"PRD_CODE_1 CHAR(14) DEFAULT SECURE_RAND(7),"+
"PRD_CODE_2 CHAR(20) DEFAULT SECURE_RAND(10),"+
"ORG_CODE CHAR(13) DEFAULT SECURE_RAND(6),"+
"SUBSTITUTED_BY CHAR(20) DEFAULT SECURE_RAND(10),"+
"SUBSTITUTED_BY_2 CHAR(14) DEFAULT SECURE_RAND(7),"+
"SUBSTITUTION_FOR CHAR(20) DEFAULT SECURE_RAND(10),"+
"SUBSTITUTION_FOR_2 CHAR(14) DEFAULT SECURE_RAND(7),"+
"TEST CHAR(2) DEFAULT SECURE_RAND(1),"+
"TEST_2 CHAR(2) DEFAULT SECURE_RAND(1),"+
"TEST_3 DECIMAL(7,2) DEFAULT RAND(),"+
"PRIMARY_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"RATE_PRICE_ORDER_UNIT DECIMAL(9,3) DEFAULT RAND(),"+
"ORDER_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"ORDER_QTY_MIN DECIMAL(6,1) DEFAULT RAND(),"+
"ORDER_QTY_LOT_SIZE DECIMAL(6,1) DEFAULT RAND(),"+
"ORDER_UNIT_CODE_2 CHAR(3) DEFAULT SECURE_RAND(1),"+
"PRICE_GROUP CHAR(20) DEFAULT SECURE_RAND(10),"+
"LEAD_TIME INTEGER DEFAULT RAND(),"+
"LEAD_TIME_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"PRD_GROUP CHAR(10) DEFAULT SECURE_RAND(5),"+
"WEIGHT_GROSS DECIMAL(7,3) DEFAULT RAND(),"+
"WEIGHT_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"PACK_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"PACK_LENGTH DECIMAL(7,3) DEFAULT RAND(),"+
"PACK_WIDTH DECIMAL(7,3) DEFAULT RAND(),"+
"PACK_HEIGHT DECIMAL(7,3) DEFAULT RAND(),"+
"SIZE_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"STATUS_CODE CHAR(3) DEFAULT SECURE_RAND(1),"+
"INTRA_STAT_CODE CHAR(12) DEFAULT SECURE_RAND(6),"+
"PRD_TITLE CHAR(50) DEFAULT SECURE_RAND(25),"+
"VALID_FROM DATE DEFAULT NOW(),"+
"MOD_DATUM DATE DEFAULT NOW())");
int len = getSize(10, 50000);
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();
for(int i=0; i<len; i++) {
if((i % 1000) == 0) {
......@@ -83,8 +83,8 @@ public class TestBigDb extends TestBase {
prep.setInt(1, i);
prep.execute();
}
stat.execute("CREATE INDEX IDX_PAB_ARTLEV_PRDCODE ON PAB_ARTLEV(PRDCODE)");
ResultSet rs = stat.executeQuery("SELECT * FROM PAB_ARTLEV");
stat.execute("CREATE INDEX IDX_TEST_PRD_CODE ON TEST(PRD_CODE)");
ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
int columns = rs.getMetaData().getColumnCount();
while(rs.next()) {
for(int i=0; i<columns; i++) {
......@@ -104,7 +104,7 @@ public class TestBigDb extends TestBase {
Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement();
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')");
int len = getSize(10, 1000);
int block = getSize(3, 10);
......
......@@ -22,6 +22,7 @@ public class TestCases extends TestBase {
public void test() throws Exception {
testDeleteGroup();
testDisconnect();
testExecuteTrace();
if(config.memory || config.logMode == 0) {
......@@ -49,6 +50,17 @@ public class TestCases extends TestBase {
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 {
deleteDb("cases");
Connection conn=getConnection("cases");
......@@ -305,13 +317,13 @@ public class TestCases extends TestBase {
ps.setTimestamp(2, orderDate);
ps.setInt(3, 2222);
ps.setString(4, "test desc");
ps.setString(5, "teststate");
ps.setString(5, "test_state");
ps.setString(6, "testid");
ps.setInt(7, 5556);
ps.setTimestamp(8, orderDate);
ps.setInt(9, 2222);
ps.setString(10, "test desc");
ps.setString(11, "teststate");
ps.setString(11, "test_state");
ps.setString(12, "testid");
check(ps.executeUpdate(), 2);
ps.close();
......@@ -582,7 +594,7 @@ public class TestCases extends TestBase {
Statement stat = conn.createStatement();
stat.execute(
"create table employee(id int, "
+"firstname VARCHAR(50), "
+"firstName VARCHAR(50), "
+"salary decimal(10, 2), "
+"superior_id int, "
+"CONSTRAINT PK_employee PRIMARY KEY (id), "
......@@ -600,13 +612,13 @@ public class TestCases extends TestBase {
Connection c0=getConnection("cases");
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.close();
c0=getConnection("cases");
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);
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();
......@@ -630,7 +642,7 @@ public class TestCases extends TestBase {
c0=getConnection("cases");
c0.createStatement().executeUpdate("SET AUTOCOMMIT FALSE");
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.close();
......
......@@ -30,9 +30,9 @@ public class TestFunctions extends TestBase {
test("abs(1)", "1");
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;
rs = stat.executeQuery("CALL ADDROW(1, 'Hello')");
rs = stat.executeQuery("CALL ADD_ROW(1, 'Hello')");
rs.next();
check(rs.getInt(1), 1);
rs = stat.executeQuery("SELECT * FROM TEST");
......@@ -41,10 +41,10 @@ public class TestFunctions extends TestBase {
check(rs.getString(2), "Hello");
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\"");
rs = stat.executeQuery("CALL SEL('SELECT * FROM TEST ORDER BY ID')");
stat.execute("CREATE ALIAS SELECT_F FOR \"" + getClass().getName() + ".select\"");
rs = stat.executeQuery("CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')");
check(rs.getMetaData().getColumnCount(), 2);
rs.next();
check(rs.getInt(1), 1);
......@@ -54,7 +54,7 @@ public class TestFunctions extends TestBase {
check(rs.getString(2), "World");
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);
rs.next();
check(rs.getString(1), "World");
......@@ -62,7 +62,7 @@ public class TestFunctions extends TestBase {
check(rs.getString(1), "Hello");
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);
rs.next();
check("((1, Hello))", rs.getString(1));
......@@ -70,14 +70,14 @@ public class TestFunctions extends TestBase {
check("((2, World))", rs.getString(1));
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);
rs.next();
check("((1, Hello), (2, World))", rs.getString(1));
checkFalse(rs.next());
try {
rs = stat.executeQuery("CALL SEL('ERROR')");
rs = stat.executeQuery("CALL SELECT_F('ERROR')");
error("expected error");
} catch (SQLException e) {
check("42001", e.getSQLState());
......@@ -115,13 +115,13 @@ public class TestFunctions extends TestBase {
check(rs.getInt(1), 3);
checkFalse(rs.next());
stat.execute("CREATE ALIAS MAXID FOR \"" + getClass().getName() + ".selectMaxId\"");
rs = stat.executeQuery("CALL MAXID()");
stat.execute("CREATE ALIAS MAX_ID FOR \"" + getClass().getName() + ".selectMaxId\"");
rs = stat.executeQuery("CALL MAX_ID()");
rs.next();
check(rs.getInt(1), 2);
checkFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM MAXID()");
rs = stat.executeQuery("SELECT * FROM MAX_ID()");
rs.next();
check(rs.getInt(1), 2);
checkFalse(rs.next());
......@@ -145,8 +145,8 @@ public class TestFunctions extends TestBase {
// ignore
}
stat.execute("CREATE ALIAS NULLRESULT FOR \"" + getClass().getName() + ".nullResultSet\"");
rs = stat.executeQuery("CALL NULLRESULT()");
stat.execute("CREATE ALIAS NULL_RESULT FOR \"" + getClass().getName() + ".nullResultSet\"");
rs = stat.executeQuery("CALL NULL_RESULT()");
check(rs.getMetaData().getColumnCount(), 1);
rs.next();
check(rs.getString(1), null);
......@@ -204,17 +204,17 @@ public class TestFunctions extends TestBase {
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();
rs.addColumn("ID", Types.INTEGER, 10, 0);
rs.addColumn("NAME", Types.VARCHAR, 255, 0);
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");
}
}
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");
}
if (count.intValue() >= 1) {
......
......@@ -213,7 +213,7 @@ public class TestIndex extends TestBase {
stat.execute("DROP TABLE IF EXISTS TEST");
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;
prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?, ?)");
// speed is quadratic (len*len)
......
......@@ -192,7 +192,7 @@ public class TestLob extends TestBase {
conn0.createStatement();
stat0.executeUpdate("drop table CLOB_ENTITY if exists");
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.close();
conn0.getWarnings();
......@@ -211,7 +211,7 @@ public class TestLob extends TestBase {
prep0.close();
conn0.getAutoCommit();
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);
StringBuffer buff = new StringBuffer(10000);
for(int i=0; i<10000; i++) {
......@@ -232,12 +232,12 @@ public class TestLob extends TestBase {
conn0.getAutoCommit();
conn0.getAutoCommit();
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);
ResultSet rs1 =
prep2.executeQuery();
rs1.next();
rs1.getCharacterStream("SER2_0_0_");
rs1.getCharacterStream("S_");
Clob clob0 =
rs1.getClob("CLOB3_0_0_");
rs1.wasNull();
......
......@@ -72,7 +72,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
PreparedStatement prep = conn.prepareStatement("insert into employee values(?, ?, 0)");
int id = getNextId();
prep.setInt(1, id);
prep.setString(2, "emp " + id);
prep.setString(2, "employee " + id);
prep.execute();
conn.close();
} catch(Throwable e) {
......
......@@ -104,7 +104,7 @@ public class TestOptimizations extends TestBase {
Connection conn=getConnection("optimizations");
Statement stat = conn.createStatement();
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);
HashMap map = new HashMap();
TreeSet set = new TreeSet();
......
......@@ -25,13 +25,13 @@ public class TestRights extends TestBase {
testTableType(conn, "CACHED");
// 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 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 = getConnection("rights", "PASSREADER", "abc");
conn = getConnection("rights", "PASS_READER", "abc");
stat = conn.createStatement();
executeSuccess("SELECT * FROM PASS_NAME");
executeError("SELECT * FROM PASS");
......@@ -47,21 +47,21 @@ public class TestRights extends TestBase {
executeSuccess("CREATE TABLE SCHEMA_A.TABLE_B(ID INT)");
executeSuccess("GRANT ALL ON SCHEMA_A.TABLE_B TO TEST");
executeSuccess("CREATE TABLE HIDDEN(ID INT)");
executeSuccess("CREATE TABLE PUBTABLE(ID INT)");
executeSuccess("CREATE TABLE ROLETABLE(ID INT)");
executeSuccess("CREATE ROLE TESTROLE");
executeSuccess("GRANT SELECT ON ROLETABLE TO TESTROLE");
executeSuccess("GRANT UPDATE ON ROLETABLE TO TESTROLE");
executeSuccess("REVOKE UPDATE ON ROLETABLE FROM TESTROLE");
executeError("REVOKE SELECT, SUB1 ON ROLETABLE FROM TESTROLE");
executeSuccess("GRANT TESTROLE TO TEST");
executeSuccess("GRANT SELECT ON PUBTABLE TO PUBLIC");
executeSuccess("CREATE TABLE PUB_TABLE(ID INT)");
executeSuccess("CREATE TABLE ROLE_TABLE(ID INT)");
executeSuccess("CREATE ROLE TEST_ROLE");
executeSuccess("GRANT SELECT ON ROLE_TABLE TO TEST_ROLE");
executeSuccess("GRANT UPDATE ON ROLE_TABLE TO TEST_ROLE");
executeSuccess("REVOKE UPDATE ON ROLE_TABLE FROM TEST_ROLE");
executeError("REVOKE SELECT, SUB1 ON ROLE_TABLE FROM TEST_ROLE");
executeSuccess("GRANT TEST_ROLE TO TEST");
executeSuccess("GRANT SELECT ON PUB_TABLE TO PUBLIC");
executeSuccess("GRANT SELECT ON TEST TO TEST");
executeSuccess("CREATE ROLE SUB1");
executeSuccess("CREATE ROLE SUB2");
executeSuccess("CREATE TABLE SUBTABLE(ID INT)");
executeSuccess("GRANT ALL ON SUBTABLE TO SUB2");
executeSuccess("REVOKE UPDATE, DELETE ON SUBTABLE FROM SUB2");
executeSuccess("CREATE TABLE SUB_TABLE(ID INT)");
executeSuccess("GRANT ALL ON SUB_TABLE TO SUB2");
executeSuccess("REVOKE UPDATE, DELETE ON SUB_TABLE FROM SUB2");
executeSuccess("GRANT SUB2 TO SUB1");
executeSuccess("GRANT SUB1 TO TEST");
......@@ -97,16 +97,16 @@ public class TestRights extends TestBase {
executeSuccess("SELECT * FROM TEST");
executeSuccess("SELECT * FROM SYSTEM_RANGE(1,2)");
executeSuccess("SELECT * FROM SCHEMA_A.TABLE_B");
executeSuccess("SELECT * FROM PUBTABLE");
executeSuccess("SELECT * FROM ROLETABLE");
executeError("UPDATE ROLETABLE SET ID=0");
executeError("DELETE FROM ROLETABLE");
executeSuccess("SELECT * FROM PUB_TABLE");
executeSuccess("SELECT * FROM ROLE_TABLE");
executeError("UPDATE ROLE_TABLE SET ID=0");
executeError("DELETE FROM ROLE_TABLE");
executeError("SELECT * FROM HIDDEN");
executeError("UPDATE TEST SET ID=0");
executeSuccess("SELECT * FROM SUBTABLE");
executeSuccess("INSERT INTO SUBTABLE VALUES(1)");
executeError("DELETE FROM SUBTABLE");
executeError("UPDATE FROM SUBTABLE");
executeSuccess("SELECT * FROM SUB_TABLE");
executeSuccess("INSERT INTO SUB_TABLE VALUES(1)");
executeError("DELETE FROM SUB_TABLE");
executeError("UPDATE FROM SUB_TABLE");
executeError("CREATE USER TEST3 PASSWORD 'def'");
executeError("ALTER USER TEST2 ADMIN FALSE");
......@@ -120,7 +120,7 @@ public class TestRights extends TestBase {
conn = getConnection("rights");
stat = conn.createStatement();
executeSuccess("DROP ROLE SUB1");
executeSuccess("DROP TABLE ROLETABLE");
executeSuccess("DROP TABLE ROLE_TABLE");
executeSuccess("DROP USER TEST");
conn.close();
......@@ -159,7 +159,7 @@ public class TestRights extends TestBase {
if(stat.execute(sql)) {
ResultSet rs = stat.getResultSet();
// this will check if the resultset is updatable
// this will check if the result set is updatable
rs.getConcurrency();
ResultSetMetaData meta = rs.getMetaData();
......
......@@ -33,20 +33,20 @@ public class TestRunscript extends TestBase implements Trigger {
stat1 = conn1.createStatement();
stat1.execute("create table test (id identity, name varchar(12))");
stat1.execute("insert into test (name) values ('first'), ('second')");
stat1.execute("create sequence testseq start with 100 increment by 10");
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 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 schema testschema authorization testadmin");
stat1.execute("create table testschema.parent(id int primary key, name varchar)");
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 user testuser salt '02' hash '03'");
stat1.execute("create role testrole");
stat1.execute("grant all on testschema.child to testuser");
stat1.execute("grant select, insert on testschema.parent to testrole");
stat1.execute("grant testrole to testuser");
stat1.execute("create sequence testSeq start with 100 increment by 10");
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 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 schema testSchema authorization testAdmin");
stat1.execute("create table testSchema.parent(id int primary key, name varchar)");
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 user testUser salt '02' hash '03'");
stat1.execute("create role testRole");
stat1.execute("grant all on testSchema.child to testUser");
stat1.execute("grant select, insert on testSchema.parent to testRole");
stat1.execute("grant testRole to testUser");
String sql = "script to '"+BASE_DIR+"/backup.2.sql'";
if(password) {
......@@ -59,7 +59,7 @@ public class TestRunscript extends TestBase implements Trigger {
stat2 = conn2.createStatement();
sql = "runscript from '"+BASE_DIR+"/backup.2.sql'";
if(password) {
sql += " CIPHER AES PASSWORD 'wrongpassword'";
sql += " CIPHER AES PASSWORD 'wrongPassword'";
}
if(password) {
try {
......
......@@ -18,8 +18,8 @@ public class TestSQLInjection extends TestBase {
Statement stat;
public void test() throws Exception {
deleteDb("sqlinjection");
reconnect("sqlinjection");
deleteDb("sqlInjection");
reconnect("sqlInjection");
stat.execute("DROP TABLE IF EXISTS USERS");
stat.execute("CREATE TABLE USERS(NAME VARCHAR PRIMARY KEY, PASSWORD VARCHAR, TYPE VARCHAR)");
stat.execute("CREATE SCHEMA CONST");
......@@ -47,7 +47,7 @@ public class TestSQLInjection extends TestBase {
return;
}
reconnect("sqlinjection");
reconnect("sqlInjection");
try {
check(checkPasswordInsecure("123456"));
......
......@@ -34,7 +34,7 @@ public class TestScript extends TestBase {
private int line;
private PrintStream out;
private ArrayList result = new ArrayList();
private String putback;
private String putBack;
private StringBuffer errors;
private ArrayList statements;
private String fileName = "org/h2/test/test.in.txt";
......@@ -63,26 +63,26 @@ public class TestScript extends TestBase {
public void testScript() throws Exception {
deleteDb("script");
String outfile = "test.out.txt";
String infile = fileName;
String outFile = "test.out.txt";
String inFile = fileName;
conn = getConnection("script");
stat = conn.createStatement();
out = new PrintStream(new FileOutputStream(outfile));
out = new PrintStream(new FileOutputStream(outFile));
errors = new StringBuffer();
testFile(infile);
testFile(inFile);
conn.close();
out.close();
if(errors.length()>0) {
throw new Exception("errors:\n" + errors.toString());
} else {
new File(outfile).delete();
new File(outFile).delete();
}
}
private String readLine() throws IOException {
if (putback != null) {
String s = putback;
putback = null;
if (putBack != null) {
String s = putBack;
putBack = null;
return s;
}
while(true) {
......@@ -97,8 +97,8 @@ public class TestScript extends TestBase {
}
}
private void testFile(String infile) throws Exception {
InputStream is = getClass().getClassLoader().getResourceAsStream(infile);
private void testFile(String inFile) throws Exception {
InputStream is = getClass().getClassLoader().getResourceAsStream(inFile);
in = new LineNumberReader(new InputStreamReader(is, "Cp1252"));
StringBuffer buff = new StringBuffer();
while (true) {
......@@ -320,9 +320,9 @@ public class TestScript extends TestBase {
if (!compare.equals(s)) {
errors.append("line: ");
errors.append(line);
errors.append("\nexp: ");
errors.append("\n" + "exp: ");
errors.append(compare);
errors.append("\ngot: ");
errors.append("\n" + "got: ");
errors.append(s);
errors.append("\n");
if(e != null) {
......@@ -335,7 +335,7 @@ public class TestScript extends TestBase {
}
}
} else {
putback = compare;
putBack = compare;
}
write(s);
......
......@@ -22,8 +22,8 @@ public class TestScriptSimple extends TestBase {
}
deleteDb("scriptSimple");
reconnect();
String infile = "org/h2/test/testSimple.in.txt";
InputStream is = getClass().getClassLoader().getResourceAsStream(infile);
String inFile = "org/h2/test/testSimple.in.txt";
InputStream is = getClass().getClassLoader().getResourceAsStream(inFile);
LineNumberReader lineReader = new LineNumberReader(new InputStreamReader(is, "Cp1252"));
ScriptReader reader = new ScriptReader(lineReader);
while(true) {
......
......@@ -16,7 +16,7 @@ public class TestSequence extends TestBase {
deleteDb("sequence");
Connection conn=getConnection("sequence");
Statement stat = conn.createStatement();
stat.execute("create sequence testseq");
stat.execute("create sequence testSequence");
conn.setAutoCommit(false);
Connection conn2=getConnection("sequence");
......@@ -40,7 +40,7 @@ public class TestSequence extends TestBase {
}
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();
long value = rs.getLong(1);
return value;
......
......@@ -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 -Xrunhprof:heap=sites org.h2.test.TestAll
// java -Xprof org.h2.test.TestAll
// TODO test: here is more code, currently untested!
......@@ -52,16 +51,16 @@ public class TestSpeed extends TestBase {
// for(int i=0; i<1000; i++) {
// stat.execute("INSERT INTO TEST VALUES("+i+", 'Hello')");
// }
// stat.execute("CREATE TABLE TESTA(ID INT PRIMARY KEY, NAME VARCHAR(255))");
// stat.execute("INSERT INTO TESTA VALUES(0, 'Hello')");
// stat.execute("CREATE TABLE TEST_A(ID INT PRIMARY KEY, NAME VARCHAR(255))");
// stat.execute("INSERT INTO TEST_A VALUES(0, 'Hello')");
long time = System.currentTimeMillis();
// 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++) {
// ResultSet rs = stat.executeQuery("SELECT * FROM TESTA");
// ResultSet rs = stat.executeQuery("SELECT * FROM TEST_A");
// while(rs.next()) {
// rs.getInt(1);
// rs.getString(2);
......@@ -70,9 +69,9 @@ public class TestSpeed extends TestBase {
// 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++) {
// stat.execute("INSERT INTO TESTB VALUES("+i+", 'Hello')");
// stat.execute("INSERT INTO TEST_B VALUES("+i+", 'Hello')");
// }
// conn.close();
......@@ -82,7 +81,7 @@ public class TestSpeed extends TestBase {
//
// stat.execute("CREATE TABLE TEST(ID INT)");
// 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.getString("ID");
// stat.execute("DROP TABLE TEST");
......@@ -96,11 +95,11 @@ public class TestSpeed extends TestBase {
int max = getSize(1, 10000);
for(int i=0; i<max; i++) {
prep.setInt(1, i);
prep.setString(2, "Helloasdfaldsjflajdflajdslfoajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd" + i);
//prep.setString(2, "Helloasdfaldsjflajdflajdslfoajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd");
prep.setString(2, "abchelloasdfaldsjflajdflajdslfoajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd" + i);
//prep.setString(2, "abchelloasdfaldsjflajdflajdslfoajlskdfkjasdfadsfasdfadsfadfsalksdjflasjflajsdlkfjaksdjflkskd");
prep.execute();
// 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);
// if(!rs.next()) {
// throw new Error("hey! i="+i);
......
......@@ -39,23 +39,23 @@ public class TestTempTables extends TestBase {
// (this features are here for compatibility only)
ResultSet rs;
c1.setAutoCommit(false);
s1.execute("create local temporary table testtemp(id int) on commit delete rows");
s1.execute("insert into testtemp values(1)");
rs = s1.executeQuery("select * from testtemp");
s1.execute("create local temporary table test_temp(id int) on commit delete rows");
s1.execute("insert into test_temp values(1)");
rs = s1.executeQuery("select * from test_temp");
checkResultRowCount(rs, 1);
c1.commit();
rs = s1.executeQuery("select * from testtemp");
rs = s1.executeQuery("select * from test_temp");
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("insert into testtemp values(1)");
rs = s1.executeQuery("select * from testtemp");
s1.execute("create local temporary table test_temp(id int) on commit drop");
s1.execute("insert into test_temp values(1)");
rs = s1.executeQuery("select * from test_temp");
checkResultRowCount(rs, 1);
c1.commit();
try {
rs = s1.executeQuery("select * from testtemp");
error("testtemp should have been dropped automatically");
rs = s1.executeQuery("select * from test_temp");
error("test_temp should have been dropped automatically");
} catch(SQLException e) {
checkNotGeneralException(e);
}
......
......@@ -88,8 +88,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
}
stat.execute("DROP TRIGGER INS_AFTER");
stat.execute("DROP TRIGGER UPD_BEFORE");
stat.execute("UPDATE TEST SET NAME=NAME||'-upd-notrigger'");
stat.execute("INSERT INTO TEST VALUES(100, 'Insert-notrigger')");
stat.execute("UPDATE TEST SET NAME=NAME||'-upd-no_trigger'");
stat.execute("INSERT INTO TEST VALUES(100, 'Insert-no_trigger')");
conn.close();
conn = getConnection("trigger");
......
......@@ -124,8 +124,8 @@ public class TestUpdatableResultSet extends TestBase {
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255), " +
"DEC DECIMAL(10,2), BOO BIT, BYE TINYINT, BIN BINARY(100), "+
"D DATE, T TIME, TS TIMESTAMP, DOU DOUBLE, REA REAL, LON BIGINT, "+
"OBI INT, SHO SMALLINT, CLO CLOB, BLO BLOB)");
"D DATE, T TIME, TS TIMESTAMP, DB DOUBLE, R REAL, L BIGINT, "+
"O_I INT, SH SMALLINT, CL CLOB, BL BLOB)");
ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
ResultSetMetaData meta = rs.getMetaData();
check(meta.getColumnClassName(1), "java.lang.Integer");
......@@ -181,13 +181,13 @@ public class TestUpdatableResultSet extends TestBase {
rs.updateDate("D", Date.valueOf("2005-09-21"));
rs.updateTime("T", Time.valueOf("21:46:28"));
rs.updateTimestamp("TS", Timestamp.valueOf("2005-09-21 21:47:09.567890123"));
rs.updateDouble("DOU", 1.725);
rs.updateFloat("REA", (float)2.5);
rs.updateLong("LON", Long.MAX_VALUE);
rs.updateObject("OBI", new Integer(10));
rs.updateShort("SHO", Short.MIN_VALUE);
rs.updateCharacterStream("CLO", new StringReader("\u00ef\u00f6\u00fc"), 0); // auml ouml uuml
rs.updateBinaryStream("BLO", new ByteArrayInputStream(new byte[]{(byte)0xab, 0x12}), 0);
rs.updateDouble("DB", 1.725);
rs.updateFloat("R", (float)2.5);
rs.updateLong("L", Long.MAX_VALUE);
rs.updateObject("O_I", new Integer(10));
rs.updateShort("SH", Short.MIN_VALUE);
rs.updateCharacterStream("CL", new StringReader("\u00ef\u00f6\u00fc"), 0); // auml ouml uuml
rs.updateBinaryStream("BL", new ByteArrayInputStream(new byte[]{(byte)0xab, 0x12}), 0);
rs.insertRow();
rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID NULLS FIRST");
......
......@@ -27,7 +27,7 @@ public class TestMultiOrder extends TestMultiThread {
}
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();
}
......@@ -117,7 +117,7 @@ public class TestMultiOrder extends TestMultiThread {
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 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();
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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 B ( ID integer, AID integer, b1 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
select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00:00-02:00');
> 3;
create schema testschema;
create table testschema.test(id int);
create sequence testschema.testseq;
select testschema.testseq.nextval;
create schema TEST_SCHEMA;
create table TEST_SCHEMA.test(id int);
create sequence TEST_SCHEMA.TEST_SEQ;
select TEST_SCHEMA.TEST_SEQ.CURRVAL;
> 0;
select TEST_SCHEMA.TEST_SEQ.nextval;
> 1;
drop schema testschema;
drop schema TEST_SCHEMA;
create table test(id int);
create trigger testtrigger before insert on test call "org.h2.test.db.TestTriggersConstraints";
comment on trigger testtrigger is 'just testing';
select remarks from information_schema.triggers where trigger_name = 'TESTTRIGGER';
create trigger TEST_TRIGGER before insert on test call "org.h2.test.db.TestTriggersConstraints";
comment on trigger TEST_TRIGGER is 'just testing';
select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER';
> just testing;
@reconnect;
select remarks from information_schema.triggers where trigger_name = 'TESTTRIGGER';
select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER';
> just testing;
drop trigger testtrigger;
drop trigger TEST_TRIGGER;
@reconnect;
create alias parselong for "java.lang.Long.parseLong";
comment on alias parselong is 'Parse a long with base';
select remarks from information_schema.function_aliases where alias_name = 'PARSELONG';
create alias parse_long for "java.lang.Long.parseLong";
comment on alias parse_long is 'Parse a long with base';
select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG';
> Parse a long with base;
@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;
drop alias parselong;
drop alias parse_long;
@reconnect;
create role hr;
......@@ -116,18 +124,18 @@ drop table test;
create table test(id int);
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 index idxid is 'idindex';
comment on index IDX_ID is 'id_index';
select remarks from information_schema.constraints where constraint_name = 'CONST1';
> unique id;
select remarks from information_schema.indexes where index_name = 'IDXID';
> idindex;
select remarks from information_schema.indexes where index_name = 'IDX_ID';
> id_index;
@reconnect;
select remarks from information_schema.constraints where constraint_name = 'CONST1';
> unique id;
select remarks from information_schema.indexes where index_name = 'IDXID';
> idindex;
select remarks from information_schema.indexes where index_name = 'IDX_ID';
> id_index;
drop table test;
@reconnect;
......@@ -138,46 +146,46 @@ select remarks from information_schema.users where name = 'SALES';
@reconnect;
select remarks from information_schema.users where name = 'SALES';
> mr. money;
alter user sales rename to salesuser;
select remarks from information_schema.users where name = 'SALESUSER';
alter user sales rename to SALES_USER;
select remarks from information_schema.users where name = 'SALES_USER';
> mr. money;
@reconnect;
select remarks from information_schema.users where name = 'SALESUSER';
select remarks from information_schema.users where name = 'SALES_USER';
> mr. money;
create table test(id int);
create linked table testlink('org.h2.Driver', 'jdbc:h2:mem:', 'sa', 'sa', 'DUAL');
comment on table testlink is '123';
select remarks from information_schema.tables where table_name = 'TESTLINK';
create linked table test_link('org.h2.Driver', 'jdbc:h2:mem:', 'sa', 'sa', 'DUAL');
comment on table test_link is '123';
select remarks from information_schema.tables where table_name = 'TEST_LINK';
> 123;
@reconnect;
select remarks from information_schema.tables where table_name = 'TESTLINK';
select remarks from information_schema.tables where table_name = 'TEST_LINK';
> 123;
comment on table testlink is 'xyz';
select remarks from information_schema.tables where table_name = 'TESTLINK';
comment on table test_link is 'xyz';
select remarks from information_schema.tables where table_name = 'TEST_LINK';
> xyz;
alter table testlink rename to testl;
select remarks from information_schema.tables where table_name = 'TESTL';
alter table test_link rename to test_l;
select remarks from information_schema.tables where table_name = 'TEST_L';
> xyz;
@reconnect;
select remarks from information_schema.tables where table_name = 'TESTL';
select remarks from information_schema.tables where table_name = 'TEST_L';
> xyz;
drop table test;
@reconnect;
create table test(id int);
create view testv as select * from test;
comment on table testv is 'abc';
select remarks from information_schema.tables where table_name = 'TESTV';
create view test_v as select * from test;
comment on table test_v is 'abc';
select remarks from information_schema.tables where table_name = 'TEST_V';
> abc;
@reconnect;
select remarks from information_schema.tables where table_name = 'TESTV';
select remarks from information_schema.tables where table_name = 'TEST_V';
> abc;
alter table testv rename to testview;
select remarks from information_schema.tables where table_name = 'TESTVIEW';
alter table test_v rename to TEST_VIEW;
select remarks from information_schema.tables where table_name = 'TEST_VIEW';
> abc;
@reconnect;
select remarks from information_schema.tables where table_name = 'TESTVIEW';
select remarks from information_schema.tables where table_name = 'TEST_VIEW';
> abc;
drop table test;
@reconnect;
......
......@@ -134,4 +134,8 @@ public class TestDataPage extends TestBase implements DataHandler {
throw new Error();
}
public Object getLobSyncObject() {
return this;
}
}
......@@ -128,4 +128,8 @@ public class TestValueHashMap extends TestBase implements DataHandler {
return null;
}
public Object getLobSyncObject() {
return this;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论