提交 4463dbfa authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 4887e417
# properties for build.xml
jdk=1.4
version.name.maven=1.0.20061217
javac=javac
benchmark.drivers.dir=D:/data/java
<project name="h2" default="all" basedir="."> <project name="h2" default="all" basedir=".">
<property name="version.name" value="1.0.20061217"/> <property file="ant-build.properties" />
<!--
<property name="version.name.maven" value="1.0.20061217"/>
<property name="jdk" value="1.4"/> <property name="jdk" value="1.4"/>
<property name="javac" value="javac"/> <property name="javac" value="javac"/>
-->
<path id="benchmark.drivers.path"> <path id="benchmark.drivers.path">
<!-- jar files required by the benchmark --> <!-- jar files required by the benchmark -->
<pathelement location="bin"/> <pathelement location="bin"/>
<pathelement path="${java.class.path}/"/> <pathelement path="${java.class.path}/"/>
<fileset dir="D:/data/java"> <fileset dir="${benchmark.drivers.dir}">
<include name="**/*.jar"/> <include name="**/*.jar"/>
</fileset> </fileset>
</path> </path>
...@@ -62,18 +65,27 @@ ...@@ -62,18 +65,27 @@
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools"> <java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools">
<arg line="+JDK13 -JDK14 -JDK16 ../main/org/h2"/> <arg line="+JDK13 -JDK14 -JDK16 ../main/org/h2"/>
</java> </java>
<propertyfile file="build.properties">
<entry key="jdk" value="1.3" />
</propertyfile>
</target> </target>
<target name="codeswitch_jdk14" depends="codeswitch_prepare"> <target name="codeswitch_jdk14" depends="codeswitch_prepare">
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools"> <java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools">
<arg line="-JDK13 +JDK14 -JDK16 ../main/org/h2"/> <arg line="-JDK13 +JDK14 -JDK16 ../main/org/h2"/>
</java> </java>
<propertyfile file="build.properties">
<entry key="jdk" value="1.4" />
</propertyfile>
</target> </target>
<target name="codeswitch_jdk16" depends="codeswitch_prepare"> <target name="codeswitch_jdk16" depends="codeswitch_prepare">
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools"> <java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools">
<arg line="-JDK13 +JDK16 +JDK14 ../main/org/h2"/> <arg line="-JDK13 +JDK16 +JDK14 ../main/org/h2"/>
</java> </java>
<propertyfile file="build.properties">
<entry key="jdk" value="1.6" />
</propertyfile>
</target> </target>
<target name="compileResources" depends="clean"> <target name="compileResources" depends="clean">
...@@ -217,15 +229,15 @@ ...@@ -217,15 +229,15 @@
</target> </target>
<target name="mavenBuildCentral"> <target name="mavenBuildCentral">
<copy tofile="bin/h2-${version.name}.jar" file="bin/h2.jar" /> <copy tofile="bin/h2-${version.name.maven}.jar" file="bin/h2.jar" />
<copy tofile="bin/pom.xml" filtering="true" file="src/installer/pom.xml"> <copy tofile="bin/pom.xml" filtering="true" file="src/installer/pom.xml">
<filterset> <filterset>
<filter token="version" value="${version.name}"/> <filter token="version" value="${version.name.maven}"/>
</filterset> </filterset>
</copy> </copy>
<zip destfile="bin/h2-maven-${version.name}.jar" basedir="bin"> <zip destfile="bin/h2-maven-${version.name.maven}.jar" basedir="bin">
<include name="pom.xml" /> <include name="pom.xml" />
<include name="h2-${version.name}.jar" /> <include name="h2-${version.name.maven}.jar" />
</zip> </zip>
</target> </target>
......
...@@ -42,7 +42,7 @@ Advanced Topics ...@@ -42,7 +42,7 @@ Advanced Topics
<a href="#uuid"> <a href="#uuid">
Universally Unique Identifiers (UUID)</a><br /> Universally Unique Identifiers (UUID)</a><br />
<a href="#system_properties"> <a href="#system_properties">
H2 System Properties</a><br /> Settings Read from System Properties</a><br />
<a href="#glossary_links"> <a href="#glossary_links">
Glossary and Links</a><br /> Glossary and Links</a><br />
...@@ -192,6 +192,15 @@ database that failed, then restart the server that was stopped, ...@@ -192,6 +192,15 @@ database that failed, then restart the server that was stopped,
and re-run the CreateCluster tool. and re-run the CreateCluster tool.
</ul> </ul>
<h3>Clustering Algorithm and Limitations</h3>
Read-only queries are only executed against the first cluster node, but all other statements are
executed against all nodes. There is currently no load balancing made to avoid problems with
transactions. The following functions may yield different results on different cluster nodes and must be
executed with care: RANDOM_UUID(), SECURE_RAND(), SESSION_ID(), MEMORY_FREE(), MEMORY_USED(),
CSVREAD(), CSVWRITE(), RAND() [when not using a seed]. Those functions should not be used
directly in modifying statements (for example INSERT, UPDATE, or MERGE). However, they can be used
in read-only statements and the result can then be used for modifying statements.
<br /><a name="two_phase_commit"></a> <br /><a name="two_phase_commit"></a>
<h2>Two Phase Commit</h2> <h2>Two Phase Commit</h2>
The two phase commit protocol is supported. 2-phase-commit works as follows: The two phase commit protocol is supported. 2-phase-commit works as follows:
...@@ -647,7 +656,7 @@ One's annual risk of being hit by a meteorite is estimated to be one chance in 1 ...@@ -647,7 +656,7 @@ One's annual risk of being hit by a meteorite is estimated to be one chance in 1
that means the probability is about 0.000'000'000'06. that means the probability is about 0.000'000'000'06.
<br /><a name="system_properties"></a> <br /><a name="system_properties"></a>
<h2>H2 System Properties</h2> <h2>Settings Read from System Properties</h2>
<p> <p>
Some settings of the database can be set on the command line using Some settings of the database can be set on the command line using
-DpropertyName=value. It is usually not required to change those settings manually. -DpropertyName=value. It is usually not required to change those settings manually.
...@@ -657,10 +666,10 @@ Example: ...@@ -657,10 +666,10 @@ Example:
<pre> <pre>
java -Dh2.serverCachedObjects=256 org.h2.tools.Server java -Dh2.serverCachedObjects=256 org.h2.tools.Server
</pre> </pre>
<pre> <p>
The current value of the settings can be read in the table The current value of the settings can be read in the table
INFORMATION_SCHEMA.SETTINGS INFORMATION_SCHEMA.SETTINGS
</pre> </p>
<table><tr> <table><tr>
<th>Setting</th> <th>Setting</th>
<th>Default</th> <th>Default</th>
......
...@@ -58,14 +58,26 @@ The other targets may be used as well. ...@@ -58,14 +58,26 @@ The other targets may be used as well.
<br /><a name="maven2"></a> <br /><a name="maven2"></a>
<h2>Using Maven 2</h2> <h2>Using Maven 2</h2>
To build and upload the H2 .jar file to the local Maven 2 repository, execute the following command: <h3>Using a Central Repository</h3>
You can include the database in your Maven 2 project as a dependency.
The version is currently 1.0.&lt;year&gt;&lt;month&gt;&lt;day&gt;. Example:
<pre>
&lt;dependency&gt;
&lt;groupId&gt;com.h2database&lt;/groupId&gt;
&lt;artifactId&gt;h2&lt;/artifactId&gt;
&lt;version&gt;1.0.20061217&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<h3>Using Snapshot Version</h3>
To build a 'snapshot' H2 .jar file and upload it the to the local Maven 2 repository, execute the following command:
<pre> <pre>
ant mavenUploadLocal ant mavenUploadLocal
</pre> </pre>
Afterwards, you can include the database in your Maven 2 project as a dependency: Afterwards, you can include the database in your Maven 2 project as a dependency:
<pre> <pre>
&lt;dependency&gt; &lt;dependency&gt;
&lt;groupId&gt;org.h2database&lt;/groupId&gt; &lt;groupId&gt;com.h2database&lt;/groupId&gt;
&lt;artifactId&gt;h2&lt;/artifactId&gt; &lt;artifactId&gt;h2&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt; &lt;/dependency&gt;
......
...@@ -34,6 +34,18 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -34,6 +34,18 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3> <h3>Version 1.0 (Current)</h3>
<h3>Version 1.0 / 2007-TODO</h3><ul>
<li>If a CLOB or BLOB was deleted in a transaction and the database crashed before the transaction was committed or rolled back,
the object was lost if it was large. Fixed.
<li>Now using ant-build.properties. The jdk is automatically updated when using ant codeswitch_...
<li>Cluster: Now the server can detect if a query is read-only, and in this case the result is only read from the first cluster node.
However, there is currently no load balancing made to avoid problems with transactions / locking.
<li>Many settings are now initialized from system properties and can be changed on the command line without having
recompile the database. See Advances / Settings Read from System Properties.
<li>H2 is now available in Maven. The groupId is com.h2database, the artifactId h2 and the version 1.0.20061217.
To create the maven artifacts yourself, use 'ant mavenUploadLocal' and 'ant mavenBuildCentral'.
</ul>
<h3>Version 1.0 / 2006-12-17</h3><ul> <h3>Version 1.0 / 2006-12-17</h3><ul>
<li>Can be compiled with JDK 1.6. However, only very few of the JDBC 4.0 features are implemented so far. <li>Can be compiled with JDK 1.6. However, only very few of the JDBC 4.0 features are implemented so far.
<li>The unit test of OpenJPA works now. <li>The unit test of OpenJPA works now.
...@@ -1551,7 +1563,7 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -1551,7 +1563,7 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<li>Backup tool should work with other databases as well <li>Backup tool should work with other databases as well
<li>Console: -ifExists doesn't work for the console. Add a flag to disable other dbs <li>Console: -ifExists doesn't work for the console. Add a flag to disable other dbs
<li>Maybe use Fowler Noll Vo hash function <li>Maybe use Fowler Noll Vo hash function
<li>Improved Full text search (update index real-time or in a lower priority thread) Update now, update every n where n could be never. <li>Improved full text search (supports LOBs, readers / tokenizers / filters).
<li>Update in-place <li>Update in-place
<li>Check if 'FSUTIL behavior set disablelastaccess 1' improves the performance (fsutil behavior query disablelastaccess) <li>Check if 'FSUTIL behavior set disablelastaccess 1' improves the performance (fsutil behavior query disablelastaccess)
<li>Remove finally() (almost) everywhere <li>Remove finally() (almost) everywhere
...@@ -1592,6 +1604,7 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -1592,6 +1604,7 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<li>File_Read / File_Store funktionen: FILE_STORE('test.sql', ?), FILE_READ('test.sql') <li>File_Read / File_Store funktionen: FILE_STORE('test.sql', ?), FILE_READ('test.sql')
<li>Public interface for functions (not public static) <li>Public interface for functions (not public static)
<li>Index usage for IN(...), IN_ARRAY(..), and IN_ARRAY_RANGES(..); support ARRAY in JDBC API (variable size) <li>Index usage for IN(...), IN_ARRAY(..), and IN_ARRAY_RANGES(..); support ARRAY in JDBC API (variable size)
<li>Change LOB mechanism (less files, keep index of lob files, point to files and row, delete unused files earlier)
</ul> </ul>
<h3>Not Planned</h3> <h3>Not Planned</h3>
......
...@@ -11,8 +11,10 @@ package org.h2.engine; ...@@ -11,8 +11,10 @@ package org.h2.engine;
* - System.out > trace messages * - System.out > trace messages
* *
* Release checklist * Release checklist
* - Update latest version in docs: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/
* - ant jarClient, check jar file size * - ant jarClient, check jar file size
* - try compiling with JDK 1.3, 1.4, 1.5 and 1.6 * - try compiling with JDK 1.3, 1.4, 1.5 and 1.6
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* - change FAQ (next release planned, known bugs) * - change FAQ (next release planned, known bugs)
* - check version, change build number in Constants.java and build.xml * - check version, change build number in Constants.java and build.xml
* - check code coverage * - check code coverage
...@@ -48,6 +50,7 @@ package org.h2.engine; ...@@ -48,6 +50,7 @@ package org.h2.engine;
* *
* - Send a mail to Google Groups * - Send a mail to Google Groups
* - newsletter: prepare, send (always send to BCC!!) * - newsletter: prepare, send (always send to BCC!!)
* - http://maven.apache.org/guides/mini/guide-ibiblio-upload.html
* *
* @author Thomas * @author Thomas
*/ */
......
...@@ -6,6 +6,8 @@ package org.h2.engine; ...@@ -6,6 +6,8 @@ package org.h2.engine;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random; import java.util.Random;
import org.h2.command.Command; import org.h2.command.Command;
...@@ -26,6 +28,7 @@ import org.h2.store.UndoLogRecord; ...@@ -26,6 +28,7 @@ import org.h2.store.UndoLogRecord;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.table.TableData; import org.h2.table.TableData;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.value.Value;
/** /**
* @author Thomas * @author Thomas
...@@ -55,6 +58,7 @@ public class Session implements SessionInterface { ...@@ -55,6 +58,7 @@ public class Session implements SessionInterface {
private boolean allowLiterals; private boolean allowLiterals;
private String currentSchemaName; private String currentSchemaName;
private String traceModuleName; private String traceModuleName;
private HashSet unlinkSet;
public Table findLocalTempTable(String name) { public Table findLocalTempTable(String name) {
Table t = null; Table t = null;
...@@ -192,6 +196,16 @@ public class Session implements SessionInterface { ...@@ -192,6 +196,16 @@ public class Session implements SessionInterface {
undoLog.clear(); undoLog.clear();
cleanTempTables(); cleanTempTables();
} }
if(unlinkSet != null && unlinkSet.size() > 0) {
// need to flush the log file, because we can't unlink lobs if the commit record is not written
logSystem.flush();
Iterator it = unlinkSet.iterator();
while(it.hasNext()) {
Value v = (Value) it.next();
v.unlink(database);
}
unlinkSet = null;
}
unlockAll(); unlockAll();
} }
...@@ -447,4 +461,17 @@ public class Session implements SessionInterface { ...@@ -447,4 +461,17 @@ public class Session implements SessionInterface {
return database; return database;
} }
public void unlinkAtCommit(Value v) {
if(unlinkSet == null) {
unlinkSet = new HashSet();
}
unlinkSet.add(v);
}
public void unlinkAtCommitStop(Value v) {
if(unlinkSet != null) {
unlinkSet.remove(v);
}
}
} }
...@@ -151,8 +151,6 @@ int count; ...@@ -151,8 +151,6 @@ int count;
int splitPoint = root.add(row, session); int splitPoint = root.add(row, session);
if (splitPoint != 0) { if (splitPoint != 0) {
SearchRow pivot = root.getData(splitPoint); SearchRow pivot = root.getData(splitPoint);
int test;
// deletePage(session, root);
BtreePage page1 = root; BtreePage page1 = root;
BtreePage page2 = root.split(session, splitPoint); BtreePage page2 = root.split(session, splitPoint);
setRoot(new BtreeNode(this, page1, pivot, page2)); setRoot(new BtreeNode(this, page1, pivot, page2));
......
...@@ -129,9 +129,8 @@ public class BtreeLeaf extends BtreePage { ...@@ -129,9 +129,8 @@ public class BtreeLeaf extends BtreePage {
public BtreePage split(Session session, int splitPoint) throws SQLException { public BtreePage split(Session session, int splitPoint) throws SQLException {
ObjectArray data = new ObjectArray(); ObjectArray data = new ObjectArray();
int max = pageData.size(); int max = pageData.size();
int test;
if(Constants.CHECK && index.getDatabase().getLogIndexChanges() && !getDeleted()) { if(Constants.CHECK && index.getDatabase().getLogIndexChanges() && !getDeleted()) {
// page must have been deleted already before calling getSplitPoint() // page must have been deleted already before calling getSplitPoint()
throw Message.getInternalError(); throw Message.getInternalError();
} }
for (int i = splitPoint; i < max; i++) { for (int i = splitPoint; i < max; i++) {
......
...@@ -176,7 +176,6 @@ public class BtreeNode extends BtreePage { ...@@ -176,7 +176,6 @@ public class BtreeNode extends BtreePage {
IntArray children = new IntArray(); IntArray children = new IntArray();
splitPoint++; splitPoint++;
int max = pageData.size(); int max = pageData.size();
int test;
if(Constants.CHECK && index.getDatabase().getLogIndexChanges() && !getDeleted()) { if(Constants.CHECK && index.getDatabase().getLogIndexChanges() && !getDeleted()) {
// page must have been deleted already before calling getSplitPoint() // page must have been deleted already before calling getSplitPoint()
throw Message.getInternalError(); throw Message.getInternalError();
......
...@@ -94,6 +94,7 @@ public class ScanIndex extends Index { ...@@ -94,6 +94,7 @@ public class ScanIndex extends Index {
for(int i=0; i<row.getColumnCount(); i++) { for(int i=0; i<row.getColumnCount(); i++) {
Value v = row.getValue(i); Value v = row.getValue(i);
Value v2 = v.link(database, getId()); Value v2 = v.link(database, getId());
session.unlinkAtCommitStop(v2);
if(v != v2) { if(v != v2) {
row.setValue(i, v2); row.setValue(i, v2);
} }
...@@ -121,7 +122,10 @@ public class ScanIndex extends Index { ...@@ -121,7 +122,10 @@ public class ScanIndex extends Index {
storage.removeRecord(session, row.getPos()); storage.removeRecord(session, row.getPos());
if(containsLargeObject) { if(containsLargeObject) {
for(int i=0; i<row.getColumnCount(); i++) { for(int i=0; i<row.getColumnCount(); i++) {
row.getValue(i).unlink(database); Value v = row.getValue(i);
if(v.isLinked()) {
session.unlinkAtCommit(v);
}
} }
} }
} else { } else {
......
...@@ -322,7 +322,8 @@ public class FtpControl extends Thread { ...@@ -322,7 +322,8 @@ public class FtpControl extends Thread {
String list = server.getDirectoryListing(directory, directories); String list = server.getDirectoryListing(directory, directories);
reply(150, "Starting transfer"); reply(150, "Starting transfer");
server.log(list); server.log(list);
data.send(list.getBytes("UTF-8")); // need to use the current locale (UTF-8 would be wrong for the Windows Explorer)
data.send(list.getBytes());
reply(226, "Done"); reply(226, "Done");
} }
......
...@@ -585,6 +585,10 @@ public abstract class Value { ...@@ -585,6 +585,10 @@ public abstract class Value {
return this; return this;
} }
public boolean isLinked() {
return false;
}
public void unlink(DataHandler handler) throws SQLException { public void unlink(DataHandler handler) throws SQLException {
} }
......
...@@ -335,6 +335,10 @@ public class ValueLob extends Value { ...@@ -335,6 +335,10 @@ public class ValueLob extends Value {
return super.convertTo(t); return super.convertTo(t);
} }
public boolean isLinked() {
return linked;
}
public void unlink(DataHandler handler) throws SQLException { public void unlink(DataHandler handler) throws SQLException {
if (linked && fileName != null) { if (linked && fileName != null) {
String temp; String temp;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
*/ */
package org.h2.test; package org.h2.test;
import java.io.File;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
...@@ -66,8 +67,9 @@ start cmd /k "java org.h2.test.TestAll all >testAll.txt" ...@@ -66,8 +67,9 @@ start cmd /k "java org.h2.test.TestAll all >testAll.txt"
start cmd /k "java org.h2.test.TestAll random >testRandom.txt" start cmd /k "java org.h2.test.TestAll random >testRandom.txt"
start cmd /k "java org.h2.test.TestAll btree >testBtree.txt" start cmd /k "java org.h2.test.TestAll btree >testBtree.txt"
Test for hot spots:
java -agentlib:yjpagent=sampling,noj2ee,dir=C:\temp\Snapshots org.h2.test.bench.TestPerformance -init -db 1
java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2:test;TRACE_LEVEL_FILE=3;LOG=2;MAX_LOG_SIZE=1000;DATABASE_EVENT_LISTENER='org.h2.samples.ShowProgress' -user sa -script test.sql java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2:test;TRACE_LEVEL_FILE=3;LOG=2;MAX_LOG_SIZE=1000;DATABASE_EVENT_LISTENER='org.h2.samples.ShowProgress' -user sa -script test.sql
*/ */
public boolean smallLog, big, networked, memory, ssl, textStorage, diskUndo, diskResult, deleteIndex, traceSystemOut; public boolean smallLog, big, networked, memory, ssl, textStorage, diskUndo, diskResult, deleteIndex, traceSystemOut;
...@@ -86,44 +88,10 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2 ...@@ -86,44 +88,10 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
TestAll test = new TestAll(); TestAll test = new TestAll();
test.printSystem(); test.printSystem();
int todoSendMail;
// here's the whole enchilada
// delete the index and log file
//create table test(id int, data array) //create table test(id int, data array)
//document array_get, array_length //document array_get, array_length
// todo: document system properties in advancaed
// lobs: rename / delete: need to check if rename works if stop in the middle
// options for java functions: readonly, deterministic // options for java functions: readonly, deterministic
// document cluster: not allowed operations: update/insert with random data (however in a readonly select it is ok)
// test & document cluster: read only selects only go to the first cluster node
// test & document settings via -Dh2.check=false
// set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
// There is one thing I forgot: you need to change the in the build script
// <property name="jdk" value="1.4"/> to
// <property name="jdk" value="1.6"/>
new TestCrashAPI().init(test).testCase(1656916106); // Bug 2111148370 seed=1656916106 id=-1834 callCount=1787 openCount=50 General error: java.lang.Error: 0 blocks to read pos=192 [HY000-34]
new TestCrashAPI().init(test).testCase(437623957); // Bug -1343599238 seed=437623957 id=-1317 callCount=1289 openCount=42 General error: java.lang.OutOfMemoryError: Java heap space [HY000-34]
// add to maven
// http://jira.codehaus.org/browse/MAVENUPLOAD-1276
// http://maven.apache.org/guides/mini/guide-ibiblio-upload.html
// java -agentlib:yjpagent=sampling,noj2ee,dir=C:\temp\Snapshots org.h2.test.bench.TestPerformance -init -db 1
// Check if new Hibernate dialect for H2 is ok
// http://opensource.atlassian.com/projects/hibernate/browse/HHH-2300
// open JPA test - submit patch // open JPA test - submit patch
// d:\data\h2test\openjpa\openjpa-persistence-jdbc\src\test\resources\META-INF\persistence.xml // d:\data\h2test\openjpa\openjpa-persistence-jdbc\src\test\resources\META-INF\persistence.xml
......
...@@ -7,16 +7,17 @@ db5 = HSQLDB, org.hsqldb.jdbcDriver, jdbc:hsqldb:hsql://localhost/xdb, sa ...@@ -7,16 +7,17 @@ db5 = HSQLDB, org.hsqldb.jdbcDriver, jdbc:hsqldb:hsql://localhost/xdb, sa
db6 = Derby, org.apache.derby.jdbc.ClientDriver, jdbc:derby://localhost/data/testServ;create=true, sa, sa db6 = Derby, org.apache.derby.jdbc.ClientDriver, jdbc:derby://localhost/data/testServ;create=true, sa, sa
db7 = PostgreSQL, org.postgresql.Driver, jdbc:postgresql:test, sa, sa db7 = PostgreSQL, org.postgresql.Driver, jdbc:postgresql:test, sa, sa
db8 = MySQL, com.mysql.jdbc.Driver, jdbc:mysql://localhost/test?jdbcCompliantTruncation=false, sa, sa db8 = MySQL, com.mysql.jdbc.Driver, jdbc:mysql://localhost/test?jdbcCompliantTruncation=false, sa, sa
db9 = Firebird, org.firebirdsql.jdbc.FBDriver, jdbc:firebirdsql:localhost:c:/temp/firebird/test, sysdba, masterkey
xdb9 = OneDollarDB, in.co.daffodil.db.jdbc.DaffodilDBDriver, jdbc:daffodilDB_embedded:school;path=C:/temp;create=true, sa #db2 = Firebird, org.firebirdsql.jdbc.FBDriver, jdbc:firebirdsql:localhost:c:/temp/firebird/test, sysdba, masterkey
xdb10 = Oracle, oracle.jdbc.driver.OracleDriver, jdbc:oracle:thin:@localhost:1521:test, scott, tiger #db2 = Oracle, oracle.jdbc.driver.OracleDriver, jdbc:oracle:thin:@localhost:1521:XE, client, client
xdb11 = DB2, COM.ibm.db2.jdbc.net.DB2Driver, jdbc:db2://localhost/test, test, test #db2 = OneDollarDB, in.co.daffodil.db.jdbc.DaffodilDBDriver, jdbc:daffodilDB_embedded:school;path=C:/temp;create=true, sa
xdb12 = MSSQLServer, com.microsoft.jdbc.sqlserver.SQLServerDriver, jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=test, test, test #db2 = DB2, COM.ibm.db2.jdbc.net.DB2Driver, jdbc:db2://localhost/test, test, test
#db2 = MSSQLServer, com.microsoft.jdbc.sqlserver.SQLServerDriver, jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=test, test, test
firebirdsql.datetime = TIMESTAMP firebirdsql.datetime = TIMESTAMP
postgresql.datetime = TIMESTAMP postgresql.datetime = TIMESTAMP
derby.datetime = TIMESTAMP derby.datetime = TIMESTAMP
oracle.datetime = TIMESTAMP
test1 = org.h2.test.bench.BenchSimple test1 = org.h2.test.bench.BenchSimple
test2 = org.h2.test.bench.BenchA test2 = org.h2.test.bench.BenchA
......
...@@ -169,7 +169,7 @@ public class TestCases extends TestBase { ...@@ -169,7 +169,7 @@ public class TestCases extends TestBase {
error("query still running"); error("query still running");
} }
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
if(time > 1000) { if(time > 5000) {
error("closing took " + time); error("closing took " + time);
} }
deleteDb("cases"); deleteDb("cases");
......
...@@ -15,6 +15,7 @@ import java.sql.Connection; ...@@ -15,6 +15,7 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Savepoint;
import java.sql.Statement; import java.sql.Statement;
import java.util.Random; import java.util.Random;
...@@ -32,6 +33,8 @@ public class TestLob extends TestBase { ...@@ -32,6 +33,8 @@ public class TestLob extends TestBase {
if(config.memory) { if(config.memory) {
return; return;
} }
testLobTransactions();
testLobRollbackStop();
testLobCopy(); testLobCopy();
testLobHibernate(); testLobHibernate();
testLobCopy(false); testLobCopy(false);
...@@ -47,6 +50,103 @@ public class TestLob extends TestBase { ...@@ -47,6 +50,103 @@ public class TestLob extends TestBase {
testJavaObject(); testJavaObject();
} }
private void testLobTransactions() throws Exception {
if(config.logMode == 0) {
return;
}
deleteDb("lob");
Connection conn = reconnect(null);
conn.createStatement().execute("CREATE TABLE TEST(ID IDENTITY, DATA CLOB, DATA2 VARCHAR)");
conn.setAutoCommit(false);
Random random = new Random(1);
int rows = 0;
Savepoint sp = null;
int len = getSize(100, 2000);
for(int i=0; i<len; i++) {
switch(random.nextInt(10)) {
case 0:
// System.out.println("insert");
conn.createStatement().execute("INSERT INTO TEST(DATA, DATA2) VALUES('"+i+"' || SPACE(10000), '"+i+"')");
rows++;
break;
case 1:
if(rows > 0) {
// System.out.println("delete");
conn.createStatement().execute("DELETE FROM TEST WHERE ID=" + random.nextInt(rows));
}
break;
case 2:
if(rows > 0) {
// System.out.println("update");
conn.createStatement().execute("UPDATE TEST SET DATA='x' || DATA, DATA2='x' || DATA2 WHERE ID=" + random.nextInt(rows));
}
break;
case 3:
if(rows > 0) {
// System.out.println("commit");
conn.commit();
sp = null;
}
break;
case 4:
if(rows > 0) {
// System.out.println("rollback");
conn.rollback();
sp = null;
}
break;
case 5:
// System.out.println("savepoint");
sp = conn.setSavepoint();
break;
case 6:
if(sp != null) {
// System.out.println("rollback to savepoint");
conn.rollback(sp);
}
break;
case 7:
if(rows > 0) {
// System.out.println("shutdown");
conn.createStatement().execute("CHECKPOINT");
conn.createStatement().execute("SHUTDOWN IMMEDIATELY");
conn = reconnect(null);
conn.setAutoCommit(false);
sp = null;
}
break;
}
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST");
while(rs.next()) {
String d1 = rs.getString("DATA").trim();
String d2 = rs.getString("DATA2").trim();
check(d1, d2);
}
}
conn.close();
}
private void testLobRollbackStop() throws Exception {
if(config.logMode == 0) {
return;
}
deleteDb("lob");
Connection conn = reconnect(null);
conn.createStatement().execute("CREATE TABLE TEST(ID INT PRIMARY KEY, DATA CLOB)");
conn.createStatement().execute("INSERT INTO TEST VALUES(1, SPACE(10000))");
conn.setAutoCommit(false);
conn.createStatement().execute("DELETE FROM TEST");
conn.createStatement().execute("CHECKPOINT");
conn.createStatement().execute("SHUTDOWN IMMEDIATELY");
conn = reconnect(null);
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST");
check(rs.next());
rs.getInt(1);
check(rs.getString(2).length(), 10000);
conn.close();
}
private void testLobCopy() throws Exception { private void testLobCopy() throws Exception {
deleteDb("lob"); deleteDb("lob");
Connection conn = reconnect(null); Connection conn = reconnect(null);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论