提交 18bb2a2e authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 cf291f53
...@@ -109,6 +109,7 @@ via PayPal: ...@@ -109,6 +109,7 @@ via PayPal:
</li><li>lumber-mill.co.jp, Japan </li><li>lumber-mill.co.jp, Japan
</li><li>Oliver Computing LLC, USA </li><li>Oliver Computing LLC, USA
</li><li>Harpal Grover Consulting Inc., USA </li><li>Harpal Grover Consulting Inc., USA
</li><li>Elisabetta Berlini, Italy
</li></ul> </li></ul>
</div></td></tr></table></body></html> </div></td></tr></table></body></html>
...@@ -42,9 +42,9 @@ public class RuleFixed implements Rule { ...@@ -42,9 +42,9 @@ public class RuleFixed implements Rule {
case ANY_WORD: case ANY_WORD:
case ANY_UNTIL_END: { case ANY_UNTIL_END: {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
int len = r.nextInt(10); int len = r.nextBoolean() ? 1 : r.nextInt(5);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
buff.append((char) ('A' + r.nextInt('Z' - 'A'))); buff.append((char) ('A' + r.nextInt('C' - 'A')));
} }
return buff.toString(); return buff.toString();
} }
...@@ -53,7 +53,7 @@ public class RuleFixed implements Rule { ...@@ -53,7 +53,7 @@ public class RuleFixed implements Rule {
case CONCAT: case CONCAT:
return "||"; return "||";
case AZ_UNDERLINE: case AZ_UNDERLINE:
return "" + (char) ('A' + r.nextInt('Z' - 'A')); return "" + (char) ('A' + r.nextInt('C' - 'A'));
case AF: case AF:
return "" + (char) ('A' + r.nextInt('F' - 'A')); return "" + (char) ('A' + r.nextInt('F' - 'A'));
case DIGIT: case DIGIT:
......
...@@ -22,7 +22,7 @@ public class RuleOptional implements Rule { ...@@ -22,7 +22,7 @@ public class RuleOptional implements Rule {
} }
public String random(Bnf config, int level) { public String random(Bnf config, int level) {
if (level > 10 ? config.getRandom().nextInt(level) == 1 : config.getRandom().nextBoolean()) { if (level > 10 ? config.getRandom().nextInt(level) == 1 : config.getRandom().nextInt(4) == 1) {
return rule.random(config, level + 1); return rule.random(config, level + 1);
} else { } else {
return ""; return "";
......
...@@ -92,6 +92,10 @@ public class User extends RightOwner { ...@@ -92,6 +92,10 @@ public class User extends RightOwner {
} }
} }
if (!isRightGrantedRecursive(table, rightMask)) { if (!isRightGrantedRecursive(table, rightMask)) {
if (table.getTemporary() && !table.getGlobalTemporary()) {
// the owner has all rights on local temporary tables
return;
}
throw Message.getSQLException(ErrorCode.NOT_ENOUGH_RIGHTS_FOR_1, table.getSQL()); throw Message.getSQLException(ErrorCode.NOT_ENOUGH_RIGHTS_FOR_1, table.getSQL());
} }
} }
......
...@@ -33,7 +33,6 @@ import org.h2.util.CacheObject; ...@@ -33,7 +33,6 @@ import org.h2.util.CacheObject;
import org.h2.util.CacheWriter; import org.h2.util.CacheWriter;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.IntArray; import org.h2.util.IntArray;
import org.h2.util.IntHashMap;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.util.ObjectUtils; import org.h2.util.ObjectUtils;
...@@ -80,9 +79,6 @@ public class DiskFile implements CacheWriter { ...@@ -80,9 +79,6 @@ public class DiskFile implements CacheWriter {
private HashSet potentiallyFreePages; private HashSet potentiallyFreePages;
private int fileBlockCount; private int fileBlockCount;
private IntArray pageOwners; private IntArray pageOwners;
// the latest delete in a page
private IntArray pageDelete;
private Cache cache; private Cache cache;
private LogSystem log; private LogSystem log;
private DataPage rowBuff; private DataPage rowBuff;
...@@ -138,7 +134,6 @@ public class DiskFile implements CacheWriter { ...@@ -138,7 +134,6 @@ public class DiskFile implements CacheWriter {
used = new BitField(); used = new BitField();
deleted = new BitField(); deleted = new BitField();
pageOwners = new IntArray(); pageOwners = new IntArray();
pageDelete = new IntArray();
// init pageOwners // init pageOwners
setBlockCount(fileBlockCount); setBlockCount(fileBlockCount);
redoBuffer = new ObjectArray(); redoBuffer = new ObjectArray();
...@@ -150,7 +145,6 @@ public class DiskFile implements CacheWriter { ...@@ -150,7 +145,6 @@ public class DiskFile implements CacheWriter {
int pages = getPage(count); int pages = getPage(count);
while (pages >= pageOwners.size()) { while (pages >= pageOwners.size()) {
pageOwners.add(FREE_PAGE); pageOwners.add(FREE_PAGE);
pageDelete.add(0);
} }
} }
...@@ -609,10 +603,6 @@ public class DiskFile implements CacheWriter { ...@@ -609,10 +603,6 @@ public class DiskFile implements CacheWriter {
freePage(getPage(i)); freePage(getPage(i));
} }
} }
int start = getPage(pos), end = getPage(pos + blockCount);
for (int i = start; i <= end; i++) {
pageDelete.set(i, nextDeleteId);
}
} }
void reuseSpace() throws SQLException { void reuseSpace() throws SQLException {
...@@ -622,14 +612,13 @@ public class DiskFile implements CacheWriter { ...@@ -622,14 +612,13 @@ public class DiskFile implements CacheWriter {
int oldest = 0; int oldest = 0;
for (int i = 0; i < sessions.length; i++) { for (int i = 0; i < sessions.length; i++) {
int deleteId = sessions[i].getLastUncommittedDelete(); int deleteId = sessions[i].getLastUncommittedDelete();
if (oldest == 0 || deleteId < oldest) { if (oldest == 0 || (deleteId != 0 && deleteId < oldest)) {
oldest = deleteId; oldest = deleteId;
} }
} }
for (Iterator it = potentiallyFreePages.iterator(); it.hasNext();) { for (Iterator it = potentiallyFreePages.iterator(); it.hasNext();) {
int p = ((Integer) it.next()).intValue(); int p = ((Integer) it.next()).intValue();
int testingReallyCareful; if (oldest == 0) {
if (oldest == 0 /*|| oldest > pageDelete.get(p)*/) {
setPageOwner(p, FREE_PAGE); setPageOwner(p, FREE_PAGE);
it.remove(); it.remove();
} }
...@@ -698,7 +687,6 @@ public class DiskFile implements CacheWriter { ...@@ -698,7 +687,6 @@ public class DiskFile implements CacheWriter {
database.getStorage(storageId, this).addPage(page); database.getStorage(storageId, this).addPage(page);
if (SysProperties.REUSE_SPACE_QUICKLY) { if (SysProperties.REUSE_SPACE_QUICKLY) {
potentiallyFreePages.remove(ObjectUtils.getInteger(page)); potentiallyFreePages.remove(ObjectUtils.getInteger(page));
pageDelete.set(page, 0);
} }
} }
pageOwners.set(page, storageId); pageOwners.set(page, storageId);
......
...@@ -149,6 +149,7 @@ public class Storage { ...@@ -149,6 +149,7 @@ public class Storage {
} }
record.setDeleted(true); record.setDeleted(true);
int blockCount = record.getBlockCount(); int blockCount = record.getBlockCount();
file.uncommittedDelete(session);
free(pos, blockCount); free(pos, blockCount);
recordCount--; recordCount--;
file.removeRecord(session, pos, record, blockCount); file.removeRecord(session, pos, record, blockCount);
...@@ -266,7 +267,7 @@ public class Storage { ...@@ -266,7 +267,7 @@ public class Storage {
pageCheckIndex = (pageCheckIndex + 1) % pages.size(); pageCheckIndex = (pageCheckIndex + 1) % pages.size();
int page = pages.get(pageCheckIndex); int page = pages.get(pageCheckIndex);
if (file.isPageFree(page) && file.getPageOwner(page) == id) { if (file.isPageFree(page) && file.getPageOwner(page) == id) {
file.freePage(page); // file.freePage(page);
} }
} }
......
...@@ -156,6 +156,9 @@ java org.h2.test.TestAll timer ...@@ -156,6 +156,9 @@ java org.h2.test.TestAll timer
Test space re-use Test space re-use
REUSE_SPACE_AFTER=20 or so REUSE_SPACE_AFTER=20 or so
delete old ipowerb content (first filter, then remove)
link to new changelog and roadmap, remove pages from google groups
sourceDocs.html: move sourceDocs.html: move
Automate real power off tests Automate real power off tests
...@@ -163,33 +166,18 @@ timer test ...@@ -163,33 +166,18 @@ timer test
Can sometimes not delete log file? need test case Can sometimes not delete log file? need test case
link to new changelog and roadmap, remove pages from google groups
Adjust cache memory usage Adjust cache memory usage
// test with garbage at the end of the log file (must be consistently detected as such) // test with garbage at the end of the log file (must be consistently detected as such)
// TestRandomSQL is too random; most statements fails
// extend the random join test that compared the result against PostgreSQL // extend the random join test that compared the result against PostgreSQL
// long running test with the same database // long running test with the same database
// repeatable test with a very big database (making backups of the database files) // repeatable test with a very big database (making backups of the database files)
Test Recovery with MAX_LOG_FILE_SIZE=1; test with various log file sizes Test Recovery with MAX_LOG_FILE_SIZE=1; test with various log file sizes
History: History:
Empty space is re-used less agressively because this could cause database corruption in some cases.
CSV tool now support lineSeparator
Roadmap: Roadmap:
The user should be allowed to do everything with his own temp tables (and views).
CREATE USER IF NOT EXISTS READER PASSWORD 'READER';
<login as READER>
CREATE LOCAL TEMPORARY TABLE IF NOT EXISTS MY_TEST(ID INT);
INSERT INTO MY_TEST VALUES(1);
SELECT * FROM MY_TEST;
DROP TABLE MY_TEST;
*/ */
if (args.length > 0) { if (args.length > 0) {
...@@ -426,10 +414,7 @@ DROP TABLE MY_TEST; ...@@ -426,10 +414,7 @@ DROP TABLE MY_TEST;
new TestSQLInjection().runTest(this); new TestSQLInjection().runTest(this);
new TestSessionsLocks().runTest(this); new TestSessionsLocks().runTest(this);
new TestSequence().runTest(this); new TestSequence().runTest(this);
int todo2;
new TestSpaceReuse().runTest(this); new TestSpaceReuse().runTest(this);
new TestSpeed().runTest(this); new TestSpeed().runTest(this);
new TestTempTables().runTest(this); new TestTempTables().runTest(this);
new TestTransaction().runTest(this); new TestTransaction().runTest(this);
...@@ -469,8 +454,6 @@ DROP TABLE MY_TEST; ...@@ -469,8 +454,6 @@ DROP TABLE MY_TEST;
// synth // synth
new TestCrashAPI().runTest(this); new TestCrashAPI().runTest(this);
new TestRandomSQL().runTest(this); new TestRandomSQL().runTest(this);
int test3;
new TestKillRestart().runTest(this); new TestKillRestart().runTest(this);
new TestKillRestartMulti().runTest(this); new TestKillRestartMulti().runTest(this);
......
...@@ -211,6 +211,10 @@ public abstract class TestBase { ...@@ -211,6 +211,10 @@ public abstract class TestBase {
return mb; return mb;
} }
protected void error() throws Exception {
error("Unexpected success");
}
protected void error(String string) throws Exception { protected void error(String string) throws Exception {
println(string); println(string);
throw new Exception(string); throw new Exception(string);
......
...@@ -34,13 +34,13 @@ public class TestAutoRecompile extends TestBase { ...@@ -34,13 +34,13 @@ public class TestAutoRecompile extends TestBase {
stat.execute("ALTER TABLE TEST ADD COLUMN Z INT"); stat.execute("ALTER TABLE TEST ADD COLUMN Z INT");
try { try {
prep.execute(); prep.execute();
error("must fail"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
try { try {
prep.execute(); prep.execute();
error("must fail"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -226,7 +226,7 @@ public class TestCases extends TestBase { ...@@ -226,7 +226,7 @@ public class TestCases extends TestBase {
stat.execute("insert into test values(1);"); stat.execute("insert into test values(1);");
try { try {
stat.execute("alter table test add column name varchar not null;"); stat.execute("alter table test add column name varchar not null;");
error("shouldn't work"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -253,7 +253,7 @@ public class TestCases extends TestBase { ...@@ -253,7 +253,7 @@ public class TestCases extends TestBase {
stat.execute("insert into test values(1)"); stat.execute("insert into test values(1)");
try { try {
stat.execute("alter table test alter column id date"); stat.execute("alter table test alter column id date");
error("shouldn't work"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -353,7 +353,7 @@ public class TestCases extends TestBase { ...@@ -353,7 +353,7 @@ public class TestCases extends TestBase {
stat = conn.createStatement(); stat = conn.createStatement();
try { try {
stat.execute("select * from abc"); stat.execute("select * from abc");
error("abc should be deleted"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -560,7 +560,7 @@ public class TestCases extends TestBase { ...@@ -560,7 +560,7 @@ public class TestCases extends TestBase {
Statement stat2 = conn2.createStatement(); Statement stat2 = conn2.createStatement();
try { try {
stat2.execute("UPDATE TEST SET ID=2"); stat2.execute("UPDATE TEST SET ID=2");
error("must fail"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -23,7 +23,7 @@ public class TestExclusive extends TestBase { ...@@ -23,7 +23,7 @@ public class TestExclusive extends TestBase {
try { try {
Connection conn2 = getConnection("exclusive"); Connection conn2 = getConnection("exclusive");
conn2.close(); conn2.close();
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -146,7 +146,7 @@ public class TestFunctions extends TestBase { ...@@ -146,7 +146,7 @@ public class TestFunctions extends TestBase {
try { try {
rs = stat.executeQuery("CALL SELECT_F('ERROR')"); rs = stat.executeQuery("CALL SELECT_F('ERROR')");
error("expected error"); error();
} catch (SQLException e) { } catch (SQLException e) {
check("42001", e.getSQLState()); check("42001", e.getSQLState());
} }
......
...@@ -127,7 +127,7 @@ public class TestLinkedTable extends TestBase { ...@@ -127,7 +127,7 @@ public class TestLinkedTable extends TestBase {
stat2.executeUpdate("INSERT INTO TEST_LINK_DI VALUES(2, 'World')"); stat2.executeUpdate("INSERT INTO TEST_LINK_DI VALUES(2, 'World')");
try { try {
stat2.executeUpdate("UPDATE TEST_LINK_U SET ID=ID+1"); stat2.executeUpdate("UPDATE TEST_LINK_U SET ID=ID+1");
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -163,9 +163,9 @@ public class TestPowerOff extends TestBase { ...@@ -163,9 +163,9 @@ public class TestPowerOff extends TestBase {
try { try {
stat.execute("INSERT INTO TEST VALUES(2, 'Hello')"); stat.execute("INSERT INTO TEST VALUES(2, 'Hello')");
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
error("should not work!"); error();
} catch (SQLException e) { } catch (SQLException e) {
// expected checkNotGeneralException(e);
} }
boolean deleted = false; boolean deleted = false;
ArrayList files = FileLister.getDatabaseFiles(dir, dbName, false); ArrayList files = FileLister.getDatabaseFiles(dir, dbName, false);
...@@ -197,9 +197,9 @@ public class TestPowerOff extends TestBase { ...@@ -197,9 +197,9 @@ public class TestPowerOff extends TestBase {
stat.execute("INSERT INTO TEST VALUES(2, 'Hello')"); stat.execute("INSERT INTO TEST VALUES(2, 'Hello')");
stat.execute("INSERT INTO TEST VALUES(3, 'Hello')"); stat.execute("INSERT INTO TEST VALUES(3, 'Hello')");
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
error("should have failed!"); error();
} catch (Exception e) { } catch (SQLException e) {
// ok checkNotGeneralException(e);
} }
((JdbcConnection) conn).setPowerOffCount(0); ((JdbcConnection) conn).setPowerOffCount(0);
......
...@@ -20,6 +20,7 @@ public class TestRights extends TestBase { ...@@ -20,6 +20,7 @@ public class TestRights extends TestBase {
private Statement stat; private Statement stat;
public void test() throws Exception { public void test() throws Exception {
testDropTempTables();
// testLowerCaseUser(); // testLowerCaseUser();
testSchemaRenameUser(); testSchemaRenameUser();
testAccessRights(); testAccessRights();
...@@ -39,6 +40,28 @@ public class TestRights extends TestBase { ...@@ -39,6 +40,28 @@ public class TestRights extends TestBase {
// conn.close(); // conn.close();
// } // }
private void testDropTempTables() throws Exception {
deleteDb("rights");
Connection conn = getConnection("rights");
stat = conn.createStatement();
stat.execute("CREATE USER IF NOT EXISTS READER PASSWORD 'READER'");
stat.execute("CREATE TABLE TEST(ID INT)");
Connection conn2 = getConnection("rights", "READER", "READER");
Statement stat2 = conn2.createStatement();
try {
stat2.execute("SELECT * FROM TEST");
error();
} catch (SQLException e) {
checkNotGeneralException(e);
}
stat2.execute("CREATE LOCAL TEMPORARY TABLE IF NOT EXISTS MY_TEST(ID INT)");
stat2.execute("INSERT INTO MY_TEST VALUES(1)");
stat2.execute("SELECT * FROM MY_TEST");
stat2.execute("DROP TABLE MY_TEST");
conn2.close();
conn.close();
}
public void testSchemaRenameUser() throws Exception { public void testSchemaRenameUser() throws Exception {
if (config.memory) { if (config.memory) {
return; return;
...@@ -56,13 +79,13 @@ public class TestRights extends TestBase { ...@@ -56,13 +79,13 @@ public class TestRights extends TestBase {
stat.execute("select * from b.test"); stat.execute("select * from b.test");
try { try {
stat.execute("alter user test1 admin false"); stat.execute("alter user test1 admin false");
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
try { try {
stat.execute("drop user test1"); stat.execute("drop user test1");
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -145,19 +168,19 @@ public class TestRights extends TestBase { ...@@ -145,19 +168,19 @@ public class TestRights extends TestBase {
try { try {
conn = getConnection("rights", "Test", "abc"); conn = getConnection("rights", "Test", "abc");
error("unexpected success (mixed case user name)"); error("mixed case user name");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
try { try {
conn = getConnection("rights", "TEST", "abc"); conn = getConnection("rights", "TEST", "abc");
error("unexpected success (wrong password)"); error("wrong password");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
try { try {
conn = getConnection("rights", "TEST", null); conn = getConnection("rights", "TEST", null);
error("unexpected success (wrong password)"); error("wrong password");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -223,7 +246,7 @@ public class TestRights extends TestBase { ...@@ -223,7 +246,7 @@ public class TestRights extends TestBase {
public void executeError(String sql) throws Exception { public void executeError(String sql) throws Exception {
try { try {
stat.execute(sql); stat.execute(sql);
error("unexpected success (not admin)"); error("not admin");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -65,7 +65,7 @@ public class TestRunscript extends TestBase implements Trigger { ...@@ -65,7 +65,7 @@ public class TestRunscript extends TestBase implements Trigger {
if (password) { if (password) {
try { try {
stat2.execute(sql); stat2.execute(sql);
error("should fail"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -38,7 +38,7 @@ public class TestSQLInjection extends TestBase { ...@@ -38,7 +38,7 @@ public class TestSQLInjection extends TestBase {
try { try {
check(checkPasswordInsecure("123456")); check(checkPasswordInsecure("123456"));
error("Should fail now"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -36,7 +36,7 @@ public class TestSpaceReuse extends TestBase { ...@@ -36,7 +36,7 @@ public class TestSpaceReuse extends TestBase {
} }
} }
if (now > first) { if (now > first) {
this.error("first: " + first + " now: " + now); error("first: " + first + " now: " + now);
} }
} }
......
...@@ -41,7 +41,7 @@ public class TestTransaction extends TestBase { ...@@ -41,7 +41,7 @@ public class TestTransaction extends TestBase {
Statement s2 = c2.createStatement(); Statement s2 = c2.createStatement();
try { try {
s2.executeUpdate("insert into B values('two', 1)"); s2.executeUpdate("insert into B values('two', 1)");
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -89,7 +89,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -89,7 +89,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat.execute("DROP TRIGGER IF EXISTS INS_BEFORE"); stat.execute("DROP TRIGGER IF EXISTS INS_BEFORE");
try { try {
stat.execute("DROP TRIGGER INS_BEFORE"); stat.execute("DROP TRIGGER INS_BEFORE");
error("must not work"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -167,7 +167,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -167,7 +167,7 @@ public class TestBatchUpdates extends TestBase {
trace("updateCount length:" + updateCountLen); trace("updateCount length:" + updateCountLen);
if (updateCountLen != 3) { if (updateCountLen != 3) {
error("addBatch"); error("updateCount: " + updateCountLen);
} else { } else {
trace("addBatch add the SQL statements to Batch "); trace("addBatch add the SQL statements to Batch ");
} }
...@@ -204,7 +204,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -204,7 +204,7 @@ public class TestBatchUpdates extends TestBase {
updCountLength = updateCount.length; updCountLength = updateCount.length;
trace("updateCount Length:" + updCountLength); trace("updateCount Length:" + updCountLength);
if (updCountLength != 3) { if (updCountLength != 3) {
error("addBatch"); error("addBatch " + updCountLength);
} else { } else {
trace("addBatch add the SQL statements to Batch "); trace("addBatch add the SQL statements to Batch ");
} }
...@@ -243,7 +243,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -243,7 +243,7 @@ public class TestBatchUpdates extends TestBase {
if (updCountLength == 0) { if (updCountLength == 0) {
trace("clearBatch Method clears the current Batch "); trace("clearBatch Method clears the current Batch ");
} else { } else {
error("clearBatch"); error("clearBatch " + updCountLength);
} }
} }
......
...@@ -63,7 +63,7 @@ public class TestCancel extends TestBase { ...@@ -63,7 +63,7 @@ public class TestCancel extends TestBase {
check(1000, rs.getInt(1)); check(1000, rs.getInt(1));
try { try {
stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"); stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)");
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
check(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode()); check(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode());
} }
...@@ -80,7 +80,7 @@ public class TestCancel extends TestBase { ...@@ -80,7 +80,7 @@ public class TestCancel extends TestBase {
stat.execute("SET QUERY_TIMEOUT 10"); stat.execute("SET QUERY_TIMEOUT 10");
try { try {
stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"); stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)");
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
check(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode()); check(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode());
} }
...@@ -96,7 +96,7 @@ public class TestCancel extends TestBase { ...@@ -96,7 +96,7 @@ public class TestCancel extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
try { try {
stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"); stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)");
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
check(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode()); check(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode());
} }
......
...@@ -58,18 +58,18 @@ public class TestPreparedStatement extends TestBase { ...@@ -58,18 +58,18 @@ public class TestPreparedStatement extends TestBase {
testParameterMetaData(conn); testParameterMetaData(conn);
conn.close(); conn.close();
} }
private void testExecuteErrorTwice(Connection conn) throws Exception { private void testExecuteErrorTwice(Connection conn) throws Exception {
PreparedStatement prep = conn.prepareStatement("CREATE TABLE BAD AS SELECT A"); PreparedStatement prep = conn.prepareStatement("CREATE TABLE BAD AS SELECT A");
try { try {
prep.execute(); prep.execute();
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
try { try {
prep.execute(); prep.execute();
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -174,9 +174,9 @@ public class TestPreparedStatement extends TestBase { ...@@ -174,9 +174,9 @@ public class TestPreparedStatement extends TestBase {
"SELECT * FROM (SELECT ? FROM DUAL)"); "SELECT * FROM (SELECT ? FROM DUAL)");
prep.setInt(1, 1); prep.setInt(1, 1);
prep.execute(); prep.execute();
error("Must fail"); error();
} catch (SQLException e) { } catch (SQLException e) {
// expected checkNotGeneralException(e);
} }
PreparedStatement prep = conn.prepareStatement("SELECT -?"); PreparedStatement prep = conn.prepareStatement("SELECT -?");
prep.setInt(1, 1); prep.setInt(1, 1);
...@@ -342,22 +342,22 @@ public class TestPreparedStatement extends TestBase { ...@@ -342,22 +342,22 @@ public class TestPreparedStatement extends TestBase {
check(pm.isSigned(1), true); check(pm.isSigned(1), true);
try { try {
pm.getPrecision(0); pm.getPrecision(0);
error("should fail"); error();
} catch (SQLException e) { } catch (SQLException e) {
// ok checkNotGeneralException(e);
} }
try { try {
pm.getPrecision(4); pm.getPrecision(4);
error("should fail"); error();
} catch (SQLException e) { } catch (SQLException e) {
// ok checkNotGeneralException(e);
} }
prep.close(); prep.close();
try { try {
pm.getPrecision(1); pm.getPrecision(1);
error("should fail"); error();
} catch (SQLException e) { } catch (SQLException e) {
// ok checkNotGeneralException(e);
} }
} }
...@@ -439,10 +439,9 @@ public class TestPreparedStatement extends TestBase { ...@@ -439,10 +439,9 @@ public class TestPreparedStatement extends TestBase {
checkFalse(rs.next()); checkFalse(rs.next());
try { try {
prep = conn.prepareStatement("select ? from dual union select ? from dual"); prep = conn.prepareStatement("select ? from dual union select ? from dual");
error("expected error"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
// ok
} }
prep = conn.prepareStatement("select cast(? as varchar) from dual union select ? from dual"); prep = conn.prepareStatement("select cast(? as varchar) from dual union select ? from dual");
check(prep.getParameterMetaData().getParameterCount(), 2); check(prep.getParameterMetaData().getParameterCount(), 2);
......
...@@ -56,7 +56,7 @@ public class TestStatement extends TestBase { ...@@ -56,7 +56,7 @@ public class TestStatement extends TestBase {
int id1 = savepoint1.getSavepointId(); int id1 = savepoint1.getSavepointId();
try { try {
savepoint1.getSavepointName(); savepoint1.getSavepointName();
error("exception expected"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -68,7 +68,7 @@ public class TestStatement extends TestBase { ...@@ -68,7 +68,7 @@ public class TestStatement extends TestBase {
conn.releaseSavepoint(savepoint2a); conn.releaseSavepoint(savepoint2a);
try { try {
savepoint2a.getSavepointId(); savepoint2a.getSavepointId();
error("exception expected"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -80,7 +80,7 @@ public class TestStatement extends TestBase { ...@@ -80,7 +80,7 @@ public class TestStatement extends TestBase {
check(savepointTest.getSavepointName(), "Joe's"); check(savepointTest.getSavepointName(), "Joe's");
try { try {
savepointTest.getSavepointId(); savepointTest.getSavepointId();
error("exception expected"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -93,7 +93,7 @@ public class TestStatement extends TestBase { ...@@ -93,7 +93,7 @@ public class TestStatement extends TestBase {
checkFalse(rs.next()); checkFalse(rs.next());
try { try {
conn.rollback(savepoint2); conn.rollback(savepoint2);
error("exception expected"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -53,7 +53,7 @@ public class TestUpdatableResultSet extends TestBase { ...@@ -53,7 +53,7 @@ public class TestUpdatableResultSet extends TestBase {
try { try {
rs.insertRow(); rs.insertRow();
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -80,7 +80,7 @@ public class TestZloty extends TestBase { ...@@ -80,7 +80,7 @@ public class TestZloty extends TestBase {
try { try {
prep.setBigDecimal(2, new ZlotyBigDecimal("11.0")); prep.setBigDecimal(2, new ZlotyBigDecimal("11.0"));
prep.execute(); prep.execute();
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -96,7 +96,7 @@ public class TestZloty extends TestBase { ...@@ -96,7 +96,7 @@ public class TestZloty extends TestBase {
}; };
prep.setBigDecimal(2, value); prep.setBigDecimal(2, value);
prep.execute(); prep.execute();
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -38,7 +38,7 @@ public class TestMvcc1 extends TestBase { ...@@ -38,7 +38,7 @@ public class TestMvcc1 extends TestBase {
check("FALSE", rs.getString("VALUE")); check("FALSE", rs.getString("VALUE"));
try { try {
stat.execute("SET MVCC TRUE"); stat.execute("SET MVCC TRUE");
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
check(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1, e.getErrorCode()); check(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1, e.getErrorCode());
} }
...@@ -80,7 +80,7 @@ public class TestMvcc1 extends TestBase { ...@@ -80,7 +80,7 @@ public class TestMvcc1 extends TestBase {
s1.execute("insert into test values(1)"); s1.execute("insert into test values(1)");
try { try {
s2.execute("drop table test"); s2.execute("drop table test");
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
// lock timeout expected // lock timeout expected
checkNotGeneralException(e); checkNotGeneralException(e);
...@@ -107,7 +107,7 @@ public class TestMvcc1 extends TestBase { ...@@ -107,7 +107,7 @@ public class TestMvcc1 extends TestBase {
s1.execute("insert into a(code) values('one')"); s1.execute("insert into a(code) values('one')");
try { try {
s2.execute("insert into b values('un B', 1)"); s2.execute("insert into b values('un B', 1)");
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -123,7 +123,7 @@ public class TestMvcc1 extends TestBase { ...@@ -123,7 +123,7 @@ public class TestMvcc1 extends TestBase {
s2.execute("select * from test for update"); s2.execute("select * from test for update");
try { try {
s1.execute("insert into test values(2, 'x')"); s1.execute("insert into test values(2, 'x')");
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
// lock timeout expected // lock timeout expected
checkNotGeneralException(e); checkNotGeneralException(e);
...@@ -346,7 +346,7 @@ public class TestMvcc1 extends TestBase { ...@@ -346,7 +346,7 @@ public class TestMvcc1 extends TestBase {
c1.commit(); c1.commit();
try { try {
s1.execute("update test set id=2 where id=1"); s1.execute("update test set id=2 where id=1");
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -40,9 +40,9 @@ public class TestPgServer extends TestBase { ...@@ -40,9 +40,9 @@ public class TestPgServer extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
try { try {
stat.execute("select ***"); stat.execute("select ***");
error("expected failure"); error();
} catch (SQLException e) { } catch (SQLException e) {
// expected checkNotGeneralException(e);
} }
conn.close(); conn.close();
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5535/test", "sa", "sa"); conn = DriverManager.getConnection("jdbc:postgresql://localhost:5535/test", "sa", "sa");
......
...@@ -29,6 +29,7 @@ public class TestRandomSQL extends TestBase { ...@@ -29,6 +29,7 @@ public class TestRandomSQL extends TestBase {
private int seed; private int seed;
private boolean exitOnError = true; private boolean exitOnError = true;
private Bnf bnf; private Bnf bnf;
private int success, total;
private void processException(String sql, SQLException e) { private void processException(String sql, SQLException e) {
if (e.getSQLState().equals("HY000")) { if (e.getSQLState().equals("HY000")) {
...@@ -100,7 +101,7 @@ public class TestRandomSQL extends TestBase { ...@@ -100,7 +101,7 @@ public class TestRandomSQL extends TestBase {
if (topic.equals("select")) { if (topic.equals("select")) {
weight = 10; weight = 10;
} else if (topic.equals("createtable")) { } else if (topic.equals("createtable")) {
weight = 5; weight = 20;
} else if (topic.equals("insert")) { } else if (topic.equals("insert")) {
weight = 5; weight = 5;
} else if (topic.startsWith("update")) { } else if (topic.startsWith("update")) {
...@@ -130,11 +131,10 @@ public class TestRandomSQL extends TestBase { ...@@ -130,11 +131,10 @@ public class TestRandomSQL extends TestBase {
conn = connect(); conn = connect();
} }
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
for (int i = 0; i < statements.size(); i++) { for (int i = 0; i < statements.size(); i++) {
int sid = config.getRandom().nextInt(statements.size()); int sid = config.getRandom().nextInt(statements.size());
RuleHead r = (RuleHead) statements.get(sid); RuleHead r = (RuleHead) statements.get(sid);
String rand = r.getRule().random(config, 0); String rand = r.getRule().random(config, 0).trim();
if (rand.length() > 0) { if (rand.length() > 0) {
try { try {
Thread.yield(); Thread.yield();
...@@ -144,7 +144,12 @@ public class TestRandomSQL extends TestBase { ...@@ -144,7 +144,12 @@ public class TestRandomSQL extends TestBase {
if (showSQL) { if (showSQL) {
System.out.println(i + " " + rand); System.out.println(i + " " + rand);
} }
total++;
if (total % 100 == 0) {
printTime("total: " + total + " success: " + (100 * success / total) + "%");
}
stat.execute(rand); stat.execute(rand);
success++;
} }
} catch (SQLException e) { } catch (SQLException e) {
processException(rand, e); processException(rand, e);
......
...@@ -165,7 +165,7 @@ public class TestFileSystem extends TestBase { ...@@ -165,7 +165,7 @@ public class TestFileSystem extends TestBase {
FileObject f = fs.openFileObject(s, "rw"); FileObject f = fs.openFileObject(s, "rw");
try { try {
f.readFully(new byte[1], 0, 1); f.readFully(new byte[1], 0, 1);
error("Unexpected success"); error();
} catch (EOFException e) { } catch (EOFException e) {
// expected // expected
} }
......
...@@ -69,13 +69,13 @@ public class TestOverflow extends TestBase { ...@@ -69,13 +69,13 @@ public class TestOverflow extends TestBase {
void onSuccess() throws Exception { void onSuccess() throws Exception {
if (!successExpected && SysProperties.OVERFLOW_EXCEPTIONS) { if (!successExpected && SysProperties.OVERFLOW_EXCEPTIONS) {
error("unexpected success"); error();
} }
} }
void onError() throws Exception { void onError() throws Exception {
if (successExpected) { if (successExpected) {
error("unexpected error"); error();
} }
} }
......
...@@ -170,7 +170,7 @@ public class TestServlet extends TestBase { ...@@ -170,7 +170,7 @@ public class TestServlet extends TestBase {
try { try {
stat1.execute("SELECT * FROM T"); stat1.execute("SELECT * FROM T");
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -182,7 +182,7 @@ public class TestServlet extends TestBase { ...@@ -182,7 +182,7 @@ public class TestServlet extends TestBase {
// listener must be stopped // listener must be stopped
try { try {
conn2 = DriverManager.getConnection("jdbc:h2:tcp://localhost:8888/" + baseDir + "/servlet", getUser(), getPassword()); conn2 = DriverManager.getConnection("jdbc:h2:tcp://localhost:8888/" + baseDir + "/servlet", getUser(), getPassword());
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
...@@ -190,7 +190,7 @@ public class TestServlet extends TestBase { ...@@ -190,7 +190,7 @@ public class TestServlet extends TestBase {
// connection must be closed // connection must be closed
try { try {
stat1.execute("SELECT * FROM DUAL"); stat1.execute("SELECT * FROM DUAL");
error("Unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
...@@ -35,13 +35,13 @@ public class TestStringUtils extends TestBase { ...@@ -35,13 +35,13 @@ public class TestStringUtils extends TestBase {
check(new byte[] { (byte) 0xfa, (byte) 0xce }, ByteUtils.convertStringToBytes("FaCe")); check(new byte[] { (byte) 0xfa, (byte) 0xce }, ByteUtils.convertStringToBytes("FaCe"));
try { try {
ByteUtils.convertStringToBytes("120"); ByteUtils.convertStringToBytes("120");
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
try { try {
ByteUtils.convertStringToBytes("fast"); ByteUtils.convertStringToBytes("fast");
error("unexpected success"); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); checkNotGeneralException(e);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论