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

--no commit message

--no commit message
上级 8bd9aeaa
#Sat Dec 01 09:41:20 CET 2007
#Mon Dec 10 07:25:40 CET 2007
javac=javac
benchmark.drivers.dir=C\:/data/java
path.servlet.jar=C\:/data/classpath/servlet-api.jar
......
......@@ -14,6 +14,7 @@ import org.h2.constraint.ConstraintCheck;
import org.h2.constraint.ConstraintReferential;
import org.h2.constraint.ConstraintUnique;
import org.h2.engine.Database;
import org.h2.engine.DbObject;
import org.h2.engine.Right;
import org.h2.engine.Session;
import org.h2.expression.Expression;
......@@ -52,9 +53,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
super(session, schema);
}
private String generateConstraintName(int id) throws SQLException {
private String generateConstraintName(DbObject obj, int id) throws SQLException {
if (constraintName == null) {
constraintName = getSchema().getUniqueConstraintName();
constraintName = getSchema().getUniqueConstraintName(obj);
}
return constraintName;
}
......@@ -72,7 +73,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
switch (type) {
case CHECK: {
int id = getObjectId(true, true);
String name = generateConstraintName(id);
String name = generateConstraintName(table, id);
ConstraintCheck check = new ConstraintCheck(getSchema(), id, name, table);
TableFilter filter = new TableFilter(session, table, null, false, null);
checkExpression.mapColumns(filter, 0);
......@@ -99,7 +100,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
}
int id = getObjectId(true, true);
String name = generateConstraintName(id);
String name = generateConstraintName(table, id);
ConstraintUnique unique = new ConstraintUnique(getSchema(), id, name, table);
unique.setColumns(columns);
unique.setIndex(index, isOwner);
......@@ -146,7 +147,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
}
int id = getObjectId(true, true);
String name = generateConstraintName(id);
String name = generateConstraintName(table, id);
ConstraintReferential ref = new ConstraintReferential(getSchema(), id, name, table);
ref.setColumns(columns);
ref.setIndex(index, isOwner);
......@@ -186,7 +187,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
indexType.setBelongsToConstraint(true);
String prefix = constraintName == null ? "CONSTRAINT" : constraintName;
String indexName = getSchema().getUniqueIndexName(prefix + "_INDEX_");
String indexName = getSchema().getUniqueIndexName(t, prefix + "_INDEX_");
IndexColumn[] idxCols = IndexColumn.wrap(cols);
return t.addIndex(session, indexName, indexId, idxCols, indexType, Index.EMPTY_HEAD, null);
}
......
......@@ -70,7 +70,7 @@ public class CreateIndex extends SchemaCommand {
}
int id = getObjectId(true, false);
if (indexName == null) {
indexName = getSchema().getUniqueIndexName("INDEX_");
indexName = getSchema().getUniqueIndexName(table, "INDEX_");
}
if (getSchema().findIndex(indexName) != null) {
if (ifNotExists) {
......
......@@ -56,7 +56,8 @@ import org.h2.constant.SysProperties;
* - Make sure the build files are removed
* - ant zip
* - Windows installer (nsis)
* - Test
* - Test Console
* - Test all languages
* - Test the windows service
* - Scan for viruses
* - ant mavenDeployCentral
......
......@@ -33,7 +33,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
// final static int MAX_PAGE_SIZE = 256;
private Storage storage;
private BtreePage root;
private BtreePage rootPage;
private TableData tableData;
private BtreeHead head;
private boolean needRebuild;
......@@ -57,7 +57,8 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
head = (BtreeHead) rec;
}
if (head != null && head.getConsistent()) {
setRoot((BtreePage) storage.getRecord(session, head.getRootPosition()));
int testing;
// setRoot((BtreePage) storage.getRecord(session, head.getRootPosition()));
needRebuild = false;
rowCount = table.getRowCount(session);
} else {
......@@ -67,12 +68,20 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
}
}
private void setRoot(BtreePage newRoot) {
if (root != null) {
root.setRoot(false);
private BtreePage getRoot(Session session) throws SQLException {
if (rootPage == null) {
setRoot((BtreePage) storage.getRecord(session, head.getRootPosition()));
}
return rootPage;
}
private BtreePage setRoot(BtreePage newRoot) {
if (rootPage != null) {
rootPage.setRoot(false);
}
newRoot.setRoot(true);
root = newRoot;
rootPage = newRoot;
return rootPage;
}
public int getHeadPos() {
......@@ -151,12 +160,13 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
Value v = r.getValue(idx);
row.setValue(idx, v);
}
BtreePage root = getRoot(session);
int splitPoint = root.add(row, session);
if (splitPoint != 0) {
SearchRow pivot = root.getData(splitPoint);
BtreePage page1 = root;
BtreePage page2 = root.split(session, splitPoint);
setRoot(new BtreeNode(this, page1, pivot, page2));
root = setRoot(new BtreeNode(this, page1, pivot, page2));
addPage(session, root);
deletePage(session, head);
head.setRootPosition(root.getPos());
......@@ -171,6 +181,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
// TODO performance: maybe improve truncate performance in this case
truncate(session);
} else {
BtreePage root = getRoot(session);
root.remove(session, row, 0);
rowCount--;
}
......@@ -180,6 +191,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
if (SysProperties.CHECK && storage == null) {
throw Message.getSQLException(ErrorCode.OBJECT_CLOSED);
}
BtreePage root = getRoot(session);
if (first == null) {
BtreeCursor cursor = new BtreeCursor(session, this, last);
root.first(cursor);
......@@ -257,7 +269,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
storage.truncate(session);
head = new BtreeHead();
addPage(session, head);
setRoot(new BtreeLeaf(this, new ObjectArray()));
BtreePage root = setRoot(new BtreeLeaf(this, new ObjectArray()));
addPage(session, root);
deletePage(session, head);
head.setRootPosition(root.getPos());
......@@ -301,7 +313,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
}
return null;
} else {
return root.getLast(session);
return getRoot(session).getLast(session);
}
}
......
......@@ -839,7 +839,8 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
* Sets the value of a parameter as an input stream.
*
* @param parameterIndex the parameter index (1, 2, ...)
* @param x the value * @throws SQLException if this object is closed
* @param x the value
* @throws SQLException if this object is closed
*/
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
setBinaryStream(parameterIndex, x, -1);
......
......@@ -24,6 +24,14 @@ import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
//#ifdef JDK16
/*
import java.sql.NClob;
import java.sql.RowId;
import java.sql.SQLXML;
*/
//#endif
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
......@@ -2668,7 +2676,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/**
* Detects if the row was updated (by somebody else or the caller).
*
* @return false because this driver does detect this
* @return false because this driver does not detect this
*/
public boolean rowUpdated() throws SQLException {
try {
......@@ -2682,7 +2690,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/**
* Detects if the row was inserted.
*
* @return false because this driver does detect this
* @return false because this driver does not detect this
*/
public boolean rowInserted() throws SQLException {
try {
......@@ -2696,7 +2704,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/**
* Detects if the row was deleted (by somebody else or the caller).
*
* @return false because this driver does detect this
* @return false because this driver does not detect this
*/
public boolean rowDeleted() throws SQLException {
try {
......@@ -2928,10 +2936,6 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
return super.getTraceId();
}
JdbcConnection getConnection() {
return conn;
}
private boolean nextRow() throws SQLException {
boolean next = result.next();
if (!next && !scrollable) {
......
......@@ -6,6 +6,7 @@ package org.h2.schema;
import java.sql.SQLException;
import java.util.HashMap;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.constraint.Constraint;
......@@ -185,7 +186,15 @@ public class Schema extends DbObjectBase {
return (Constant) constants.get(constantName);
}
private String getUniqueName(HashMap map, String prefix) {
private String getUniqueName(DbObject obj, HashMap map, String prefix) {
String hash = Integer.toHexString(obj.getName().hashCode()).toUpperCase();
for (int i = 1; i < hash.length(); i++) {
String name = prefix + hash.substring(0, i);
if (map.get(name) == null) {
return name;
}
}
prefix = prefix + hash + "_";
for (int i = 0;; i++) {
String name = prefix + i;
if (map.get(name) == null) {
......@@ -194,12 +203,12 @@ public class Schema extends DbObjectBase {
}
}
public String getUniqueConstraintName() {
return getUniqueName(constraints, "CONSTRAINT_");
public String getUniqueConstraintName(DbObject obj) {
return getUniqueName(obj, constraints, "CONSTRAINT_");
}
public String getUniqueIndexName(String prefix) {
return getUniqueName(indexes, prefix);
public String getUniqueIndexName(DbObject obj, String prefix) {
return getUniqueName(obj, indexes, prefix);
}
public Table getTableOrView(Session session, String name) throws SQLException {
......
......@@ -70,7 +70,7 @@ public class WebServer implements Service {
"Generic OneDollarDB|in.co.daffodil.db.jdbc.DaffodilDBDriver|jdbc:daffodilDB_embedded:school;path=C:/temp;create=true|sa",
"Generic DB2|COM.ibm.db2.jdbc.net.DB2Driver|jdbc:db2://<host>/<db>|" ,
"Generic Oracle|oracle.jdbc.driver.OracleDriver|jdbc:oracle:thin:@<host>:1521:<instance>|scott" ,
"Generic MS SQL Server|com.microsoft.jdbc.sqlserver.SQLServerDriver|jdbc:Microsoft:sqlserver://localhost:1433;DatabaseName=sqlexpress|sa",
"Generic MS SQL Server 2000|com.microsoft.jdbc.sqlserver.SQLServerDriver|jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sqlexpress|sa",
"Generic MS SQL Server 2005|com.microsoft.sqlserver.jdbc.SQLServerDriver|jdbc:sqlserver://localhost;DatabaseName=test|sa",
"Generic PostgreSQL|org.postgresql.Driver|jdbc:postgresql:<db>|" ,
"Generic MySQL|com.mysql.jdbc.Driver|jdbc:mysql://<host>:<port>/<db>|" ,
......
......@@ -1429,7 +1429,8 @@ class WebThread extends Thread implements DatabaseEventListener {
stat.close();
}
return buff.toString();
} catch (Exception e) {
} catch (Throwable e) {
// throwable: including OutOfMemoryError and so on
return getStackTrace(id, e);
} finally {
session.executingStatement = null;
......
<!-- can not use doctype -->
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html>
......@@ -13,13 +13,14 @@ Initial Developer: H2 Group
var agent=navigator.userAgent.toLowerCase();
var is_opera = agent.indexOf("opera") >= 0;
var autoComplete = 1;
var autoComplete = 1; // 0: off, 1: normal, 2: full
var selectedRow = -1;
var lastList = '';
var lastQuery = null;
var columnsByTable = new Object();
var tableAliases = new Object();
var showAutoCompleteWait = 0;
var autoCompleteManual = false;
var req;
function refreshTables() {
......@@ -71,7 +72,7 @@ function splitSQL(s) {
function help() {
var input = document.h2query.sql;
setSelection(input);
var pos = input.selectionStart;
var pos = input.selectionStart;
if(pos > 0) {
var s = input.value.substring(0, pos).toUpperCase();
var e = pos-1;
......@@ -108,7 +109,7 @@ function setSelection(element) {
} catch (e) {
element.selectionEnd = element.selectionStart = 0;
}
}
}
}
function set(field, combo) {
......@@ -172,13 +173,6 @@ function insertText(s, isTable) {
field.focus();
}
function keyUp() {
if(autoComplete != 0) {
showAutoComplete();
}
return true;
}
function showAutoComplete() {
if(showAutoCompleteWait==0) {
showAutoCompleteWait=5;
......@@ -206,24 +200,32 @@ function keyDown(event) {
return false;
}
if (key == 13 && event.ctrlKey) {
// ctrl + return
document.h2query.submit();
return false;
} else if(key == 32 && event.ctrlKey) {
showAutoComplete();
// ctrl + space
autoCompleteManual = true;
lastQuery = null;
lastList = '';
showAutoCompleteNow();
return false;
} else if(key == 190 && autoComplete==0) {
// dot
help();
return true;
}
var table = getAutoCompleteTable();
if(table.rows.length > 0) {
if(key == 27) {
// escape
while(table.rows.length > 0) {
table.deleteRow(0);
}
showOutput('');
return false;
} else if((key == 13 && !event.shiftKey) || (key==9 && !event.shiftKey)) {
// enter or tab
if(table.rows.length > selectedRow) {
var row = table.rows[selectedRow];
if(row.cells.length>1) {
......@@ -231,31 +233,44 @@ function keyDown(event) {
}
if(autoComplete == 0) {
setAutoComplete(0);
}
}
return false;
}
} else if(key == 38 && !event.shiftKey) {
if(table.rows.length > selectedRow) {
// up
if(table.rows.length > selectedRow) {
selectedRow = selectedRow <= 0 ? table.rows.length-1 : selectedRow-1;
highlightRow(selectedRow);
}
return false;
return false;
} else if(key == 40 && !event.shiftKey) {
if(table.rows.length > selectedRow) {
// down
if(table.rows.length > selectedRow) {
selectedRow = selectedRow >= table.rows.length-1 ? 0 : selectedRow+1;
highlightRow(selectedRow);
}
return false;
return false;
}
}
return true;
// alert('key:' + key);
// bs:8 ret:13 lt:37 up:38 rt:39 dn:40 tab:9
// pgup:33 pgdn:34 home:36 end:35 del:46 shift:16
// ctrl,alt gr:17 alt:18 caps:20 5(num):12 ins:45
// pgup:33 pgdn:34 home:36 end:35 del:46 shift:16
// ctrl, alt gr:17 alt:18 caps:20 5(num):12 ins:45
// pause:19 f1..13:112..123 win-start:91 win-ctx:93 esc:27
}
function keyUp(event) {
if(autoComplete != 0) {
var key=event == null ? 0 : (event.keyCode? event.keyCode : event.charCode);
if(key != 37 && key != 38 && key != 39 && key != 40) {
// left, right, up, down: don't show autocomplete
showAutoComplete();
}
}
return true;
}
function setAutoComplete(value) {
autoComplete = value;
if(value != 1) {
......@@ -325,7 +340,7 @@ function showList(s) {
for(var i=0; list != null && i<list.length; i++) {
var kv = list[i].split('#');
var type = kv[0];
if(type > 0 && autoComplete != 2) {
if(type > 0 && autoComplete != 2 && !autoCompleteManual) {
continue;
}
var row = doc.createElement("tr");
......@@ -354,7 +369,7 @@ function showList(s) {
cell = doc.createElement("td");
cell.style.display='none';
text = doc.createTextNode(value);
cell.appendChild(text);
cell.appendChild(text);
row.appendChild(cell);
}
if(count > 0) {
......@@ -365,6 +380,7 @@ function showList(s) {
}
// scroll to the top left
top.h2result.scrollTo(0, 0);
autoCompleteManual = false;
}
function retrieveList(s) {
......@@ -436,7 +452,7 @@ function processAsyncResponse() {
<div style="display:none">
<iframe id="h2iframeTransport" src="" onload="showList(this.contentWindow.document.body.innerHTML);"></iframe>
</div>
<textarea id="sql" name="sql" cols="80" rows="5" onkeydown="return keyDown(event)" onkeyup="return keyUp()"
<textarea id="sql" name="sql" cols="80" rows="5" onkeydown="return keyDown(event)" onkeyup="return keyUp(event)"
onfocus="keyUp()" onchange="return keyUp()">${query}</textarea>
</form>
</body>
......
......@@ -35,8 +35,8 @@ import org.h2.util.MathUtils;
import org.h2.util.ObjectArray;
/**
* This class represents a file that is usually written to disk.
* The two main files are .data.db and .index.db.
* This class represents a file that is usually written to disk.
* The two main files are .data.db and .index.db.
* For each such file, a number of {@link Storage} objects exists.
* The disk file is responsible for caching; each object contains a {@link Cache} object.
* Changes in the file are logged in a {@link LogSystem} object.
......@@ -277,7 +277,7 @@ public class DiskFile implements CacheWriter {
}
}
}
public void init() throws SQLException {
synchronized (database) {
......@@ -351,6 +351,33 @@ public class DiskFile implements CacheWriter {
}
}
public void flushNew() throws SQLException {
int todoTest;
synchronized (database) {
database.checkPowerOff();
ObjectArray list = cache.getAllChanged();
CacheObject.sort(list);
int deletePos = deleted.nextSetBit(0);
int writeIndex = 0;
Record writeRecord = null;
while (true) {
if (writeRecord == null && writeIndex < list.size()) {
writeRecord = (Record) list.get(writeIndex++);
}
if (writeRecord != null && (deletePos < 0 || writeRecord.getPos() < deletePos)) {
writeBack(writeRecord);
writeRecord = null;
} else if (deletePos < fileBlockCount && deletePos >= 0) {
writeDirectDeleted(deletePos, 1);
deleted.clear(deletePos);
deletePos = deleted.nextSetBit(deletePos);
} else {
break;
}
}
}
}
public void close() throws SQLException {
synchronized (database) {
SQLException closeException = null;
......@@ -888,8 +915,6 @@ public class DiskFile implements CacheWriter {
if (last != null && last.data != null) {
writeRedoLog(last);
}
redoBuffer.clear();
redoBufferSize = 0;
}
......@@ -917,4 +942,8 @@ public class DiskFile implements CacheWriter {
}
}
public String toString() {
return getClass().getName() + ":" + fileName;
}
}
......@@ -36,7 +36,7 @@ public class FileSystemDisk extends FileSystem {
return INSTANCE;
}
private FileSystemDisk() {
protected FileSystemDisk() {
}
public long length(String fileName) {
......
......@@ -143,7 +143,7 @@ public class TableData extends Table implements RecordReader {
public Index addIndex(Session session, String indexName, int indexId, IndexColumn[] cols, IndexType indexType,
int headPos, String indexComment) throws SQLException {
if (indexType.isPrimaryKey()) {
indexName = getSchema().getUniqueIndexName(Constants.PRIMARY_KEY_PREFIX);
indexName = getSchema().getUniqueIndexName(this, Constants.PRIMARY_KEY_PREFIX);
for (int i = 0; i < cols.length; i++) {
Column column = cols[i].column;
if (column.getNullable()) {
......
......@@ -152,24 +152,17 @@ java org.h2.test.TestAll timer
/*
History:
The performance has been improved for ResultSet methods with column name.
The method Trigger.init has been changed: the parameters 'before' and 'type', have been added to the init method.
The Ukrainian translation was not working in the last release. Fixed.
Creating many tables (many hundreds) was slow. Fixed.
Opening a database with many indexes (thousands) was slow. Fixed.
C:\temp\test\db
No more
@author
autocomplete only just after meaningful key (ctrl+space, space, bs, ...)
write more tests for the command line tools
C:\temp\test\db
Known Problems:
Web site:
link to history page, bug page
Add a link to the google code bug page
implement & test: checkpoint commits running transactions
test DbStarter
----
......@@ -203,8 +196,6 @@ shrink newsletter list (migrate to google groups)
don't create @~ of not translated
test performance and document fulltext search
clustered tables: test, document
extend tests that simulate power off
......@@ -297,6 +288,7 @@ Features of H2
if (args.length > 0) {
if ("crash".equals(args[0])) {
test.endless = true;
new TestCrashAPI().runTest(test);
} else if ("synth".equals(args[0])) {
new TestSynth().runTest(test);
......@@ -620,6 +612,7 @@ Features of H2
new TestMVCC().runTest(this);
// synthetic
new TestCrashAPI().runTest(this);
new TestRandomSQL().runTest(this);
new TestKillRestart().runTest(this);
......
/*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test;
......@@ -52,6 +52,9 @@ public abstract class TestBase {
}
public void runTest(TestAll conf) {
if (conf.networked) {
return;
}
try {
init(conf);
start = System.currentTimeMillis();
......
......@@ -5,8 +5,10 @@
package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.StringTokenizer;
import org.h2.test.TestBase;
......@@ -17,17 +19,59 @@ public class TestFullText extends TestBase {
return;
}
test(false);
testPerformance(false);
String luceneFullTextClassName = "org.h2.fulltext.FullTextLucene";
try {
Class.forName(luceneFullTextClassName);
test(true);
testPerformance(true);
} catch (ClassNotFoundException e) {
this.println("Class not found, not tested: " + luceneFullTextClassName);
println("Class not found, not tested: " + luceneFullTextClassName);
// ok
}
}
private void testPerformance(boolean lucene) throws Exception {
deleteDb("fullText");
Connection conn = getConnection("fullText");
String prefix = lucene ? "FTL" : "FT";
Statement stat = conn.createStatement();
String className = lucene ? "FullTextLucene" : "FullText";
stat.execute("CREATE ALIAS IF NOT EXISTS " + prefix + "_INIT FOR \"org.h2.fulltext." + className + ".init\"");
stat.execute("CALL " + prefix + "_INIT()");
stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("CREATE TABLE TEST AS SELECT * FROM INFORMATION_SCHEMA.HELP");
stat.execute("ALTER TABLE TEST ALTER COLUMN ID INT NOT NULL");
stat.execute("CREATE PRIMARY KEY ON TEST(ID)");
long time = System.currentTimeMillis();
stat.execute("CALL " + prefix + "_CREATE_INDEX('PUBLIC', 'TEST', NULL)");
println("Create index " + prefix + ": " + (System.currentTimeMillis() - time) + " ms");
PreparedStatement prep = conn.prepareStatement("SELECT * FROM " + prefix + "_SEARCH(?, 0, 0)");
time = System.currentTimeMillis();
ResultSet rs = stat.executeQuery("SELECT TEXT FROM TEST");
int count = 0;
while (rs.next()) {
String text = rs.getString(1);
StringTokenizer tokenizer = new StringTokenizer(text, " ()[].,;:-+*/!?=<>{}#@'\"~$_%&|");
while (tokenizer.hasMoreTokens()) {
String word = tokenizer.nextToken();
if (word.length() < 10) {
continue;
}
prep.setString(1, word);
ResultSet rs2 = prep.executeQuery();
while (rs2.next()) {
rs2.getString(1);
count++;
}
}
}
println("Search " + prefix + ": " + (System.currentTimeMillis() - time) + " ms, count: " + count);
stat.execute("CALL " + prefix + "_DROP_ALL()");
conn.close();
}
private void test(boolean lucene) throws Exception {
deleteDb("fullText");
Connection conn = getConnection("fullText");
......
......@@ -578,7 +578,7 @@ public class TestMetaData extends TestBase {
testResultSetOrdered(rs, new String[][] {
{ catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog, "IDX_DATE",
"" + DatabaseMetaData.tableIndexOther, "1", "DATE_V", "A", "0", "0", "" },
{ catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog, "PRIMARY_KEY_1",
{ catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog, "PRIMARY_KEY_2",
"" + DatabaseMetaData.tableIndexOther, "1", "ID", "A", "0", "0", "" },
{ catalog, Constants.SCHEMA_MAIN, "TEST", "TRUE", catalog, "IDX_TEXT_DEC",
"" + DatabaseMetaData.tableIndexOther, "1", "TEXT_V", "A", "0", "0", "" },
......@@ -593,14 +593,14 @@ public class TestMetaData extends TestBase {
DataType.TYPE_BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.SMALLINT, Types.VARCHAR,
Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER }, null, null);
testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog,
"PRIMARY_KEY_1", "" + DatabaseMetaData.tableIndexOther, "1", "ID", "A", "0", "0", "" } });
"PRIMARY_KEY_2", "" + DatabaseMetaData.tableIndexOther, "1", "ID", "A", "0", "0", "" } });
trace("getPrimaryKeys");
rs = meta.getPrimaryKeys(null, null, "TEST");
testResultSetMeta(rs, 6, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "KEY_SEQ",
"PK_NAME" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT,
Types.VARCHAR }, null, null);
testResultSetOrdered(rs,
new String[][] { { catalog, Constants.SCHEMA_MAIN, "TEST", "ID", "1", "PRIMARY_KEY_1" }, });
new String[][] { { catalog, Constants.SCHEMA_MAIN, "TEST", "ID", "1", "PRIMARY_KEY_2" }, });
trace("getTables - using a wildcard");
stat.executeUpdate("CREATE TABLE T_2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))");
stat.executeUpdate("CREATE TABLE TX2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))");
......@@ -719,21 +719,21 @@ public class TestMetaData extends TestBase {
* null,
* null
*/},
{ catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_3",
{ catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_146",
"" + DatabaseMetaData.tableIndexOther, "1", "C", "A" /*
* ,
* null,
* null,
* null
*/},
{ catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_3",
{ catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_146",
"" + DatabaseMetaData.tableIndexOther, "2", "A", "A" /*
* ,
* null,
* null,
* null
*/},
{ catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_3",
{ catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_146",
"" + DatabaseMetaData.tableIndexOther, "3", "B", "A"/*
* ,
* null,
......@@ -763,9 +763,9 @@ public class TestMetaData extends TestBase {
*/}, });
trace("getPrimaryKeys");
rs = meta.getPrimaryKeys(null, null, "T_2");
testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "T_2", "A", "2", "PRIMARY_KEY_2" },
{ catalog, Constants.SCHEMA_MAIN, "T_2", "B", "3", "PRIMARY_KEY_2" },
{ catalog, Constants.SCHEMA_MAIN, "T_2", "C", "1", "PRIMARY_KEY_2" }, });
testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "T_2", "A", "2", "PRIMARY_KEY_14" },
{ catalog, Constants.SCHEMA_MAIN, "T_2", "B", "3", "PRIMARY_KEY_14" },
{ catalog, Constants.SCHEMA_MAIN, "T_2", "C", "1", "PRIMARY_KEY_14" }, });
stat.executeUpdate("DROP TABLE TX2");
stat.executeUpdate("DROP TABLE T_2");
stat.executeUpdate("CREATE TABLE PARENT(ID INT PRIMARY KEY)");
......
......@@ -6,11 +6,16 @@ package org.h2.test.synth;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.BatchUpdateException;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
......@@ -33,7 +38,8 @@ import org.h2.util.RandomUtils;
*/
public class TestCrashAPI extends TestBase {
public static final Class[] INTERFACES = { Connection.class, PreparedStatement.class, Statement.class,
ResultSet.class, ResultSetMetaData.class, Savepoint.class };
ResultSet.class, ResultSetMetaData.class, Savepoint.class,
ParameterMetaData.class, Clob.class, Blob.class, Array.class, CallableStatement.class };
private ArrayList objects = new ArrayList();
private HashMap classMethods = new HashMap();
private RandomGen random = new RandomGen(null);
......@@ -376,7 +382,8 @@ public class TestCrashAPI extends TestBase {
}
public void test() throws Exception {
while (true) {
int len = getSize(2, 6);
for (int i = 0; i < len; i++) {
int seed = RandomUtils.nextInt(Integer.MAX_VALUE);
testCase(seed);
deleteDb();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论