提交 277312ed authored 作者: Thomas Mueller's avatar Thomas Mueller

Split long lines.

上级 87b97ef0
......@@ -118,11 +118,16 @@ public class BenchA implements Bench {
int branch = random.nextInt(branches);
int teller = random.nextInt(tellers);
PreparedStatement updateAccount = database.prepare("UPDATE ACCOUNTS SET ABALANCE=ABALANCE+? WHERE AID=?");
PreparedStatement selectBalance = database.prepare("SELECT ABALANCE FROM ACCOUNTS WHERE AID=?");
PreparedStatement updateTeller = database.prepare("UPDATE TELLERS SET TBALANCE=TBALANCE+? WHERE TID=?");
PreparedStatement updateBranch = database.prepare("UPDATE BRANCHES SET BBALANCE=BBALANCE+? WHERE BID=?");
PreparedStatement insertHistory = database.prepare("INSERT INTO HISTORY(AID,TID,BID,DELTA,HTIME,FILLER) VALUES(?,?,?,?,?,?)");
PreparedStatement updateAccount = database.prepare(
"UPDATE ACCOUNTS SET ABALANCE=ABALANCE+? WHERE AID=?");
PreparedStatement selectBalance = database.prepare(
"SELECT ABALANCE FROM ACCOUNTS WHERE AID=?");
PreparedStatement updateTeller = database.prepare(
"UPDATE TELLERS SET TBALANCE=TBALANCE+? WHERE TID=?");
PreparedStatement updateBranch = database.prepare(
"UPDATE BRANCHES SET BBALANCE=BBALANCE+? WHERE BID=?");
PreparedStatement insertHistory = database.prepare(
"INSERT INTO HISTORY(AID,TID,BID,DELTA,HTIME,FILLER) VALUES(?,?,?,?,?,?)");
int accountsPerBranch = accounts / branches;
database.setAutoCommit(false);
......
......@@ -338,7 +338,8 @@ public class TestCases extends TestBase {
conn.close();
}
private void testCompareDoubleWithIntColumn(Statement stat, boolean pk, double x, boolean prepared) throws SQLException {
private void testCompareDoubleWithIntColumn(Statement stat, boolean pk,
double x, boolean prepared) throws SQLException {
if (pk) {
stat.execute("create table test(id int primary key)");
} else {
......@@ -347,7 +348,8 @@ public class TestCases extends TestBase {
stat.execute("insert into test values(1)");
ResultSet rs;
if (prepared) {
PreparedStatement prep = stat.getConnection().prepareStatement("select * from test where id > ?");
PreparedStatement prep = stat.getConnection().prepareStatement(
"select * from test where id > ?");
prep.setDouble(1, x);
rs = prep.executeQuery();
} else {
......@@ -815,11 +817,12 @@ public class TestCases extends TestBase {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ORDER_ID INT PRIMARY KEY, ORDER_DATE DATETIME, USER_ID INT ,"
+ "DESCRIPTION VARCHAR, STATE VARCHAR, TRACKING_ID VARCHAR)");
stat.execute("CREATE TABLE TEST(ORDER_ID INT PRIMARY KEY, ORDER_DATE DATETIME, " +
"USER_ID INT, DESCRIPTION VARCHAR, STATE VARCHAR, TRACKING_ID VARCHAR)");
Timestamp orderDate = Timestamp.valueOf("2005-05-21 17:46:00");
String sql = "insert into TEST (ORDER_ID,ORDER_DATE,USER_ID,DESCRIPTION,STATE,TRACKING_ID) "
+ "select cast(? as int),cast(? as date),cast(? as int),cast(? as varchar),cast(? as varchar),cast(? as varchar) union all select ?,?,?,?,?,?";
String sql = "insert into TEST (ORDER_ID,ORDER_DATE,USER_ID,DESCRIPTION,STATE,TRACKING_ID) " +
"select cast(? as int),cast(? as date),cast(? as int),cast(? as varchar)," +
"cast(? as varchar),cast(? as varchar) union all select ?,?,?,?,?,?";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setInt(1, 5555);
ps.setTimestamp(2, orderDate);
......
......@@ -258,7 +258,8 @@ public class TestCsv extends TestBase {
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
stat.execute("call csvwrite('" + file.getName() + "', 'select NULL as a, '''' as b, ''\\N'' as c, NULL as d', 'UTF8', ',', '\"', NULL, '\\N', '\n')");
stat.execute("call csvwrite('" + file.getName() +
"', 'select NULL as a, '''' as b, ''\\N'' as c, NULL as d', 'UTF8', ',', '\"', NULL, '\\N', '\n')");
InputStreamReader reader = new InputStreamReader(fs.openFileInputStream(fileName));
// on read, an empty string is treated like null,
// but on write a null is always written with the nullString
......@@ -358,8 +359,11 @@ public class TestCsv extends TestBase {
assertEquals("It's nice", rs.getString(1));
assertEquals("\nHello*\n", rs.getString(2));
assertFalse(rs.next());
stat.execute("call csvwrite('" + fileName2 + "', 'select * from csvread(''" + fileName + "'', null, null, '';'', '''''''', ''\\'')', null, '+', '*', '#')");
rs = stat.executeQuery("select * from csvread('" + fileName2 + "', null, null, '+', '*', '#')");
stat.execute("call csvwrite('" + fileName2 +
"', 'select * from csvread(''" + fileName +
"'', null, null, '';'', '''''''', ''\\'')', null, '+', '*', '#')");
rs = stat.executeQuery("select * from csvread('" + fileName2 +
"', null, null, '+', '*', '#')");
meta = rs.getMetaData();
assertEquals(2, meta.getColumnCount());
assertEquals("A", meta.getColumnLabel(1));
......@@ -473,7 +477,8 @@ public class TestCsv extends TestBase {
}
long time;
time = System.currentTimeMillis();
Csv.getInstance().write(conn, getBaseDir() + "/testRW.csv", "SELECT X ID, 'Ruebezahl' NAME FROM SYSTEM_RANGE(1, " + len + ")", "UTF8");
Csv.getInstance().write(conn, getBaseDir() + "/testRW.csv",
"SELECT X ID, 'Ruebezahl' NAME FROM SYSTEM_RANGE(1, " + len + ")", "UTF8");
trace("write: " + (System.currentTimeMillis() - time));
ResultSet rs;
time = System.currentTimeMillis();
......
......@@ -122,7 +122,8 @@ public class TestDateStorage extends TestBase {
}
private static void test(int year, int month, int day, int hour) {
DateTimeUtils.parseDateTime(year + "-" + month + "-" + day + " " + hour + ":00:00", Value.TIMESTAMP, ErrorCode.TIMESTAMP_CONSTANT_2);
DateTimeUtils.parseDateTime(year + "-" + month + "-" + day + " " + hour + ":00:00",
Value.TIMESTAMP, ErrorCode.TIMESTAMP_CONSTANT_2);
}
private void testAllTimeZones() throws SQLException {
......
......@@ -446,12 +446,22 @@ public class TestLinkedTable extends TestBase {
Connection conn = DriverManager.getConnection(url1, "sa1", "abc abc");
Statement stat = conn.createStatement();
stat.execute("CREATE TEMP TABLE TEST_TEMP(ID INT PRIMARY KEY)");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(200), XT TINYINT, XD DECIMAL(10,2), XTS TIMESTAMP, XBY BINARY(255), XBO BIT, XSM SMALLINT, XBI BIGINT, XBL BLOB, XDA DATE, XTI TIME, XCL CLOB, XDO DOUBLE)");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, " +
"NAME VARCHAR(200), XT TINYINT, XD DECIMAL(10,2), " +
"XTS TIMESTAMP, XBY BINARY(255), XBO BIT, XSM SMALLINT, " +
"XBI BIGINT, XBL BLOB, XDA DATE, XTI TIME, XCL CLOB, XDO DOUBLE)");
stat.execute("CREATE INDEX IDXNAME ON TEST(NAME)");
stat.execute("INSERT INTO TEST VALUES(0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello', -1, 10.30, '2001-02-03 11:22:33.4455', X'FF0102', TRUE, 3000, 1234567890123456789, X'1122AA', DATE '0002-01-01', TIME '00:00:00', 'J\u00fcrg', 2.25)");
stat.execute("INSERT INTO TEST VALUES(0, NULL, NULL, NULL, NULL, " +
"NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello', -1, 10.30, " +
"'2001-02-03 11:22:33.4455', X'FF0102', TRUE, 3000, " +
"1234567890123456789, X'1122AA', DATE '0002-01-01', " +
"TIME '00:00:00', 'J\u00fcrg', 2.25)");
testRow(stat, "TEST");
stat.execute("INSERT INTO TEST VALUES(2, 'World', 30, 100.05, '2005-12-31 12:34:56.789', X'FFEECC33', FALSE, 1, -1234567890123456789, X'4455FF', DATE '9999-12-31', TIME '23:59:59', 'George', -2.5)");
stat.execute("INSERT INTO TEST VALUES(2, 'World', 30, 100.05, " +
"'2005-12-31 12:34:56.789', X'FFEECC33', FALSE, 1, " +
"-1234567890123456789, X'4455FF', DATE '9999-12-31', " +
"TIME '23:59:59', 'George', -2.5)");
testRow(stat, "TEST");
stat.execute("SELECT * FROM TEST_TEMP");
conn.close();
......@@ -483,7 +493,10 @@ public class TestLinkedTable extends TestBase {
conn = DriverManager.getConnection(url2, "sa2", "def def");
stat = conn.createStatement();
stat.execute("INSERT INTO LINK_TEST VALUES(3, 'Link Test', 30, 100.05, '2005-12-31 12:34:56.789', X'FFEECC33', FALSE, 1, -1234567890123456789, X'4455FF', DATE '9999-12-31', TIME '23:59:59', 'George', -2.5)");
stat.execute("INSERT INTO LINK_TEST VALUES(3, 'Link Test', " +
"30, 100.05, '2005-12-31 12:34:56.789', X'FFEECC33', " +
"FALSE, 1, -1234567890123456789, X'4455FF', " +
"DATE '9999-12-31', TIME '23:59:59', 'George', -2.5)");
rs = stat.executeQuery("SELECT COUNT(*) FROM LINK_TEST");
rs.next();
......
......@@ -773,7 +773,8 @@ public class TestLob extends TestBase {
conn0.getAutoCommit();
conn0.getAutoCommit();
PreparedStatement prep2 = 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=?");
.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();
......
......@@ -271,7 +271,8 @@ public class TestOptimizations extends TestBase {
stat.execute("create view test_view as select a.status, a.tag from accounts a, parent t where a.id = t.id");
rs = stat.executeQuery("select * from test_view where status='X' and tag in ('A','B')");
assertTrue(rs.next());
rs = stat.executeQuery("select * from (select a.status, a.tag from accounts a, parent t where a.id = t.id) x where status='X' and tag in ('A','B')");
rs = stat.executeQuery("select * from (select a.status, a.tag " +
"from accounts a, parent t where a.id = t.id) x where status='X' and tag in ('A','B')");
assertTrue(rs.next());
stat.execute("create table test(id int primary key, name varchar(255))");
......
......@@ -76,7 +76,8 @@ public class TestReadOnly extends TestBase {
} catch (SQLException e) {
assertKnownException(e);
}
stat.execute("create local temporary linked table test(null, 'jdbc:h2:mem:test3', 'sa', 'sa', 'INFORMATION_SCHEMA.TABLES')");
stat.execute("create local temporary linked table test(" +
"null, 'jdbc:h2:mem:test3', 'sa', 'sa', 'INFORMATION_SCHEMA.TABLES')");
ResultSet rs = stat.executeQuery("select * from test");
assertTrue(rs.next());
conn.close();
......
......@@ -65,7 +65,9 @@ public class TestRecursiveQueries extends TestBase {
ResultSet rs;
stat = conn.createStatement();
rs = stat.executeQuery("with recursive t(n) as (select 1 union all select n+1 from t where n<3) select * from t");
rs = stat.executeQuery("with recursive t(n) as " +
"(select 1 union all select n+1 from t where n<3) " +
"select * from t");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertTrue(rs.next());
......@@ -74,7 +76,9 @@ public class TestRecursiveQueries extends TestBase {
assertEquals(3, rs.getInt(1));
assertFalse(rs.next());
prep = conn.prepareStatement("with recursive t(n) as (select 1 union all select n+1 from t where n<3) select * from t where n>?");
prep = conn.prepareStatement("with recursive t(n) as " +
"(select 1 union all select n+1 from t where n<3) " +
"select * from t where n>?");
prep.setInt(1, 2);
rs = prep.executeQuery();
assertTrue(rs.next());
......@@ -89,7 +93,9 @@ public class TestRecursiveQueries extends TestBase {
assertEquals(3, rs.getInt(1));
assertFalse(rs.next());
prep = conn.prepareStatement("with recursive t(n) as (select @start union all select n+@inc from t where n<@end) select * from t");
prep = conn.prepareStatement("with recursive t(n) as " +
"(select @start union all select n+@inc from t where n<@end) " +
"select * from t");
prep2 = conn.prepareStatement("select @start:=?, @inc:=?, @end:=?");
prep2.setInt(1, 10);
prep2.setInt(2, 2);
......
......@@ -184,12 +184,14 @@ public class TestRunscript extends TestBase implements Trigger {
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 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 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");
......
......@@ -260,8 +260,10 @@ public class TestTransaction extends TestBase {
Statement s1 = c1.createStatement();
s1.execute("drop table if exists a");
s1.execute("drop table if exists b");
s1.execute("create table a (id integer identity not null, code varchar(10) not null, primary key(id))");
s1.execute("create table b (name varchar(100) not null, a integer, primary key(name), foreign key(a) references a(id))");
s1.execute("create table a (id integer identity not null, " +
"code varchar(10) not null, primary key(id))");
s1.execute("create table b (name varchar(100) not null, a integer, " +
"primary key(name), foreign key(a) references a(id))");
Connection c2 = getConnection("transaction");
c2.setAutoCommit(false);
s1.executeUpdate("insert into A(code) values('one')");
......
......@@ -151,7 +151,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat.execute("drop table if exists test");
stat.execute("create table test(id int)");
stat.execute("create view test_view as select * from test");
stat.execute("create trigger test_view_insert instead of insert on test_view for each row call \"" + TestView.class.getName() + "\"");
stat.execute("create trigger test_view_insert " +
"instead of insert on test_view for each row call \"" + TestView.class.getName() + "\"");
if (!config.memory) {
conn.close();
conn = getConnection("trigger");
......@@ -219,7 +220,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat = conn.createStatement();
stat.execute("drop table if exists meta_tables");
stat.execute("create table meta_tables(name varchar)");
stat.execute("create trigger meta_tables_select before select on meta_tables call \"" + TestSelect.class.getName() + "\"");
stat.execute("create trigger meta_tables_select " +
"before select on meta_tables call \"" + TestSelect.class.getName() + "\"");
ResultSet rs;
rs = stat.executeQuery("select * from meta_tables");
assertTrue(rs.next());
......@@ -319,7 +321,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
Statement stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("create table test(id int primary key, parent int)");
stat.execute("alter table test add constraint test_parent_id foreign key(parent) references test (id) on delete cascade");
stat.execute("alter table test add constraint test_parent_id " +
"foreign key(parent) references test (id) on delete cascade");
stat.execute("insert into test select x, x/2 from system_range(0, 100)");
stat.execute("delete from test");
assertSingleValue(stat, "select count(*) from test", 0);
......@@ -336,28 +339,37 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
// CREATE TRIGGER trigger {BEFORE|AFTER}
// {INSERT|UPDATE|DELETE|ROLLBACK} ON table
// [FOR EACH ROW] [QUEUE n] [NOWAIT] CALL triggeredClass
stat.execute("CREATE TRIGGER IF NOT EXISTS INS_BEFORE BEFORE INSERT ON TEST FOR EACH ROW NOWAIT CALL \""
+ getClass().getName() + "\"");
stat.execute("CREATE TRIGGER IF NOT EXISTS INS_BEFORE BEFORE INSERT ON TEST FOR EACH ROW NOWAIT CALL \""
+ getClass().getName() + "\"");
stat.execute("CREATE TRIGGER INS_AFTER AFTER INSERT ON TEST FOR EACH ROW NOWAIT CALL \"" + getClass().getName()
+ "\"");
stat.execute("CREATE TRIGGER UPD_BEFORE BEFORE UPDATE ON TEST FOR EACH ROW NOWAIT CALL \""
+ getClass().getName() + "\"");
stat.execute("CREATE TRIGGER INS_AFTER_ROLLBACK AFTER INSERT, ROLLBACK ON TEST FOR EACH ROW NOWAIT CALL \"" + getClass().getName()
+ "\"");
stat.execute("CREATE TRIGGER IF NOT EXISTS INS_BEFORE " +
"BEFORE INSERT ON TEST " +
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\"");
stat.execute("CREATE TRIGGER IF NOT EXISTS INS_BEFORE " +
"BEFORE INSERT ON TEST " +
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\"");
stat.execute("CREATE TRIGGER INS_AFTER " + "" +
"AFTER INSERT ON TEST " +
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\"");
stat.execute("CREATE TRIGGER UPD_BEFORE " +
"BEFORE UPDATE ON TEST " +
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\"");
stat.execute("CREATE TRIGGER INS_AFTER_ROLLBACK " +
"AFTER INSERT, ROLLBACK ON TEST " +
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\"");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello')");
ResultSet rs;
rs = stat.executeQuery("SCRIPT");
checkRows(rs, new String[] {
"CREATE FORCE TRIGGER PUBLIC.INS_BEFORE BEFORE INSERT ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+ getClass().getName() + "\";",
"CREATE FORCE TRIGGER PUBLIC.INS_AFTER AFTER INSERT ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+ getClass().getName() + "\";",
"CREATE FORCE TRIGGER PUBLIC.UPD_BEFORE BEFORE UPDATE ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+ getClass().getName() + "\";",
"CREATE FORCE TRIGGER PUBLIC.INS_AFTER_ROLLBACK AFTER INSERT, ROLLBACK ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+ getClass().getName() + "\";",
"CREATE FORCE TRIGGER PUBLIC.INS_BEFORE " +
"BEFORE INSERT ON PUBLIC.TEST " +
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\";",
"CREATE FORCE TRIGGER PUBLIC.INS_AFTER " +
"AFTER INSERT ON PUBLIC.TEST " +
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\";",
"CREATE FORCE TRIGGER PUBLIC.UPD_BEFORE " +
"BEFORE UPDATE ON PUBLIC.TEST " +
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\";",
"CREATE FORCE TRIGGER PUBLIC.INS_AFTER_ROLLBACK " +
"AFTER INSERT, ROLLBACK ON PUBLIC.TEST " +
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\";",
});
while (rs.next()) {
String sql = rs.getString(1);
......@@ -468,10 +480,13 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
if (!"TEST".equals(tableName)) {
throw new AssertionError("supposed to be TEST");
}
if ((trigger.endsWith("AFTER") && before) || (trigger.endsWith("BEFORE") && !before)) {
if ((trigger.endsWith("AFTER") && before) ||
(trigger.endsWith("BEFORE") && !before)) {
throw new AssertionError("triggerName: " + trigger + " before:" + before);
}
if ((trigger.startsWith("UPD") && type != UPDATE) || (trigger.startsWith("INS") && type != INSERT) || (trigger.startsWith("DEL") && type != DELETE)) {
if ((trigger.startsWith("UPD") && type != UPDATE) ||
(trigger.startsWith("INS") && type != INSERT) ||
(trigger.startsWith("DEL") && type != DELETE)) {
throw new AssertionError("triggerName: " + trigger + " type:" + type);
}
}
......
......@@ -46,7 +46,8 @@ public class TestUpgrade extends TestBase {
private void testLobs() throws Exception {
deleteDb("upgrade");
Connection conn;
conn = DriverManager.getConnection("jdbc:h2v1_1:" + getBaseDir() + "/upgrade;PAGE_STORE=FALSE", getUser(), getPassword());
conn = DriverManager.getConnection("jdbc:h2v1_1:" +
getBaseDir() + "/upgrade;PAGE_STORE=FALSE", getUser(), getPassword());
conn.createStatement().execute("create table test(data clob) as select space(100000)");
conn.close();
assertTrue(IOUtils.exists(getBaseDir() + "/upgrade.data.db"));
......@@ -105,9 +106,11 @@ public class TestUpgrade extends TestBase {
// Create old db
Utils.callStaticMethod("org.h2.upgrade.v1_1.Driver.load");
Connection connOld = DriverManager.getConnection("jdbc:h2v1_1:" + getBaseDir() + "/upgradeOld;PAGE_STORE=FALSE" + additionalParameters);
Connection connOld = DriverManager.getConnection("jdbc:h2v1_1:" +
getBaseDir() + "/upgradeOld;PAGE_STORE=FALSE" + additionalParameters);
// Test auto server, too
Connection connOld2 = DriverManager.getConnection("jdbc:h2v1_1:" + getBaseDir() + "/upgradeOld;PAGE_STORE=FALSE" + additionalParameters);
Connection connOld2 = DriverManager.getConnection("jdbc:h2v1_1:" +
getBaseDir() + "/upgradeOld;PAGE_STORE=FALSE" + additionalParameters);
Statement statOld = connOld.createStatement();
statOld.execute("create table testOld(id int)");
connOld.close();
......@@ -115,24 +118,32 @@ public class TestUpgrade extends TestBase {
assertTrue(IOUtils.exists(getBaseDir() + "/upgradeOld.data.db"));
// Create new DB
Connection connNew = DriverManager.getConnection("jdbc:h2:" + getBaseDir() + "/upgrade" + additionalParameters);
Connection connNew2 = DriverManager.getConnection("jdbc:h2:" + getBaseDir() + "/upgrade" + additionalParameters);
Connection connNew = DriverManager.getConnection("jdbc:h2:" +
getBaseDir() + "/upgrade" + additionalParameters);
Connection connNew2 = DriverManager.getConnection("jdbc:h2:" +
getBaseDir() + "/upgrade" + additionalParameters);
Statement statNew = connNew.createStatement();
statNew.execute("create table test(id int)");
// Link to old DB without upgrade
statNew.executeUpdate("CREATE LOCAL TEMPORARY LINKED TABLE linkedTestOld('org.h2.Driver', 'jdbc:h2v1_1:" + getBaseDir() + "/upgradeOld" + additionalParameters + "', '', '', 'TestOld')");
statNew.executeUpdate("CREATE LOCAL TEMPORARY LINKED TABLE " +
"linkedTestOld('org.h2.Driver', 'jdbc:h2v1_1:" +
getBaseDir() + "/upgradeOld" + additionalParameters + "', '', '', 'TestOld')");
statNew.executeQuery("select * from linkedTestOld");
connNew.close();
connNew2.close();
assertTrue(IOUtils.exists(getBaseDir() + "/upgradeOld.data.db"));
assertTrue(IOUtils.exists(getBaseDir() + "/upgrade.h2.db"));
connNew = DriverManager.getConnection("jdbc:h2:" + getBaseDir() + "/upgrade" + additionalParameters);
connNew2 = DriverManager.getConnection("jdbc:h2:" + getBaseDir() + "/upgrade" + additionalParameters);
connNew = DriverManager.getConnection("jdbc:h2:" +
getBaseDir() + "/upgrade" + additionalParameters);
connNew2 = DriverManager.getConnection("jdbc:h2:" +
getBaseDir() + "/upgrade" + additionalParameters);
statNew = connNew.createStatement();
// Link to old DB with upgrade
statNew.executeUpdate("CREATE LOCAL TEMPORARY LINKED TABLE linkedTestOld('org.h2.Driver', 'jdbc:h2:" + getBaseDir() + "/upgradeOld" + additionalParameters + "', '', '', 'TestOld')");
statNew.executeUpdate("CREATE LOCAL TEMPORARY LINKED TABLE " +
"linkedTestOld('org.h2.Driver', 'jdbc:h2:" +
getBaseDir() + "/upgradeOld" + additionalParameters + "', '', '', 'TestOld')");
statNew.executeQuery("select * from linkedTestOld");
connNew.close();
connNew2.close();
......@@ -172,14 +183,16 @@ public class TestUpgrade extends TestBase {
// Create old db
Utils.callStaticMethod("org.h2.upgrade.v1_1.Driver.load");
Connection conn = DriverManager.getConnection("jdbc:h2v1_1:" + getBaseDir() + "/upgrade;PAGE_STORE=FALSE;CIPHER=AES", "abc", "abc abc");
Connection conn = DriverManager.getConnection("jdbc:h2v1_1:" +
getBaseDir() + "/upgrade;PAGE_STORE=FALSE;CIPHER=AES", "abc", "abc abc");
Statement stat = conn.createStatement();
stat.execute("create table test(id int)");
conn.close();
assertTrue(IOUtils.exists(getBaseDir() + "/upgrade.data.db"));
// Connect to old DB with upgrade
conn = DriverManager.getConnection("jdbc:h2:" + getBaseDir() + "/upgrade;CIPHER=AES", "abc", "abc abc");
conn = DriverManager.getConnection("jdbc:h2:" +
getBaseDir() + "/upgrade;CIPHER=AES", "abc", "abc abc");
stat = conn.createStatement();
stat.executeQuery("select * from test");
conn.close();
......@@ -191,7 +204,8 @@ public class TestUpgrade extends TestBase {
public void deleteDb(String dbName) {
super.deleteDb(dbName);
try {
Utils.callStaticMethod("org.h2.upgrade.v1_1.tools.DeleteDbFiles.execute", getBaseDir(), dbName, true);
Utils.callStaticMethod("org.h2.upgrade.v1_1.tools.DeleteDbFiles.execute",
getBaseDir(), dbName, true);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
......
......@@ -81,13 +81,18 @@ public class TestCallableStatement extends TestBase {
call.setInt(1, 1);
call.setString(2, "Hello");
call.execute();
call = conn.prepareCall("SELECT * FROM TEST", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
call = conn.prepareCall("SELECT * FROM TEST",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
rs = call.executeQuery();
rs.next();
assertEquals(1, rs.getInt(1));
assertEquals("Hello", rs.getString(2));
assertFalse(rs.next());
call = conn.prepareCall("SELECT * FROM TEST", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
call = conn.prepareCall("SELECT * FROM TEST",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
ResultSet.HOLD_CURSORS_OVER_COMMIT);
rs = call.executeQuery();
rs.next();
assertEquals(1, rs.getInt(1));
......
......@@ -345,7 +345,8 @@ public class TestMetaData extends TestBase {
ResultSet rs;
stat = conn.createStatement();
stat.execute("CREATE TABLE PARENT(A INT, B INT, PRIMARY KEY(A, B))");
stat.execute("CREATE TABLE CHILD(ID INT PRIMARY KEY, PA INT, PB INT, CONSTRAINT AB FOREIGN KEY(PA, PB) REFERENCES PARENT(A, B))");
stat.execute("CREATE TABLE CHILD(ID INT PRIMARY KEY, PA INT, PB INT, " +
"CONSTRAINT AB FOREIGN KEY(PA, PB) REFERENCES PARENT(A, B))");
rs = meta.getCrossReference(null, "PUBLIC", "PARENT", null, "PUBLIC", "CHILD");
checkCrossRef(rs);
rs = meta.getImportedKeys(null, "PUBLIC", "CHILD");
......
......@@ -565,7 +565,8 @@ public class TestPreparedStatement extends TestBase {
stat.execute("DROP TABLE TEST3");
}
private void checkParameter(PreparedStatement prep, int index, String className, int type, String typeName, int precision, int scale) throws SQLException {
private void checkParameter(PreparedStatement prep, int index,
String className, int type, String typeName, int precision, int scale) throws SQLException {
ParameterMetaData meta = prep.getParameterMetaData();
assertEquals(className, meta.getParameterClassName(index));
assertEquals(type, meta.getParameterType(index));
......@@ -616,7 +617,8 @@ public class TestPreparedStatement extends TestBase {
stat.execute("INSERT INTO TEST VALUES(1),(2),(3)");
PreparedStatement prep;
ResultSet rs;
prep = conn.prepareStatement("EXPLAIN SELECT COUNT(*) FROM TEST WHERE CASEWHEN(ID=1, ID, ID)=? GROUP BY ID");
prep = conn.prepareStatement("EXPLAIN SELECT COUNT(*) FROM TEST " +
"WHERE CASEWHEN(ID=1, ID, ID)=? GROUP BY ID");
prep.setInt(1, 1);
rs = prep.executeQuery();
rs.next();
......@@ -624,7 +626,8 @@ public class TestPreparedStatement extends TestBase {
trace(plan);
rs.close();
prep = conn
.prepareStatement("EXPLAIN SELECT COUNT(*) FROM TEST WHERE CASE ID WHEN 1 THEN ID WHEN 2 THEN ID ELSE ID END=? GROUP BY ID");
.prepareStatement("EXPLAIN SELECT COUNT(*) FROM TEST " +
"WHERE CASE ID WHEN 1 THEN ID WHEN 2 THEN ID ELSE ID END=? GROUP BY ID");
prep.setInt(1, 1);
rs = prep.executeQuery();
rs.next();
......
......@@ -215,7 +215,9 @@ public class TestResultSet extends TestBase {
private void testOwnUpdates() throws SQLException {
DatabaseMetaData meta = conn.getMetaData();
for (int i = 0; i < 3; i++) {
int type = i == 0 ? ResultSet.TYPE_FORWARD_ONLY : i == 1 ? ResultSet.TYPE_SCROLL_INSENSITIVE : ResultSet.TYPE_SCROLL_SENSITIVE;
int type = i == 0 ? ResultSet.TYPE_FORWARD_ONLY :
i == 1 ? ResultSet.TYPE_SCROLL_INSENSITIVE :
ResultSet.TYPE_SCROLL_SENSITIVE;
assertTrue(meta.ownUpdatesAreVisible(type));
assertFalse(meta.ownDeletesAreVisible(type));
assertFalse(meta.ownInsertsAreVisible(type));
......
......@@ -173,7 +173,10 @@ public class TestStatement extends TestBase {
stat.setFetchSize(0);
assertEquals(SysProperties.SERVER_RESULT_SET_FETCH_SIZE, stat.getFetchSize());
assertEquals(ResultSet.TYPE_FORWARD_ONLY, stat.getResultSetType());
Statement stat2 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
Statement stat2 = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY,
ResultSet.HOLD_CURSORS_OVER_COMMIT);
assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, stat2.getResultSetType());
assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, stat2.getResultSetHoldability());
assertEquals(ResultSet.CONCUR_READ_ONLY, stat2.getResultSetConcurrency());
......
......@@ -541,7 +541,8 @@ public class TestUpdatableResultSet extends TestBase {
}
}
private void assertState(ResultSet rs, boolean beforeFirst, boolean first, boolean last, boolean afterLast) throws SQLException {
private void assertState(ResultSet rs, boolean beforeFirst,
boolean first, boolean last, boolean afterLast) throws SQLException {
assertEquals(beforeFirst, rs.isBeforeFirst());
assertEquals(first, rs.isFirst());
assertEquals(last, rs.isLast());
......
......@@ -107,8 +107,10 @@ public class TestMvcc1 extends TestBase {
c2.commit();
// referential integrity problem
s1.execute("create table a (id integer identity not null, code varchar(10) not null, primary key(id))");
s1.execute("create table b (name varchar(100) not null, a integer, primary key(name), foreign key(a) references a(id))");
s1.execute("create table a (id integer identity not null, " +
"code varchar(10) not null, primary key(id))");
s1.execute("create table b (name varchar(100) not null, a integer, " +
"primary key(name), foreign key(a) references a(id))");
s1.execute("insert into a(code) values('one')");
try {
s2.execute("insert into b values('un B', 1)");
......
......@@ -78,7 +78,8 @@ public class TestRecover {
testLoop();
}
private static File backup(String sourcePath, String targetPath, String basePath, int max, String node) throws IOException {
private static File backup(String sourcePath, String targetPath,
String basePath, int max, String node) throws IOException {
File root = new File(targetPath);
if (!root.exists()) {
root.mkdirs();
......
......@@ -106,19 +106,25 @@ public class TestWeb extends TestBase {
client.readSessionId(result);
result = client.get(url, "tools.jsp");
IOUtils.delete(getBaseDir() + "/backup.zip");
result = client.get(url, "tools.do?tool=Backup&args=-dir," + getBaseDir() + ",-db,web,-file," + getBaseDir() + "/backup.zip");
result = client.get(url, "tools.do?tool=Backup&args=-dir," +
getBaseDir() + ",-db,web,-file," + getBaseDir() + "/backup.zip");
deleteDb("web");
assertTrue(IOUtils.exists(getBaseDir() + "/backup.zip"));
result = client.get(url, "tools.do?tool=DeleteDbFiles&args=-dir," + getBaseDir() + ",-db,web");
result = client.get(url, "tools.do?tool=DeleteDbFiles&args=-dir," +
getBaseDir() + ",-db,web");
assertFalse(IOUtils.exists(getBaseDir() + "/web.h2.db"));
result = client.get(url, "tools.do?tool=Restore&args=-dir," + getBaseDir() + ",-db,web,-file," + getBaseDir() + "/backup.zip");
result = client.get(url, "tools.do?tool=Restore&args=-dir," +
getBaseDir() + ",-db,web,-file," + getBaseDir() + "/backup.zip");
assertTrue(IOUtils.exists(getBaseDir() + "/web.h2.db"));
IOUtils.delete(getBaseDir() + "/web.h2.sql");
IOUtils.delete(getBaseDir() + "/backup.zip");
result = client.get(url, "tools.do?tool=Recover&args=-dir," + getBaseDir() + ",-db,web");
result = client.get(url, "tools.do?tool=Recover&args=-dir," +
getBaseDir() + ",-db,web");
assertTrue(IOUtils.exists(getBaseDir() + "/web.h2.sql"));
IOUtils.delete(getBaseDir() + "/web.h2.sql");
result = client.get(url, "tools.do?tool=RunScript&args=-script," + getBaseDir() + "/web.h2.sql,-url," + getURL("web", true) + ",-user," + getUser() + ",-password," + getPassword());
result = client.get(url, "tools.do?tool=RunScript&args=-script," +
getBaseDir() + "/web.h2.sql,-url," + getURL("web", true) +
",-user," + getUser() + ",-password," + getPassword());
IOUtils.delete(getBaseDir() + "/web.h2.sql");
assertTrue(IOUtils.exists(getBaseDir() + "/web.h2.db"));
deleteDb("web");
......@@ -218,7 +224,8 @@ public class TestWeb extends TestBase {
assertTrue(result.indexOf("Exception") < 0);
result = client.get(url, "login.do?driver=org.h2.Driver&url=jdbc:h2:mem:web&user=sa&password=sa&name=_test_");
result = client.get(url, "header.jsp");
result = client.get(url, "query.do?sql=create table test(id int primary key, name varchar);insert into test values(1, 'Hello')");
result = client.get(url, "query.do?sql=create table test(id int primary key, name varchar);" +
"insert into test values(1, 'Hello')");
result = client.get(url, "query.do?sql=create sequence test_sequence");
result = client.get(url, "query.do?sql=create schema test_schema");
result = client.get(url, "query.do?sql=create view test_view as select * from test");
......
......@@ -96,7 +96,8 @@ public class TestFuzzOptimizations extends TestBase {
Random seedGenerator = new Random();
String[] columns = new String[] { "a", "b", "c" };
String[] values = new String[] { null, "0", "0", "1", "2", "10", "a", "?" };
String[] compares = new String[] { "in(", "not in(", "=", "=", ">", "<", ">=", "<=", "<>", "in(select", "not in(select" };
String[] compares = new String[] { "in(", "not in(", "=", "=", ">",
"<", ">=", "<=", "<>", "in(select", "not in(select" };
int size = getSize(100, 1000);
for (int i = 0; i < size; i++) {
long seed = seedGenerator.nextLong();
......
......@@ -87,7 +87,9 @@ public class TestKill extends TestBase {
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE IF NOT EXISTS ACCOUNT(ID INT PRIMARY KEY, SUM INT)");
stat
.execute("CREATE TABLE IF NOT EXISTS LOG(ID IDENTITY, ACCOUNTID INT, AMOUNT INT, FOREIGN KEY(ACCOUNTID) REFERENCES ACCOUNT(ID))");
.execute("CREATE TABLE IF NOT EXISTS LOG(" +
"ID IDENTITY, ACCOUNTID INT, AMOUNT INT, " +
"FOREIGN KEY(ACCOUNTID) REFERENCES ACCOUNT(ID))");
stat.execute("CREATE TABLE IF NOT EXISTS TEST_A(ID INT PRIMARY KEY, DATA VARCHAR)");
stat.execute("CREATE TABLE IF NOT EXISTS TEST_B(ID INT PRIMARY KEY, DATA VARCHAR)");
}
......
......@@ -310,11 +310,13 @@ public class TestNestedJoins extends TestBase {
stat.execute("create table test(id int primary key, x int) as select x, x from system_range(1, 10)");
stat.execute("create index on test(x)");
stat.execute("create table o(id int primary key) as select x from system_range(1, 10)");
rs = stat.executeQuery("explain select * from test a inner join test b on a.id=b.id inner join o on o.id=a.id where b.x=1");
rs = stat.executeQuery("explain select * from test a inner join " +
"test b on a.id=b.id inner join o on o.id=a.id where b.x=1");
assertTrue(rs.next());
sql = rs.getString(1);
assertTrue("using table scan", sql.indexOf("tableScan") < 0);
rs = stat.executeQuery("explain select * from test a inner join test b on a.id=b.id left outer join o on o.id=a.id where b.x=1");
rs = stat.executeQuery("explain select * from test a inner join " +
"test b on a.id=b.id left outer join o on o.id=a.id where b.x=1");
assertTrue(rs.next());
sql = rs.getString(1);
// TODO Support optimizing queries with both inner and outer joins
......@@ -331,7 +333,8 @@ public class TestNestedJoins extends TestBase {
*/
stat.execute("create table test(id int primary key)");
stat.execute("insert into test values(1)");
rs = stat.executeQuery("select b.id from test a left outer join test b on a.id = b.id and not exists (select * from test c where c.id = b.id)");
rs = stat.executeQuery("select b.id from test a left outer join " +
"test b on a.id = b.id and not exists (select * from test c where c.id = b.id)");
assertTrue(rs.next());
sql = rs.getString(1);
assertEquals(null, sql);
......@@ -370,11 +373,15 @@ public class TestNestedJoins extends TestBase {
stat.execute("insert into t2 values(1,1), (2,2)");
stat.execute("insert into t3 values(1,1), (3,3)");
stat.execute("insert into t4 values(1,1), (2,2), (3,3), (4,4)");
rs = stat.executeQuery("explain select distinct t1.a, t2.a, t3.a from t1 right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
rs = stat.executeQuery("explain select distinct t1.a, t2.a, t3.a from t1 " +
"right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
assertTrue(rs.next());
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT DISTINCT T1.A, T2.A, T3.A FROM PUBLIC.T2 LEFT OUTER JOIN ( PUBLIC.T3 LEFT OUTER JOIN ( PUBLIC.T1 ) ON T1.B = T3.A ) ON T2.B = T1.A", sql);
rs = stat.executeQuery("select distinct t1.a, t2.a, t3.a from t1 right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
assertEquals("SELECT DISTINCT T1.A, T2.A, T3.A FROM PUBLIC.T2 " +
"LEFT OUTER JOIN ( PUBLIC.T3 LEFT OUTER JOIN ( PUBLIC.T1 ) " +
"ON T1.B = T3.A ) ON T2.B = T1.A", sql);
rs = stat.executeQuery("select distinct t1.a, t2.a, t3.a from t1 " +
"right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
// expected: 1 1 1; null 2 null
assertTrue(rs.next());
assertEquals("1", rs.getString(1));
......@@ -404,11 +411,14 @@ public class TestNestedJoins extends TestBase {
stat.execute("insert into a values(1)");
stat.execute("insert into b values(1)");
stat.execute("insert into c values(1), (2)");
rs = stat.executeQuery("explain select a.x, b.x, c.x from a inner join b on a.x = b.x right outer join c on c.x = a.x");
rs = stat.executeQuery("explain select a.x, b.x, c.x from a " +
"inner join b on a.x = b.x right outer join c on c.x = a.x");
assertTrue(rs.next());
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.X, B.X, C.X FROM PUBLIC.C LEFT OUTER JOIN ( PUBLIC.A INNER JOIN PUBLIC.B ON A.X = B.X ) ON C.X = A.X", sql);
rs = stat.executeQuery("select a.x, b.x, c.x from a inner join b on a.x = b.x right outer join c on c.x = a.x");
assertEquals("SELECT A.X, B.X, C.X FROM PUBLIC.C LEFT OUTER JOIN " +
"( PUBLIC.A INNER JOIN PUBLIC.B ON A.X = B.X ) ON C.X = A.X", sql);
rs = stat.executeQuery("select a.x, b.x, c.x from a inner join b on a.x = b.x " +
"right outer join c on c.x = a.x");
// expected result: 1 1 1; null null 2
assertTrue(rs.next());
assertEquals("1", rs.getString(1));
......
......@@ -326,11 +326,15 @@ public class TestOuterJoins extends TestBase {
stat.execute("insert into t2 values(1,1), (2,2)");
stat.execute("insert into t3 values(1,1), (3,3)");
stat.execute("insert into t4 values(1,1), (2,2), (3,3), (4,4)");
rs = stat.executeQuery("explain select distinct t1.a, t2.a, t3.a from t1 right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
rs = stat.executeQuery("explain select distinct t1.a, t2.a, t3.a from t1 " +
"right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
assertTrue(rs.next());
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT DISTINCT T1.A, T2.A, T3.A FROM PUBLIC.T2 LEFT OUTER JOIN ( PUBLIC.T3 LEFT OUTER JOIN ( PUBLIC.T1 ) ON T1.B = T3.A ) ON T2.B = T1.A", sql);
rs = stat.executeQuery("select distinct t1.a, t2.a, t3.a from t1 right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
assertEquals("SELECT DISTINCT T1.A, T2.A, T3.A FROM PUBLIC.T2 " +
"LEFT OUTER JOIN ( PUBLIC.T3 LEFT OUTER JOIN ( PUBLIC.T1 ) ON T1.B = T3.A ) " +
"ON T2.B = T1.A", sql);
rs = stat.executeQuery("select distinct t1.a, t2.a, t3.a from t1 " +
"right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
// expected: 1 1 1; null 2 null
assertTrue(rs.next());
assertEquals("1", rs.getString(1));
......@@ -360,11 +364,14 @@ public class TestOuterJoins extends TestBase {
stat.execute("insert into a values(1)");
stat.execute("insert into b values(1)");
stat.execute("insert into c values(1), (2)");
rs = stat.executeQuery("explain select a.x, b.x, c.x from a inner join b on a.x = b.x right outer join c on c.x = a.x");
rs = stat.executeQuery("explain select a.x, b.x, c.x from a " +
"inner join b on a.x = b.x right outer join c on c.x = a.x");
assertTrue(rs.next());
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.X, B.X, C.X FROM PUBLIC.C LEFT OUTER JOIN ( PUBLIC.A INNER JOIN PUBLIC.B ON A.X = B.X ) ON C.X = A.X", sql);
rs = stat.executeQuery("select a.x, b.x, c.x from a inner join b on a.x = b.x right outer join c on c.x = a.x");
assertEquals("SELECT A.X, B.X, C.X FROM PUBLIC.C LEFT OUTER JOIN " +
"( PUBLIC.A INNER JOIN PUBLIC.B ON A.X = B.X ) ON C.X = A.X", sql);
rs = stat.executeQuery("select a.x, b.x, c.x from a inner join b on a.x = b.x " +
"right outer join c on c.x = a.x");
// expected result: 1 1 1; null null 2
assertTrue(rs.next());
assertEquals("1", rs.getString(1));
......
......@@ -38,7 +38,8 @@ public class TestRandomSQL extends TestBase {
private void processException(String sql, SQLException e) {
if (e.getSQLState().equals("HY000")) {
TestBase.logError("new TestRandomSQL().init(test).testCase(" + seed + "); // FAIL: " + e.toString() + " sql: " + sql, e);
TestBase.logError("new TestRandomSQL().init(test).testCase(" + seed + "); " +
"// FAIL: " + e.toString() + " sql: " + sql, e);
if (exitOnError) {
System.exit(0);
}
......
......@@ -15,8 +15,10 @@ import org.h2.util.StatementBuilder;
* Represents a statement.
*/
class Command {
private static final int CONNECT = 0, RESET = 1, DISCONNECT = 2, CREATE_TABLE = 3, INSERT = 4, DROP_TABLE = 5, SELECT = 6,
DELETE = 7, UPDATE = 8, COMMIT = 9, ROLLBACK = 10, AUTOCOMMIT_ON = 11, AUTOCOMMIT_OFF = 12,
private static final int CONNECT = 0, RESET = 1, DISCONNECT = 2,
CREATE_TABLE = 3, INSERT = 4, DROP_TABLE = 5, SELECT = 6,
DELETE = 7, UPDATE = 8, COMMIT = 9, ROLLBACK = 10,
AUTOCOMMIT_ON = 11, AUTOCOMMIT_OFF = 12,
CREATE_INDEX = 13, DROP_INDEX = 14, END = 15;
/**
......
......@@ -122,9 +122,13 @@ public class TestMultiOrder extends TestMultiThread {
c.createStatement().execute("drop table customer if exists");
c.createStatement().execute("drop table orders if exists");
c.createStatement().execute("drop table orderLine if exists");
c.createStatement().execute("create table customer(id int primary key, name varchar, account decimal)");
c.createStatement().execute("create table orders(id int identity primary key, customer_id int, total decimal)");
c.createStatement().execute("create table orderLine(order_id int, line_id int, text varchar, amount decimal, primary key(order_id, line_id))");
c.createStatement().execute("create table customer(" +
"id int primary key, name varchar, account decimal)");
c.createStatement().execute("create table orders(" +
"id int identity primary key, customer_id int, total decimal)");
c.createStatement().execute("create table orderLine(" +
"order_id int, line_id int, text varchar, " +
"amount decimal, primary key(order_id, line_id))");
c.close();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论