提交 9cf66529 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 433bf879
...@@ -11,7 +11,7 @@ Advanced Topics ...@@ -11,7 +11,7 @@ Advanced Topics
<table class="content"><tr class="content"><td class="content"><div class="contentDiv"> <table class="content"><tr class="content"><td class="content"><div class="contentDiv">
<h1>Advanced Topics</h1> <h1>Advanced Topics</h1>
<a href="#resultsets"> <a href="#result_sets">
Result Sets</a><br> Result Sets</a><br>
<a href="#large_objects"> <a href="#large_objects">
Large Objects</a><br> Large Objects</a><br>
...@@ -46,7 +46,7 @@ Advanced Topics ...@@ -46,7 +46,7 @@ Advanced Topics
<a href="#glossary_links"> <a href="#glossary_links">
Glossary and Links</a><br> Glossary and Links</a><br>
<br><a name="resultsets"></a> <br><a name="result_sets"></a>
<h2>Result Sets</h2> <h2>Result Sets</h2>
<h3>Limiting the Number of Rows</h3> <h3>Limiting the Number of Rows</h3>
...@@ -85,7 +85,7 @@ CREATE LINKED TABLE LINK('org.postgresql.Driver', 'jdbc:postgresql:test', 'sa', ...@@ -85,7 +85,7 @@ CREATE LINKED TABLE LINK('org.postgresql.Driver', 'jdbc:postgresql:test', 'sa',
</pre> </pre>
It is then possible to access the table in the usual way. It is then possible to access the table in the usual way.
There is a restriction when inserting data to this table: When inserting or updating rows into the table, There is a restriction when inserting data to this table: When inserting or updating rows into the table,
NULL values and values that are not set in the insert statement are both inserted as NULL. NULL and values that are not set in the insert statement are both inserted as NULL.
This may not have the desired effect if a default value in the target table is other than NULL. This may not have the desired effect if a default value in the target table is other than NULL.
<br><a name="transaction_isolation"></a> <br><a name="transaction_isolation"></a>
...@@ -358,7 +358,7 @@ In Java, there are two ways how this can be achieved: ...@@ -358,7 +358,7 @@ In Java, there are two ways how this can be achieved:
</p> </p>
<ul> <ul>
<li>FileDescriptor.sync(). The documentation says that this will force all system buffers to synchronize with the underlying device. <li>FileDescriptor.sync(). The documentation says that this will force all system buffers to synchronize with the underlying device.
Sync is supposed to return after all in-memory modified copies of buffers associated with this FileDesecriptor Sync is supposed to return after all in-memory modified copies of buffers associated with this FileDescriptor
have been written to the physical medium. have been written to the physical medium.
<li>FileChannel.force() (since JDK 1.4). This method is supposed to force any updates to this channel's file <li>FileChannel.force() (since JDK 1.4). This method is supposed to force any updates to this channel's file
to be written to the storage device that contains it. to be written to the storage device that contains it.
...@@ -643,7 +643,7 @@ custom certificates are supported as well. ...@@ -643,7 +643,7 @@ custom certificates are supported as well.
<br><a name="uuid"></a> <br><a name="uuid"></a>
<h2>Universally Unique Identifiers (UUID)</h2> <h2>Universally Unique Identifiers (UUID)</h2>
This database supports UUIDs. Also upported is a function to create new UUIDs using This database supports the UUIDs. Also supported is a function to create new UUIDs using
a cryptographically strong pseudo random number generator. a cryptographically strong pseudo random number generator.
With random UUIDs, the chance of two having the same value can be calculated With random UUIDs, the chance of two having the same value can be calculated
using the probability theory. See also 'Birthday Paradox'. using the probability theory. See also 'Birthday Paradox'.
......
...@@ -14,10 +14,8 @@ Frequently Asked Questions ...@@ -14,10 +14,8 @@ Frequently Asked Questions
<h3>Are there any known bugs? When is the next release?</h3> <h3>Are there any known bugs? When is the next release?</h3>
Usually, bugs get fixes as they are found. There is a release every few weeks. Usually, bugs get fixes as they are found. There is a release every few weeks.
The next release is planned for
2007-01-29.
Here is the list of known and confirmed issues as of Here is the list of known and confirmed issues as of
2007-01-17: 2007-01-30:
<ul> <ul>
<li>Can not build using ant with JDK 1.3 at the moment. However most things are fixed. <li>Can not build using ant with JDK 1.3 at the moment. However most things are fixed.
<li>Some problems have been found with right outer join. Internally, it is converted to left outer join, which <li>Some problems have been found with right outer join. Internally, it is converted to left outer join, which
...@@ -43,7 +41,7 @@ some problems that have not yet been found. ...@@ -43,7 +41,7 @@ some problems that have not yet been found.
Areas that are not completely tested: Areas that are not completely tested:
<ul> <ul>
<li>Platforms other than Windows XP and the Sun JVM 1.4 <li>Platforms other than Windows XP and the Sun JVM 1.4
<li>Data types BLOBs / CLOBs, VARCHAR_IGNORECASE, OTHER <li>Data types BLOB, CLOB, VARCHAR_IGNORECASE, OTHER
<li>Cluster mode, 2-Phase Commit, Savepoints <li>Cluster mode, 2-Phase Commit, Savepoints
<li>Server mode (well tested, but not as well as Embedded mode) <li>Server mode (well tested, but not as well as Embedded mode)
<li>Multi-Threading and using multiple connections <li>Multi-Threading and using multiple connections
......
...@@ -349,7 +349,7 @@ This is achieved using different database URLs. The settings in the URLs are not ...@@ -349,7 +349,7 @@ This is achieved using different database URLs. The settings in the URLs are not
<td>In-Memory (named)</td> <td>In-Memory (named)</td>
<td> <td>
jdbc:h2:mem:&lt;databaseName&gt;<br> jdbc:h2:mem:&lt;databaseName&gt;<br>
jdbc:h2:mem:imdb1 jdbc:h2:mem:test_mem
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -816,14 +816,14 @@ Here is the list of currently supported modes and the difference to the regular ...@@ -816,14 +816,14 @@ Here is the list of currently supported modes and the difference to the regular
<tr><td> <tr><td>
PostgreSQL PostgreSQL
</td><td> </td><td>
Concatenation of a NULL value with another value results in NULL. Concatenation of a NULL with another value results in NULL.
Usually, the NULL is treated as an empty string if only one of the operators is NULL, Usually, the NULL is treated as an empty string if only one of the operators is NULL,
and NULL is only returned if both values are NULL. and NULL is only returned if both values are NULL.
</td></tr> </td></tr>
<tr><td> <tr><td>
MySQL MySQL
</td><td> </td><td>
When inserting data, if a column is defined to be NOT NULL and a null value is inserted, When inserting data, if a column is defined to be NOT NULL and NULL is inserted,
then a 0 (or empty string, or the current timestamp for timestamp columns) value is used. then a 0 (or empty string, or the current timestamp for timestamp columns) value is used.
Usually, this operation is not allowed and an exception is thrown. Usually, this operation is not allowed and an exception is thrown.
</td></tr> </td></tr>
...@@ -1024,7 +1024,7 @@ secure. A way to create good passwords that can be remembered is, take the first ...@@ -1024,7 +1024,7 @@ secure. A way to create good passwords that can be remembered is, take the first
letters of a sentence, use upper and lower case characters, and creatively include special characters. letters of a sentence, use upper and lower case characters, and creatively include special characters.
Example: Example:
</p><p> </p><p>
i'sE2rTpiUKtt (it's easy to remember this password if you know the trick) i'sE2rtPiUKtT (it's easy to remember this password if you know the trick)
</p> </p>
<h3>Passwords: Using Char Arrays instead of Strings</h3> <h3>Passwords: Using Char Arrays instead of Strings</h3>
...@@ -1096,7 +1096,7 @@ public class Function { ...@@ -1096,7 +1096,7 @@ public class Function {
</pre> </pre>
The Java function must be registered in the database by calling CREATE ALIAS: The Java function must be registered in the database by calling CREATE ALIAS:
<pre> <pre>
CREATE ALIAS ISPRIME FOR "org.h2.samples.Function.isPrime" CREATE ALIAS IS_PRIME FOR "org.h2.samples.Function.isPrime"
</pre> </pre>
For a complete sample application, see src/test/org/h2/samples/Function.java. For a complete sample application, see src/test/org/h2/samples/Function.java.
......
...@@ -137,7 +137,7 @@ Welcome to H2, the free SQL database. The main feature of H2 are: ...@@ -137,7 +137,7 @@ Welcome to H2, the free SQL database. The main feature of H2 are:
server/web/res/_text_*.properties). Or click on the PayPal button below to<br> server/web/res/_text_*.properties). Or click on the PayPal button below to<br>
donate money. You will be listed as a supporter: donate money. You will be listed as a supporter:
</p> </p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="cmd" value="_s-xclick">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" border="0" name="submit" alt="Zahlen Sie mit PayPal - schnell, kostenlos und sicher!"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" border="0" name="submit" alt="Zahlen Sie mit PayPal - schnell, kostenlos und sicher!">
<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1"> <img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1">
......
...@@ -62,31 +62,6 @@ In most cases H2 is a lot faster than all other ...@@ -62,31 +62,6 @@ In most cases H2 is a lot faster than all other
<tr><td>Statement per Second</td><td>#</td><td>9761</td><td>4546</td><td>1975</td><td>5259</td><td>7823</td></tr> <tr><td>Statement per Second</td><td>#</td><td>9761</td><td>4546</td><td>1975</td><td>5259</td><td>7823</td></tr>
</table> </table>
<h3>PolePosition Benchmark</h3>
<table border="1" class="bar">
<tr><th>Test Case</th><th>Unit</th><th>H2</th><th>HSQLDB</th><th>MySQL</th></tr>
<tr><td>Melbourne write</td><td>ms</td><td>369</td><td>249</td><td>2022</td></tr>
<tr><td>Melbourne read</td><td>ms</td><td>47</td><td>49</td><td>93</td></tr>
<tr><td>Melbourne read_hot</td><td>ms</td><td>24</td><td>43</td><td>95</td></tr>
<tr><td>Melbourne delete</td><td>ms</td><td>147</td><td>133</td><td>176</td></tr>
<tr><td>Sepang write</td><td>ms</td><td>965</td><td>1201</td><td>3213</td></tr>
<tr><td>Sepang read</td><td>ms</td><td>765</td><td>948</td><td>3455</td></tr>
<tr><td>Sepang read_hot</td><td>ms</td><td>789</td><td>859</td><td>3563</td></tr>
<tr><td>Sepang delete</td><td>ms</td><td>1384</td><td>1596</td><td>6214</td></tr>
<tr><td>Bahrain write</td><td>ms</td><td>1186</td><td>1387</td><td>6904</td></tr>
<tr><td>Bahrain query_indexed_string</td><td>ms</td><td>336</td><td>170</td><td>693</td></tr>
<tr><td>Bahrain query_string</td><td>ms</td><td>18064</td><td>39703</td><td>41243</td></tr>
<tr><td>Bahrain query_indexed_int</td><td>ms</td><td>104</td><td>134</td><td>678</td></tr>
<tr><td>Bahrain update</td><td>ms</td><td>191</td><td>87</td><td>159</td></tr>
<tr><td>Bahrain delete</td><td>ms</td><td>1215</td><td>729</td><td>6812</td></tr>
<tr><td>Imola retrieve</td><td>ms</td><td>198</td><td>194</td><td>4036</td></tr>
<tr><td>Barcelona write</td><td>ms</td><td>413</td><td>832</td><td>3191</td></tr>
<tr><td>Barcelona read</td><td>ms</td><td>119</td><td>160</td><td>1177</td></tr>
<tr><td>Barcelona query</td><td>ms</td><td>20</td><td>5169</td><td>101</td></tr>
<tr><td>Barcelona delete</td><td>ms</td><td>388</td><td>319</td><td>3287</td></tr>
<tr><td>Total</td><td>ms</td><td>26724</td><td>53962</td><td>87112</td></tr>
</table>
<h3>Benchmark Results and Comments</h3> <h3>Benchmark Results and Comments</h3>
<h4>H2</h4> <h4>H2</h4>
...@@ -218,6 +193,35 @@ and for each step a new connection is opened and then closed. ...@@ -218,6 +193,35 @@ and for each step a new connection is opened and then closed.
That means the Open/Close time listed is for opening a connection That means the Open/Close time listed is for opening a connection
if the database is already in use. if the database is already in use.
<h3>PolePosition Benchmark</h3>
<p>
The PolePosition is an open source benchmark. The algorithms are all quite simple.
It was developed / sponsored by db4o.
</p>
<table border="1" class="bar">
<tr><th>Test Case</th><th>Unit</th><th>H2</th><th>HSQLDB</th><th>MySQL</th></tr>
<tr><td>Melbourne write</td><td>ms</td><td>369</td><td>249</td><td>2022</td></tr>
<tr><td>Melbourne read</td><td>ms</td><td>47</td><td>49</td><td>93</td></tr>
<tr><td>Melbourne read_hot</td><td>ms</td><td>24</td><td>43</td><td>95</td></tr>
<tr><td>Melbourne delete</td><td>ms</td><td>147</td><td>133</td><td>176</td></tr>
<tr><td>Sepang write</td><td>ms</td><td>965</td><td>1201</td><td>3213</td></tr>
<tr><td>Sepang read</td><td>ms</td><td>765</td><td>948</td><td>3455</td></tr>
<tr><td>Sepang read_hot</td><td>ms</td><td>789</td><td>859</td><td>3563</td></tr>
<tr><td>Sepang delete</td><td>ms</td><td>1384</td><td>1596</td><td>6214</td></tr>
<tr><td>Bahrain write</td><td>ms</td><td>1186</td><td>1387</td><td>6904</td></tr>
<tr><td>Bahrain query_indexed_string</td><td>ms</td><td>336</td><td>170</td><td>693</td></tr>
<tr><td>Bahrain query_string</td><td>ms</td><td>18064</td><td>39703</td><td>41243</td></tr>
<tr><td>Bahrain query_indexed_int</td><td>ms</td><td>104</td><td>134</td><td>678</td></tr>
<tr><td>Bahrain update</td><td>ms</td><td>191</td><td>87</td><td>159</td></tr>
<tr><td>Bahrain delete</td><td>ms</td><td>1215</td><td>729</td><td>6812</td></tr>
<tr><td>Imola retrieve</td><td>ms</td><td>198</td><td>194</td><td>4036</td></tr>
<tr><td>Barcelona write</td><td>ms</td><td>413</td><td>832</td><td>3191</td></tr>
<tr><td>Barcelona read</td><td>ms</td><td>119</td><td>160</td><td>1177</td></tr>
<tr><td>Barcelona query</td><td>ms</td><td>20</td><td>5169</td><td>101</td></tr>
<tr><td>Barcelona delete</td><td>ms</td><td>388</td><td>319</td><td>3287</td></tr>
<tr><td>Total</td><td>ms</td><td>26724</td><td>53962</td><td>87112</td></tr>
</table>
<br><a name="application_profiling"></a> <br><a name="application_profiling"></a>
<h2>Application Profiling</h2> <h2>Application Profiling</h2>
......
...@@ -62,21 +62,21 @@ function listWords(value, open) { ...@@ -62,21 +62,21 @@ function listWords(value, open) {
word = wordRef.split("=")[0]; word = wordRef.split("=")[0];
var tr = table.insertRow(x++); var tr = table.insertRow(x++);
var td = document.createElement('td'); var td = document.createElement('td');
var tdc = document.createAttribute('class'); var tdClass = document.createAttribute('class');
tdc.nodeValue = 'searchKeyword'; tdClass.nodeValue = 'searchKeyword';
td.setAttributeNode(tdc); td.setAttributeNode(tdClass);
var ah = document.createElement('a'); var ah = document.createElement('a');
var hre = document.createAttribute('href'); var href = document.createAttribute('href');
hre.nodeValue = 'javascript:set("' + word + '");'; href.nodeValue = 'javascript:set("' + word + '");';
var link = document.createTextNode(word); var link = document.createTextNode(word);
ah.setAttributeNode(hre); ah.setAttributeNode(href);
ah.appendChild(link); ah.appendChild(link);
td.appendChild(ah); td.appendChild(ah);
tr.appendChild(td); tr.appendChild(td);
pis = wordRef.split("=")[1].split(","); piList = wordRef.split("=")[1].split(",");
if(count<20 || open==word) { if(count<20 || open==word) {
x = addReferences(x, pis, word); x = addReferences(x, piList, word);
} }
} }
} }
...@@ -129,10 +129,10 @@ function listAnd(keywords) { ...@@ -129,10 +129,10 @@ function listAnd(keywords) {
for(var j=0; j<words.length; j++) { for(var j=0; j<words.length; j++) {
var wordRef = words[j]; var wordRef = words[j];
if(wordRef.toLowerCase().indexOf(value)==0) { if(wordRef.toLowerCase().indexOf(value)==0) {
pis = wordRef.split("=")[1].split(","); piList = wordRef.split("=")[1].split(",");
var w=1; var w=1;
for(var k=0; k<pis.length; k++) { for(var k=0; k<piList.length; k++) {
var pi = pis[k]; var pi = piList[k];
if(pi.charAt(0) == 't') { if(pi.charAt(0) == 't') {
pi = pi.substring(1); pi = pi.substring(1);
w=10000; w=10000;
...@@ -155,36 +155,36 @@ function listAnd(keywords) { ...@@ -155,36 +155,36 @@ function listAnd(keywords) {
} }
var x = 0; var x = 0;
var table = document.getElementById('result'); var table = document.getElementById('result');
var pis = new Array(); var piList = new Array();
var piw = new Array(); var piWeight = new Array();
for(var i=0; i<pages.length; i++) { for(var i=0; i<pages.length; i++) {
if(count[i] >= keywords.length) { if(count[i] >= keywords.length) {
pis[x] = '' + i; piList[x] = '' + i;
piw[x] = weight[i]; piWeight[x] = weight[i];
x++; x++;
} }
} }
// sort // sort
for (var i = 1, j; i < x; i++) { for (var i = 1, j; i < x; i++) {
var tw = piw[i]; var tw = piWeight[i];
var ti = pis[i]; var ti = piList[i];
for (j = i - 1; j >= 0 && (piw[j] < tw); j--) { for (j = i - 1; j >= 0 && (piWeight[j] < tw); j--) {
piw[j + 1] = piw[j]; piWeight[j + 1] = piWeight[j];
pis[j + 1] = pis[j]; piList[j + 1] = piList[j];
} }
piw[j + 1] = tw; piWeight[j + 1] = tw;
pis[j + 1] = ti; piList[j + 1] = ti;
} }
addReferences(0, pis, keywords); addReferences(0, piList, keywords);
if(pis.length == 0) { if(piList.length == 0) {
noResults(table); noResults(table);
} }
} }
function addReferences(x, pis, word) { function addReferences(x, piList, word) {
var table = document.getElementById('result'); var table = document.getElementById('result');
for(var j=0; j<pis.length; j++) { for(var j=0; j<piList.length; j++) {
var pi = pis[j]; var pi = piList[j];
if(pi.charAt(0) == 't') { if(pi.charAt(0) == 't') {
pi = pi.substring(1); pi = pi.substring(1);
} else if(pi.charAt(0) == 'h') { } else if(pi.charAt(0) == 'h') {
...@@ -194,18 +194,18 @@ function addReferences(x, pis, word) { ...@@ -194,18 +194,18 @@ function addReferences(x, pis, word) {
} }
var tr = table.insertRow(x++); var tr = table.insertRow(x++);
var td = document.createElement('td'); var td = document.createElement('td');
var tdc = document.createAttribute('class'); var tdClass = document.createAttribute('class');
tdc.nodeValue = 'searchLink'; tdClass.nodeValue = 'searchLink';
td.setAttributeNode(tdc); td.setAttributeNode(tdClass);
var ah = document.createElement('a'); var ah = document.createElement('a');
var hre = document.createAttribute('href'); var href = document.createAttribute('href');
var thisLink = 'javascript:go(' + pi + ', "' + word + '")'; var thisLink = 'javascript:go(' + pi + ', "' + word + '")';
if(firstLink==null) { if(firstLink==null) {
firstLink = pi; firstLink = pi;
firstLinkWord = word; firstLinkWord = word;
} }
hre.nodeValue = thisLink; href.nodeValue = thisLink;
ah.setAttributeNode(hre); ah.setAttributeNode(href);
var page = pages[pi]; var page = pages[pi];
var link = document.createTextNode(page.title); var link = document.createTextNode(page.title);
ah.appendChild(link); ah.appendChild(link);
...@@ -240,9 +240,9 @@ function replaceOtherChars(s) { ...@@ -240,9 +240,9 @@ function replaceOtherChars(s) {
function noResults(table) { function noResults(table) {
var tr = table.insertRow(0); var tr = table.insertRow(0);
var td = document.createElement('td'); var td = document.createElement('td');
var tdc = document.createAttribute('class'); var tdClass = document.createAttribute('class');
tdc.nodeValue = 'searchKeyword'; tdClass.nodeValue = 'searchKeyword';
td.setAttributeNode(tdc); td.setAttributeNode(tdClass);
var text = document.createTextNode('No results found'); var text = document.createTextNode('No results found');
td.appendChild(text); td.appendChild(text);
tr.appendChild(td); tr.appendChild(td);
......
...@@ -27,7 +27,7 @@ Tutorial ...@@ -27,7 +27,7 @@ Tutorial
CSV (Comma Separated Values) Support</a><br> CSV (Comma Separated Values) Support</a><br>
<a href="#upgrade_backup_restore"> <a href="#upgrade_backup_restore">
Upgrade, Backup, and Restore</a><br> Upgrade, Backup, and Restore</a><br>
<a href="#openoffice"> <a href="#open_office">
Using OpenOffice Base</a><br> Using OpenOffice Base</a><br>
<br><a name="tutorial_starting_h2_console"></a> <br><a name="tutorial_starting_h2_console"></a>
...@@ -384,8 +384,8 @@ SimpleResultSet rs = new SimpleResultSet(); ...@@ -384,8 +384,8 @@ SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addColumn("EMAIL", Types.VARCHAR, 255, 0); rs.addColumn("EMAIL", Types.VARCHAR, 255, 0);
rs.addColumn("PHONE", Types.VARCHAR, 255, 0); rs.addColumn("PHONE", Types.VARCHAR, 255, 0);
rs.addRow(new String[]{"Bob Meier", "bob.meier@abcde.fgh", "+41123456789"}); rs.addRow(new String[]{"Bob Meier", "bob.meier@abcde.abc", "+41123456789"});
rs.addRow(new String[]{"John Jones", "johnjones@abcde.fgh", "+41976543210"}); rs.addRow(new String[]{"John Jones", "john.jones@abcde.abc", "+41976543210"});
Csv.write("test.csv", rs, null); Csv.write("test.csv", rs, null);
</pre> </pre>
...@@ -438,7 +438,7 @@ SQL script files may contain references to other script files, in the form of ...@@ -438,7 +438,7 @@ SQL script files may contain references to other script files, in the form of
RUNSCRIPT commands. However, when using the server mode, the references script files RUNSCRIPT commands. However, when using the server mode, the references script files
need to be available on the server side. need to be available on the server side.
<br><a name="openoffice"></a> <br><a name="open_office"></a>
<h2>Using OpenOffice Base</h2> <h2>Using OpenOffice Base</h2>
OpenOffice.org Base supports database access over the JDBC API. To connect to a H2 database OpenOffice.org Base supports database access over the JDBC API. To connect to a H2 database
using OpenOffice Base, you first need to add the JDBC driver to OpenOffice. using OpenOffice Base, you first need to add the JDBC driver to OpenOffice.
......
...@@ -1705,7 +1705,9 @@ public class Parser { ...@@ -1705,7 +1705,9 @@ public class Parser {
Sequence sequence = database.getSchema(schemaName).findSequence(objectName); Sequence sequence = database.getSchema(schemaName).findSequence(objectName);
if(sequence != null) { if(sequence != null) {
Function function = Function.getFunction(database, "CURRVAL"); Function function = Function.getFunction(database, "CURRVAL");
function.setParameter(0, ValueExpression.get(ValueString.get(objectName))); function.setParameter(0, ValueExpression.get(ValueString.get(schemaName)));
function.setParameter(1, ValueExpression.get(ValueString.get(objectName)));
function.doneWithParameters();
return function; return function;
} }
} }
...@@ -1931,6 +1933,7 @@ public class Parser { ...@@ -1931,6 +1933,7 @@ public class Parser {
function.setParameter(0, when); function.setParameter(0, when);
function.setParameter(1, then); function.setParameter(1, then);
function.setParameter(2, elsePart); function.setParameter(2, elsePart);
function.doneWithParameters();
return function; return function;
} }
...@@ -3587,12 +3590,12 @@ public class Parser { ...@@ -3587,12 +3590,12 @@ public class Parser {
command.setStartWith(start); command.setStartWith(start);
return command; return command;
} else if(readIf("SELECTIVITY")) { } else if(readIf("SELECTIVITY")) {
int sel = getPositiveInt(); int selectivity = getPositiveInt();
AlterTableAlterColumn command = new AlterTableAlterColumn(session, tableSchema); AlterTableAlterColumn command = new AlterTableAlterColumn(session, tableSchema);
command.setTable(table); command.setTable(table);
command.setType(AlterTableAlterColumn.SELECTIVITY); command.setType(AlterTableAlterColumn.SELECTIVITY);
command.setOldColumn(column); command.setOldColumn(column);
command.setStartWith(sel); command.setStartWith(selectivity);
return command; return command;
} else { } else {
Column newColumn = parseColumnForTable(columnName); Column newColumn = parseColumnForTable(columnName);
......
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.command.dml; package org.h2.command.dml;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -50,38 +54,32 @@ public class Backup extends Prepared { ...@@ -50,38 +54,32 @@ public class Backup extends Prepared {
name = FileUtils.getFileName(name); name = FileUtils.getFileName(name);
FileOutputStream zip = new FileOutputStream(fileName); FileOutputStream zip = new FileOutputStream(fileName);
ZipOutputStream out = new ZipOutputStream(zip); ZipOutputStream out = new ZipOutputStream(zip);
out.putNextEntry(new ZipEntry(name + Constants.SUFFIX_DATA_FILE));
DiskFile file = db.getDataFile();
LogSystem log = db.getLog(); LogSystem log = db.getLog();
try { try {
log.flush();
log.updateKeepFiles(1); log.updateKeepFiles(1);
int pos = -1; String fn = db.getName() + Constants.SUFFIX_DATA_FILE;
int max = file.getReadCount(); backupDiskFile(out, fn, db.getDataFile());
while(true) { fn = db.getName() + Constants.SUFFIX_INDEX_FILE;
pos = file.readDirect(pos, out); backupDiskFile(out, fn, db.getIndexFile());
if(pos < 0) {
break;
}
db.setProgress(DatabaseEventListener.STATE_BACKUP_FILE, name, pos, max);
}
out.closeEntry();
ObjectArray list = log.getActiveLogFiles(); ObjectArray list = log.getActiveLogFiles();
max = list.size(); int max = list.size();
for(int i=0; i<list.size(); i++) { // synchronize on the database, to avoid concurrent temp file creation / deletion / backup
LogFile lf = (LogFile) list.get(i); synchronized(db.getLobSyncObject()) {
String fn = lf.getFileName(); for(int i=0; i<list.size(); i++) {
out.putNextEntry(new ZipEntry(FileUtils.getFileName(fn))); LogFile lf = (LogFile) list.get(i);
FileInputStream in = new FileInputStream(fn); fn = lf.getFileName();
IOUtils.copyAndCloseInput(in, out); backupFile(out, fn);
out.closeEntry(); db.setProgress(DatabaseEventListener.STATE_BACKUP_FILE, name, i, max);
db.setProgress(DatabaseEventListener.STATE_BACKUP_FILE, name, i, max); }
} ArrayList fileList = FileBase.getDatabaseFiles(db.getDatabasePath(), name, true);
int todoLockDatabaseSomehow; for(int i=0; i<fileList.size(); i++) {
ArrayList fileList = FileBase.getDatabaseFiles(db.getDatabasePath(), name, true); fn = (String) fileList.get(i);
for(int i=0; i<fileList.size(); i++) { if(fn.endsWith(Constants.SUFFIX_HASH_FILE) || fn.endsWith(Constants.SUFFIX_LOB_FILE)) {
String fn = (String) fileList.get(i); backupFile(out, fn);
}
}
} }
int todoCopyLobFiles;
out.close(); out.close();
zip.close(); zip.close();
} finally { } finally {
...@@ -91,6 +89,29 @@ public class Backup extends Prepared { ...@@ -91,6 +89,29 @@ public class Backup extends Prepared {
throw Message.convert(e); throw Message.convert(e);
} }
} }
private void backupDiskFile(ZipOutputStream out, String fileName, DiskFile file) throws SQLException, IOException {
Database db = session.getDatabase();
fileName = FileUtils.getFileName(fileName);
out.putNextEntry(new ZipEntry(fileName));
int pos = -1;
int max = file.getReadCount();
while(true) {
pos = file.readDirect(pos, out);
if(pos < 0) {
break;
}
db.setProgress(DatabaseEventListener.STATE_BACKUP_FILE, fileName, pos, max);
}
out.closeEntry();
}
private void backupFile(ZipOutputStream out, String fn) throws SQLException, IOException {
out.putNextEntry(new ZipEntry(FileUtils.getFileName(fn)));
FileInputStream in = new FileInputStream(fn);
IOUtils.copyAndCloseInput(in, out);
out.closeEntry();
}
public boolean isTransactional() { public boolean isTransactional() {
return true; return true;
......
...@@ -83,8 +83,10 @@ public abstract class Query extends Prepared { ...@@ -83,8 +83,10 @@ public abstract class Query extends Prepared {
if(lastResult != null && limit == lastLimit) { if(lastResult != null && limit == lastLimit) {
if(sameResultAsLast(session, params, lastParameters, lastEvaluated)) { if(sameResultAsLast(session, params, lastParameters, lastEvaluated)) {
lastResult = lastResult.createShallowCopy(session); lastResult = lastResult.createShallowCopy(session);
lastResult.reset(); if(lastResult != null) {
return lastResult; lastResult.reset();
return lastResult;
}
} }
} }
lastParameters = params; lastParameters = params;
......
...@@ -201,4 +201,8 @@ public class ScriptBase extends Prepared implements DataHandler { ...@@ -201,4 +201,8 @@ public class ScriptBase extends Prepared implements DataHandler {
this.compressionAlgorithm = algorithm; this.compressionAlgorithm = algorithm;
} }
public Object getLobSyncObject() {
return this;
}
} }
...@@ -4,19 +4,12 @@ ...@@ -4,19 +4,12 @@
*/ */
package org.h2.command.dml; package org.h2.command.dml;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import org.h2.command.Prepared; import org.h2.command.Prepared;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.store.DiskFile;
/** /**
...@@ -124,32 +117,6 @@ public class TransactionCommand extends Prepared { ...@@ -124,32 +117,6 @@ public class TransactionCommand extends Prepared {
return 0; return 0;
} }
private void backupTo(String fileName) throws SQLException {
int todoMoveToOwnCommand;
try {
FileOutputStream fileOut = new FileOutputStream("test.zip");
ZipOutputStream out = new ZipOutputStream(fileOut);
out.putNextEntry(new ZipEntry("test.data.db"));
DiskFile file = session.getDatabase().getDataFile();
try {
session.getDatabase().getLog().updateKeepFiles(1);
int pos = -1;
while(true) {
pos = file.readDirect(pos, out);
if(pos < 0) {
break;
}
}
out.close();
fileOut.close();
} finally {
session.getDatabase().getLog().updateKeepFiles(-1);
}
} catch(IOException e) {
throw Message.convert(e);
}
}
public boolean isTransactional() { public boolean isTransactional() {
return true; return true;
} }
......
...@@ -49,11 +49,10 @@ public class CompressLZF implements Compressor { ...@@ -49,11 +49,10 @@ public class CompressLZF implements Compressor {
return Compressor.LZF; return Compressor.LZF;
} }
static final int HLOG = 14; private static final int HASH_SIZE = (1 << 14);
static final int HASH_SIZE = (1 << 14); private static final int MAX_LITERAL = (1 << 5);
static final int MAX_LITERAL = (1 << 5); private static final int MAX_OFF = (1 << 13);
static final int MAX_OFF = (1 << 13); private static final int MAX_REF = ((1 << 8) + (1 << 3));
static final int MAX_REF = ((1 << 8) + (1 << 3));
int first(byte[] in, int inPos) { int first(byte[] in, int inPos) {
return (in[inPos] << 8) + (in[inPos + 1] & 255); return (in[inPos] << 8) + (in[inPos + 1] & 255);
...@@ -79,11 +78,11 @@ public class CompressLZF implements Compressor { ...@@ -79,11 +78,11 @@ public class CompressLZF implements Compressor {
System.arraycopy(empty, 0, hashTab, 0, HASH_SIZE); System.arraycopy(empty, 0, hashTab, 0, HASH_SIZE);
} }
int literals = 0; int literals = 0;
int hval = first(in, inPos); int hash = first(in, inPos);
while (true) { while (true) {
if (inPos < inLen - 4) { if (inPos < inLen - 4) {
hval = next(hval, in, inPos); hash = next(hash, in, inPos);
int off = hash(hval); int off = hash(hash);
int ref = hashTab[off]; int ref = hashTab[off];
hashTab[off] = inPos; hashTab[off] = inPos;
off = inPos - ref - 1; off = inPos - ref - 1;
...@@ -110,11 +109,11 @@ public class CompressLZF implements Compressor { ...@@ -110,11 +109,11 @@ public class CompressLZF implements Compressor {
} }
out[outPos++] = (byte) off; out[outPos++] = (byte) off;
inPos += len; inPos += len;
hval = first(in, inPos); hash = first(in, inPos);
hval = next(hval, in, inPos); hash = next(hash, in, inPos);
hashTab[hash(hval)] = inPos++; hashTab[hash(hash)] = inPos++;
hval = next(hval, in, inPos); hash = next(hash, in, inPos);
hashTab[hash(hval)] = inPos++; hashTab[hash(hash)] = inPos++;
continue; continue;
} }
} else if (inPos == inLen) { } else if (inPos == inLen) {
......
...@@ -17,7 +17,11 @@ package org.h2.engine; ...@@ -17,7 +17,11 @@ package org.h2.engine;
* - Compiling with JDK 1.3, 1.4, 1.5 and 1.6 * - Compiling with JDK 1.3, 1.4, 1.5 and 1.6
* *
* set path=C:\jdk1.3.1_19\bin;%PATH% * set path=C:\jdk1.3.1_19\bin;%PATH%
* set JAVA_HOME=C:\jdk1.3.1_19\bin * set JAVA_HOME=C:\jdk1.3.1_19
* ant codeswitch_jdk13
* ant compile
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* set JAVA_HOME=C:\Programme\Java\jdk1.6.0
* ant codeswitch_jdk16 * ant codeswitch_jdk16
* ant compile * ant compile
* *
...@@ -38,7 +42,7 @@ package org.h2.engine; ...@@ -38,7 +42,7 @@ package org.h2.engine;
* - Change version(s) in performance.html; use latest versions of other databases * - Change version(s) in performance.html; use latest versions of other databases
* - Run 'ant benchmark' (with JDK 1.4 currently) * - Run 'ant benchmark' (with JDK 1.4 currently)
* - Copy the benchmark results and update the performance page and diagram * - Copy the benchmark results and update the performance page and diagram
* (remove rows 2*open/close, 2*executed statement) * (remove 2*executed statement)
* *
* - Documentation: if there are new files, add them to MergeDocs * - Documentation: if there are new files, add them to MergeDocs
* - Documentation: check if all javadoc files are in the index * - Documentation: check if all javadoc files are in the index
...@@ -69,8 +73,8 @@ package org.h2.engine; ...@@ -69,8 +73,8 @@ package org.h2.engine;
*/ */
public class Constants { public class Constants {
public static final int BUILD_ID = 40; public static final int BUILD_ID = 41;
private static final String BUILD = "2007-01-17"; private static final String BUILD = "2007-01-30";
public static final int VERSION_MAJOR = 1; public static final int VERSION_MAJOR = 1;
public static final int VERSION_MINOR = 0; public static final int VERSION_MINOR = 0;
...@@ -118,7 +122,6 @@ public class Constants { ...@@ -118,7 +122,6 @@ public class Constants {
public static final String SUFFIX_TRACE_FILE = ".trace.db"; public static final String SUFFIX_TRACE_FILE = ".trace.db";
public static final String SUFFIX_LOB_FILE = ".lob.db"; public static final String SUFFIX_LOB_FILE = ".lob.db";
public static final String SUFFIX_TRACE_START_FILE = ".start"; public static final String SUFFIX_TRACE_START_FILE = ".start";
public static final String SUFFIX_SUMMARY_FILE = ".sum.db";
public static final String SUFFIX_LOBS_DIRECTORY = ".lobs.db"; public static final String SUFFIX_LOBS_DIRECTORY = ".lobs.db";
public static final String UTF8 = "UTF8"; public static final String UTF8 = "UTF8";
......
...@@ -133,6 +133,7 @@ public class Database implements DataHandler { ...@@ -133,6 +133,7 @@ public class Database implements DataHandler {
private boolean optimizeReuseResults = true; private boolean optimizeReuseResults = true;
private String cacheType; private String cacheType;
private boolean indexSummaryValid = true; private boolean indexSummaryValid = true;
private Object lobSyncObject = new Object();
public static void setInitialPowerOffCount(int count) { public static void setInitialPowerOffCount(int count) {
initialPowerOffCount = count; initialPowerOffCount = count;
...@@ -1483,4 +1484,8 @@ public class Database implements DataHandler { ...@@ -1483,4 +1484,8 @@ public class Database implements DataHandler {
return indexSummaryValid; return indexSummaryValid;
} }
public Object getLobSyncObject() {
return lobSyncObject;
}
} }
...@@ -153,7 +153,7 @@ public class FunctionAlias extends DbObject { ...@@ -153,7 +153,7 @@ public class FunctionAlias extends DbObject {
// need to set to default value otherwise the function can't be called at all // need to set to default value otherwise the function can't be called at all
o = DataType.getDefaultForPrimitiveType(paramClass); o = DataType.getDefaultForPrimitiveType(paramClass);
} else { } else {
// NULL value for a java primitive: return NULL // NULL for a java primitive: return NULL
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
} }
} }
......
...@@ -203,7 +203,7 @@ public class Session implements SessionInterface { ...@@ -203,7 +203,7 @@ public class Session implements SessionInterface {
Iterator it = unlinkSet.iterator(); Iterator it = unlinkSet.iterator();
while(it.hasNext()) { while(it.hasNext()) {
Value v = (Value) it.next(); Value v = (Value) it.next();
v.unlink(database); v.unlink();
} }
unlinkSet = null; unlinkSet = null;
} }
......
...@@ -53,6 +53,7 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -53,6 +53,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
private String databaseName; private String databaseName;
private String cipher; private String cipher;
private byte[] fileEncryptionKey; private byte[] fileEncryptionKey;
private Object lobSyncObject = new Object();
private Transfer initTransfer(ConnectionInfo ci, String db, String server) throws IOException, SQLException { private Transfer initTransfer(ConnectionInfo ci, String db, String server) throws IOException, SQLException {
int port = Constants.DEFAULT_SERVER_PORT; int port = Constants.DEFAULT_SERVER_PORT;
...@@ -91,12 +92,12 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -91,12 +92,12 @@ public class SessionRemote implements SessionInterface, DataHandler {
return trans; return trans;
} }
private void switchOffAutocommitIfCluster() throws SQLException { private void switchOffAutoCommitIfCluster() throws SQLException {
if(autoCommit && transferList.size() > 1) { if(autoCommit && transferList.size() > 1) {
if(switchOffAutoCommit == null) { if(switchOffAutoCommit == null) {
switchOffAutoCommit = prepareCommand("SET AUTOCOMMIT FALSE"); switchOffAutoCommit = prepareCommand("SET AUTOCOMMIT FALSE");
} }
// this will call setAutocommit(false) // this will call setAutoCommit(false)
switchOffAutoCommit.executeUpdate(); switchOffAutoCommit.executeUpdate();
// so we need to switch it on // so we need to switch it on
autoCommit = true; autoCommit = true;
...@@ -109,7 +110,7 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -109,7 +110,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
public void autoCommitIfCluster() throws SQLException { public void autoCommitIfCluster() throws SQLException {
if(autoCommit && transferList!= null && transferList.size() > 1) { if(autoCommit && transferList!= null && transferList.size() > 1) {
// server side autocommit is off because of race conditions // server side auto commit is off because of race conditions
// (update set id=1 where id=0, but update set id=2 where id=0 is faster) // (update set id=1 where id=0, but update set id=2 where id=0 is faster)
for(int i=0; i<transferList.size(); i++) { for(int i=0; i<transferList.size(); i++) {
Transfer transfer = (Transfer) transferList.get(i); Transfer transfer = (Transfer) transferList.get(i);
...@@ -217,7 +218,7 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -217,7 +218,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
if(switchOffCluster) { if(switchOffCluster) {
switchOffCluster(); switchOffCluster();
} }
switchOffAutocommitIfCluster(); switchOffAutoCommitIfCluster();
} }
private void switchOffCluster() throws SQLException { private void switchOffCluster() throws SQLException {
...@@ -379,4 +380,8 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -379,4 +380,8 @@ public class SessionRemote implements SessionInterface, DataHandler {
return this; return this;
} }
public Object getLobSyncObject() {
return lobSyncObject;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论