提交 554a5c0f authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 22be687e
...@@ -18,7 +18,12 @@ Change Log ...@@ -18,7 +18,12 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>Calling execute() or prepareStatement() with null as the SQL statement <ul><li>Identifiers with a digit and then a dollar sign didn't work. Example: A1$B.
</li><li>MS SQL Server compatibility: support for linked tables with
NVARCHAR, NCHAR, NCLOB, and LONGNVARCHAR.
</li><li>Android: Workaround for a problem when using read-only databases in zip files
(skip seems to be implemented incorrectly on the Android system).
</li><li>Calling execute() or prepareStatement() with null as the SQL statement
now throws an exception. now throws an exception.
</li><li>Benchmark: the number of executed statements was incorrect. The H2 database </li><li>Benchmark: the number of executed statements was incorrect. The H2 database
was loaded at the beginning of the test to collect results, now it is loaded at the very end. was loaded at the beginning of the test to collect results, now it is loaded at the very end.
......
...@@ -107,7 +107,7 @@ One query where HSQLDB is slow is a two-table join: ...@@ -107,7 +107,7 @@ One query where HSQLDB is slow is a two-table join:
</p> </p>
<pre> <pre>
SELECT COUNT(DISTINCT S_I_ID) FROM ORDER_LINE, STOCK SELECT COUNT(DISTINCT S_I_ID) FROM ORDER_LINE, STOCK
WHERE OL_W_ID=? AND OL_D_ID=? AND OL_O_ID&lt;? AND OL_O_ID>=? WHERE OL_W_ID=? AND OL_D_ID=? AND OL_O_ID&lt;? AND OL_O_ID&gt;=?
AND S_W_ID=? AND S_I_ID=OL_I_ID AND S_QUANTITY&lt;? AND S_W_ID=? AND S_I_ID=OL_I_ID AND S_QUANTITY&lt;?
</pre> </pre>
<p> <p>
...@@ -172,6 +172,20 @@ SQLite was not tested because the JDBC driver doesn't support transactions. ...@@ -172,6 +172,20 @@ SQLite was not tested because the JDBC driver doesn't support transactions.
<h3>About this Benchmark</h3> <h3>About this Benchmark</h3>
<h4>How to Run</h4>
<p>
This test was executed as follows:
</p>
<pre>
build benchmark
</pre>
<h4>Separate Process per Database</h4>
<p>
For each database, a new process is started, to ensure the previous test does not impact
the current test.
</p>
<h4>Number of Connections</h4> <h4>Number of Connections</h4>
<p> <p>
This is mostly a single-connection benchmark. This is mostly a single-connection benchmark.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -12,7 +12,6 @@ import java.text.Collator; ...@@ -12,7 +12,6 @@ import java.text.Collator;
import org.h2.command.Prepared; import org.h2.command.Prepared;
import org.h2.compress.Compressor; import org.h2.compress.Compressor;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Mode; import org.h2.engine.Mode;
import org.h2.engine.Session; import org.h2.engine.Session;
...@@ -99,21 +98,20 @@ public class Set extends Prepared { ...@@ -99,21 +98,20 @@ public class Set extends Prepared {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
buff.append(stringValue); buff.append(stringValue);
if (stringValue.equals(CompareMode.OFF)) { if (stringValue.equals(CompareMode.OFF)) {
compareMode = new CompareMode(null, null, 0); compareMode = new CompareMode(null, 0);
} else { } else {
Collator coll = CompareMode.getCollator(stringValue); int strength = getIntValue();
compareMode = new CompareMode(coll, stringValue, SysProperties.getCollatorCacheSize());
buff.append(" STRENGTH "); buff.append(" STRENGTH ");
if (getIntValue() == Collator.IDENTICAL) { if (strength == Collator.IDENTICAL) {
buff.append("IDENTICAL"); buff.append("IDENTICAL");
} else if (getIntValue() == Collator.PRIMARY) { } else if (strength == Collator.PRIMARY) {
buff.append("PRIMARY"); buff.append("PRIMARY");
} else if (getIntValue() == Collator.SECONDARY) { } else if (strength == Collator.SECONDARY) {
buff.append("SECONDARY"); buff.append("SECONDARY");
} else if (getIntValue() == Collator.TERTIARY) { } else if (strength == Collator.TERTIARY) {
buff.append("TERTIARY"); buff.append("TERTIARY");
} }
coll.setStrength(getIntValue()); compareMode = new CompareMode(stringValue, strength);
} }
addOrUpdateSetting(name, buff.toString(), 0); addOrUpdateSetting(name, buff.toString(), 0);
database.setCompareMode(compareMode); database.setCompareMode(compareMode);
...@@ -341,7 +339,7 @@ public class Set extends Prepared { ...@@ -341,7 +339,7 @@ public class Set extends Prepared {
private void addOrUpdateSetting(String name, String s, int v) throws SQLException { private void addOrUpdateSetting(String name, String s, int v) throws SQLException {
Database database = session.getDatabase(); Database database = session.getDatabase();
if (database.getReadOnly()) { if (database.isReadOnly()) {
return; return;
} }
Setting setting = database.findSetting(name); Setting setting = database.findSetting(name);
......
...@@ -170,7 +170,7 @@ public class Database implements DataHandler { ...@@ -170,7 +170,7 @@ public class Database implements DataHandler {
private boolean reconnectChangePending; private boolean reconnectChangePending;
public Database(String name, ConnectionInfo ci, String cipher) throws SQLException { public Database(String name, ConnectionInfo ci, String cipher) throws SQLException {
this.compareMode = new CompareMode(null, null, 0); this.compareMode = new CompareMode(null, 0);
this.persistent = ci.isPersistent(); this.persistent = ci.isPersistent();
this.filePasswordHash = ci.getFilePasswordHash(); this.filePasswordHash = ci.getFilePasswordHash();
this.databaseName = name; this.databaseName = name;
...@@ -1768,7 +1768,7 @@ public class Database implements DataHandler { ...@@ -1768,7 +1768,7 @@ public class Database implements DataHandler {
} }
} }
public boolean getReadOnly() { public boolean isReadOnly() {
return readOnly; return readOnly;
} }
...@@ -2046,7 +2046,7 @@ public class Database implements DataHandler { ...@@ -2046,7 +2046,7 @@ public class Database implements DataHandler {
} }
} }
public boolean getIndexSummaryValid() { public boolean isIndexSummaryValid() {
return indexSummaryValid; return indexSummaryValid;
} }
......
...@@ -691,7 +691,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -691,7 +691,7 @@ public class Function extends Expression implements FunctionCall {
result = ValueBoolean.get(session.getAutoCommit()); result = ValueBoolean.get(session.getAutoCommit());
break; break;
case READONLY: case READONLY:
result = ValueBoolean.get(database.getReadOnly()); result = ValueBoolean.get(database.isReadOnly());
break; break;
case DATABASE_PATH: { case DATABASE_PATH: {
String path = database.getDatabasePath(); String path = database.getDatabasePath();
......
...@@ -85,7 +85,7 @@ public class LogFile { ...@@ -85,7 +85,7 @@ public class LogFile {
unwritten = new ObjectArray(); unwritten = new ObjectArray();
try { try {
readHeader(); readHeader();
if (!log.getDatabase().getReadOnly()) { if (!log.getDatabase().isReadOnly()) {
writeHeader(); writeHeader();
} }
pos = getBlock(); pos = getBlock();
...@@ -243,7 +243,7 @@ public class LogFile { ...@@ -243,7 +243,7 @@ public class LogFile {
int blocks = in.readInt(); int blocks = in.readInt();
if (blocks < 0) { if (blocks < 0) {
return true; return true;
} else if (blocks == 0 && !database.getReadOnly()) { } else if (blocks == 0 && !database.isReadOnly()) {
truncate(pos); truncate(pos);
return false; return false;
} }
...@@ -359,7 +359,7 @@ public class LogFile { ...@@ -359,7 +359,7 @@ public class LogFile {
* the file. * the file.
*/ */
void redoAllGoEnd() throws SQLException { void redoAllGoEnd() throws SQLException {
boolean readOnly = logSystem.getDatabase().getReadOnly(); boolean readOnly = logSystem.getDatabase().isReadOnly();
long length = file.length(); long length = file.length();
if (length <= FileStore.HEADER_LENGTH) { if (length <= FileStore.HEADER_LENGTH) {
return; return;
......
...@@ -602,7 +602,7 @@ public class LogSystem { ...@@ -602,7 +602,7 @@ public class LogSystem {
if (summary != null) { if (summary != null) {
currentLog.addSummary(true, summary); currentLog.addSummary(true, summary);
} }
if (database.getLogIndexChanges() || database.getIndexSummaryValid()) { if (database.getLogIndexChanges() || database.isIndexSummaryValid()) {
file = database.getIndexFile(); file = database.getIndexFile();
summary = file.getSummary(); summary = file.getSummary();
if (summary != null) { if (summary != null) {
......
...@@ -480,7 +480,7 @@ public class DiskFile implements CacheWriter { ...@@ -480,7 +480,7 @@ public class DiskFile implements CacheWriter {
public void close() throws SQLException { public void close() throws SQLException {
synchronized (database) { synchronized (database) {
SQLException closeException = null; SQLException closeException = null;
if (!database.getReadOnly()) { if (!database.isReadOnly()) {
try { try {
flush(); flush();
} catch (SQLException e) { } catch (SQLException e) {
......
...@@ -246,7 +246,7 @@ public class TableData extends Table implements RecordReader { ...@@ -246,7 +246,7 @@ public class TableData extends Table implements RecordReader {
// need to update, because maybe the index is rebuilt at startup, // need to update, because maybe the index is rebuilt at startup,
// and so the head pos may have changed, which needs to be stored now. // and so the head pos may have changed, which needs to be stored now.
// addSchemaObject doesn't update the sys table at startup // addSchemaObject doesn't update the sys table at startup
if (index.getIndexType().getPersistent() && !database.getReadOnly() if (index.getIndexType().getPersistent() && !database.isReadOnly()
&& !database.getLog().containsInDoubtTransactions()) { && !database.getLog().containsInDoubtTransactions()) {
// can not save anything in the log file if it contains in-doubt transactions // can not save anything in the log file if it contains in-doubt transactions
database.update(session, index); database.update(session, index);
......
...@@ -10,6 +10,7 @@ import java.text.CollationKey; ...@@ -10,6 +10,7 @@ import java.text.CollationKey;
import java.text.Collator; import java.text.Collator;
import java.util.Locale; import java.util.Locale;
import org.h2.constant.SysProperties;
import org.h2.util.SmallLRUCache; import org.h2.util.SmallLRUCache;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -35,13 +36,17 @@ public class CompareMode { ...@@ -35,13 +36,17 @@ public class CompareMode {
* The cache is used to speed up comparison when using a collator; * The cache is used to speed up comparison when using a collator;
* CollationKey objects are cached. * CollationKey objects are cached.
* *
* @param collator the collator or null
* @param name the collation name or null * @param name the collation name or null
* @param cacheSize the number of entries in the CollationKey cache * @param strength the collation strength
*/ */
public CompareMode(Collator collator, String name, int cacheSize) { public CompareMode(String name, int strength) {
this.collator = collator; this.collator = CompareMode.getCollator(name);
if (collator != null && cacheSize != 0) { int cacheSize = 0;
if (collator != null) {
this.collator.setStrength(strength);
cacheSize = SysProperties.getCollatorCacheSize();
}
if (cacheSize != 0) {
collationKeys = new SmallLRUCache(cacheSize); collationKeys = new SmallLRUCache(cacheSize);
} else { } else {
collationKeys = null; collationKeys = null;
...@@ -140,6 +145,9 @@ public class CompareMode { ...@@ -140,6 +145,9 @@ public class CompareMode {
* @return the collator * @return the collator
*/ */
public static Collator getCollator(String name) { public static Collator getCollator(String name) {
if (name == null) {
return null;
}
Collator result = null; Collator result = null;
if (name.length() == 2) { if (name.length() == 2) {
Locale locale = new Locale(name.toLowerCase(), ""); Locale locale = new Locale(name.toLowerCase(), "");
......
...@@ -286,12 +286,22 @@ java org.h2.test.TestAll timer ...@@ -286,12 +286,22 @@ java org.h2.test.TestAll timer
System.setProperty("h2.maxMemoryRowsDistinct", "128"); System.setProperty("h2.maxMemoryRowsDistinct", "128");
System.setProperty("h2.check2", "true"); System.setProperty("h2.check2", "true");
// 2009-05-15: 25 test fail with page store (first loop)
// System.setProperty("h2.pageStore", "true"); // System.setProperty("h2.pageStore", "true");
/* /*
what do other databases do when calling prepareStatement(null) index grows:
and execute(null)? runscript from '~/Desktop/merge.sql';
create table test(id int, name varchar, primary key(id, name));
@LOOP 10000 merge into test(id, name) values(?, 'test' || ?);
BaseIndex or TableData should have its own compareMode
(default is: Database.compareMode when created).
standard: COLLATE for each column (MySQL, SQL Server)
stored in the pageStore as well.
check syntax in other databases.
this mean changing the collation is allowed if there are tables.
test case for running out of disk space (using a special file system) test case for running out of disk space (using a special file system)
......
...@@ -121,6 +121,7 @@ public class TestFuzzOptimizations extends TestBase { ...@@ -121,6 +121,7 @@ public class TestFuzzOptimizations extends TestBase {
group += " ORDER BY 1, 2, 3"; group += " ORDER BY 1, 2, 3";
List a = db.query(x + "TEST" + group); List a = db.query(x + "TEST" + group);
List b = db.query(x + "TEST_INDEXED" + group); List b = db.query(x + "TEST_INDEXED" + group);
assertEquals(a.toString(), b.toString());
assertTrue(a.equals(b)); assertTrue(a.equals(b));
} }
db.execute("DROP TABLE TEST_INDEXED"); db.execute("DROP TABLE TEST_INDEXED");
......
create table t1$2(id int);
drop table t1$2;
create table test(id int primary key) as select x from system_range(1, 200); create table test(id int primary key) as select x from system_range(1, 200);
delete from test; delete from test;
insert into test(id) values(1); insert into test(id) values(1);
......
...@@ -27,7 +27,7 @@ public class TestPattern extends TestBase { ...@@ -27,7 +27,7 @@ public class TestPattern extends TestBase {
} }
public void test() throws SQLException { public void test() throws SQLException {
CompareMode mode = new CompareMode(null, null, 100); CompareMode mode = new CompareMode(null, 0);
CompareLike comp = new CompareLike(mode, null, null, null, false); CompareLike comp = new CompareLike(mode, null, null, null, false);
test(comp, "B", "%_"); test(comp, "B", "%_");
test(comp, "A", "A%"); test(comp, "A", "A%");
......
...@@ -29,7 +29,7 @@ import org.h2.value.ValueInt; ...@@ -29,7 +29,7 @@ import org.h2.value.ValueInt;
*/ */
public class TestValueHashMap extends TestBase implements DataHandler { public class TestValueHashMap extends TestBase implements DataHandler {
CompareMode compareMode = new CompareMode(null, null, 0); CompareMode compareMode = new CompareMode(null, 0);
/** /**
* Run just this test. * Run just this test.
......
...@@ -588,4 +588,5 @@ animate scaladoc models disadvantages vladykin sergi trims requesting ...@@ -588,4 +588,5 @@ animate scaladoc models disadvantages vladykin sergi trims requesting
handing bonita placed euros embeds reliability singular unregister quotas handing bonita placed euros embeds reliability singular unregister quotas
overall httpdocs tigris eclemma separates underscore yajsw she her truncating overall httpdocs tigris eclemma separates underscore yajsw she her truncating
relocating smtps smtp osde joist catching guesses delimiters shortlist sheet relocating smtps smtp osde joist catching guesses delimiters shortlist sheet
rowspan cheat partitioning datepart rowspan cheat partitioning datepart dreamsource toussi locates fred
\ No newline at end of file longnvarchar collate localdb
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论