Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9cf66529
提交
9cf66529
authored
1月 30, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
433bf879
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
221 行增加
和
189 行删除
+221
-189
advanced.html
h2/src/docsrc/html/advanced.html
+5
-5
faq.html
h2/src/docsrc/html/faq.html
+2
-4
features.html
h2/src/docsrc/html/features.html
+5
-5
history.html
h2/src/docsrc/html/history.html
+41
-20
mainWeb_text_.html
h2/src/docsrc/html/mainWeb_text_.html
+1
-1
performance.html
h2/src/docsrc/html/performance.html
+29
-25
search.js
h2/src/docsrc/html/search.js
+36
-36
tutorial.html
h2/src/docsrc/html/tutorial.html
+4
-4
Parser.java
h2/src/main/org/h2/command/Parser.java
+6
-3
Backup.java
h2/src/main/org/h2/command/dml/Backup.java
+48
-27
Query.java
h2/src/main/org/h2/command/dml/Query.java
+4
-2
ScriptBase.java
h2/src/main/org/h2/command/dml/ScriptBase.java
+4
-0
TransactionCommand.java
h2/src/main/org/h2/command/dml/TransactionCommand.java
+0
-33
CompressLZF.java
h2/src/main/org/h2/compress/CompressLZF.java
+12
-13
Constants.java
h2/src/main/org/h2/engine/Constants.java
+8
-5
Database.java
h2/src/main/org/h2/engine/Database.java
+5
-0
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+1
-1
Session.java
h2/src/main/org/h2/engine/Session.java
+1
-1
SessionRemote.java
h2/src/main/org/h2/engine/SessionRemote.java
+9
-4
没有找到文件。
h2/src/docsrc/html/advanced.html
浏览文件 @
9cf66529
...
...
@@ -11,7 +11,7 @@ Advanced Topics
<table
class=
"content"
><tr
class=
"content"
><td
class=
"content"
><div
class=
"contentDiv"
>
<h1>
Advanced Topics
</h1>
<a
href=
"#resultsets"
>
<a
href=
"#result
_
sets"
>
Result Sets
</a><br>
<a
href=
"#large_objects"
>
Large Objects
</a><br>
...
...
@@ -46,7 +46,7 @@ Advanced Topics
<a
href=
"#glossary_links"
>
Glossary and Links
</a><br>
<br><a
name=
"resultsets"
></a>
<br><a
name=
"result
_
sets"
></a>
<h2>
Result Sets
</h2>
<h3>
Limiting the Number of Rows
</h3>
...
...
@@ -85,7 +85,7 @@ CREATE LINKED TABLE LINK('org.postgresql.Driver', 'jdbc:postgresql:test', 'sa',
</pre>
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,
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.
<br><a
name=
"transaction_isolation"
></a>
...
...
@@ -358,7 +358,7 @@ In Java, there are two ways how this can be achieved:
</p>
<ul>
<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 FileDes
e
criptor
Sync is supposed to return after all in-memory modified copies of buffers associated with this FileDescriptor
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
to be written to the storage device that contains it.
...
...
@@ -643,7 +643,7 @@ custom certificates are supported as well.
<br><a
name=
"uuid"
></a>
<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 s
upported is a function to create new UUIDs using
a cryptographically strong pseudo random number generator.
With random UUIDs, the chance of two having the same value can be calculated
using the probability theory. See also 'Birthday Paradox'.
...
...
h2/src/docsrc/html/faq.html
浏览文件 @
9cf66529
...
...
@@ -14,10 +14,8 @@ Frequently Asked Questions
<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.
The next release is planned for
2007-01-29.
Here is the list of known and confirmed issues as of
2007-01-
17
:
2007-01-
30
:
<ul>
<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
...
...
@@ -43,7 +41,7 @@ some problems that have not yet been found.
Areas that are not completely tested:
<ul>
<li>
Platforms other than Windows XP and the Sun JVM 1.4
<li>
Data types BLOB
s / CLOBs
, VARCHAR_IGNORECASE, OTHER
<li>
Data types BLOB
, CLOB
, VARCHAR_IGNORECASE, OTHER
<li>
Cluster mode, 2-Phase Commit, Savepoints
<li>
Server mode (well tested, but not as well as Embedded mode)
<li>
Multi-Threading and using multiple connections
...
...
h2/src/docsrc/html/features.html
浏览文件 @
9cf66529
...
...
@@ -349,7 +349,7 @@ This is achieved using different database URLs. The settings in the URLs are not
<td>
In-Memory (named)
</td>
<td>
jdbc:h2:mem:
<
databaseName
>
<br>
jdbc:h2:mem:
imdb1
jdbc:h2:mem:
test_mem
</td>
</tr>
<tr>
...
...
@@ -816,14 +816,14 @@ Here is the list of currently supported modes and the difference to the regular
<tr><td>
PostgreSQL
</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,
and NULL is only returned if both values are NULL.
</td></tr>
<tr><td>
MySQL
</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.
Usually, this operation is not allowed and an exception is thrown.
</td></tr>
...
...
@@ -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.
Example:
</p><p>
i'sE2r
TpiUKtt
(it's easy to remember this password if you know the trick)
i'sE2r
tPiUKtT
(it's easy to remember this password if you know the trick)
</p>
<h3>
Passwords: Using Char Arrays instead of Strings
</h3>
...
...
@@ -1096,7 +1096,7 @@ public class Function {
</pre>
The Java function must be registered in the database by calling CREATE ALIAS:
<pre>
CREATE ALIAS ISPRIME FOR "org.h2.samples.Function.isPrime"
CREATE ALIAS IS
_
PRIME FOR "org.h2.samples.Function.isPrime"
</pre>
For a complete sample application, see src/test/org/h2/samples/Function.java.
...
...
h2/src/docsrc/html/history.html
浏览文件 @
9cf66529
差异被折叠。
点击展开。
h2/src/docsrc/html/mainWeb.html
→
h2/src/docsrc/html/mainWeb
_text_
.html
浏览文件 @
9cf66529
...
...
@@ -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>
donate money. You will be listed as a supporter:
</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=
"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"
>
...
...
h2/src/docsrc/html/performance.html
浏览文件 @
9cf66529
...
...
@@ -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>
</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>
<h4>
H2
</h4>
...
...
@@ -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
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>
<h2>
Application Profiling
</h2>
...
...
h2/src/docsrc/html/search.js
浏览文件 @
9cf66529
...
...
@@ -62,21 +62,21 @@ function listWords(value, open) {
word
=
wordRef
.
split
(
"="
)[
0
];
var
tr
=
table
.
insertRow
(
x
++
);
var
td
=
document
.
createElement
(
'td'
);
var
td
c
=
document
.
createAttribute
(
'class'
);
td
c
.
nodeValue
=
'searchKeyword'
;
td
.
setAttributeNode
(
td
c
);
var
td
Class
=
document
.
createAttribute
(
'class'
);
td
Class
.
nodeValue
=
'searchKeyword'
;
td
.
setAttributeNode
(
td
Class
);
var
ah
=
document
.
createElement
(
'a'
);
var
hre
=
document
.
createAttribute
(
'href'
);
hre
.
nodeValue
=
'javascript:set("'
+
word
+
'");'
;
var
hre
f
=
document
.
createAttribute
(
'href'
);
hre
f
.
nodeValue
=
'javascript:set("'
+
word
+
'");'
;
var
link
=
document
.
createTextNode
(
word
);
ah
.
setAttributeNode
(
hre
);
ah
.
setAttributeNode
(
hre
f
);
ah
.
appendChild
(
link
);
td
.
appendChild
(
ah
);
tr
.
appendChild
(
td
);
pi
s
=
wordRef
.
split
(
"="
)[
1
].
split
(
","
);
pi
List
=
wordRef
.
split
(
"="
)[
1
].
split
(
","
);
if
(
count
<
20
||
open
==
word
)
{
x
=
addReferences
(
x
,
pi
s
,
word
);
x
=
addReferences
(
x
,
pi
List
,
word
);
}
}
}
...
...
@@ -129,10 +129,10 @@ function listAnd(keywords) {
for
(
var
j
=
0
;
j
<
words
.
length
;
j
++
)
{
var
wordRef
=
words
[
j
];
if
(
wordRef
.
toLowerCase
().
indexOf
(
value
)
==
0
)
{
pi
s
=
wordRef
.
split
(
"="
)[
1
].
split
(
","
);
pi
List
=
wordRef
.
split
(
"="
)[
1
].
split
(
","
);
var
w
=
1
;
for
(
var
k
=
0
;
k
<
pi
s
.
length
;
k
++
)
{
var
pi
=
pi
s
[
k
];
for
(
var
k
=
0
;
k
<
pi
List
.
length
;
k
++
)
{
var
pi
=
pi
List
[
k
];
if
(
pi
.
charAt
(
0
)
==
't'
)
{
pi
=
pi
.
substring
(
1
);
w
=
10000
;
...
...
@@ -155,36 +155,36 @@ function listAnd(keywords) {
}
var
x
=
0
;
var
table
=
document
.
getElementById
(
'result'
);
var
pi
s
=
new
Array
();
var
pi
w
=
new
Array
();
var
pi
List
=
new
Array
();
var
pi
Weight
=
new
Array
();
for
(
var
i
=
0
;
i
<
pages
.
length
;
i
++
)
{
if
(
count
[
i
]
>=
keywords
.
length
)
{
pi
s
[
x
]
=
''
+
i
;
pi
w
[
x
]
=
weight
[
i
];
pi
List
[
x
]
=
''
+
i
;
pi
Weight
[
x
]
=
weight
[
i
];
x
++
;
}
}
// sort
for
(
var
i
=
1
,
j
;
i
<
x
;
i
++
)
{
var
tw
=
pi
w
[
i
];
var
ti
=
pi
s
[
i
];
for
(
j
=
i
-
1
;
j
>=
0
&&
(
pi
w
[
j
]
<
tw
);
j
--
)
{
pi
w
[
j
+
1
]
=
piw
[
j
];
pi
s
[
j
+
1
]
=
pis
[
j
];
var
tw
=
pi
Weight
[
i
];
var
ti
=
pi
List
[
i
];
for
(
j
=
i
-
1
;
j
>=
0
&&
(
pi
Weight
[
j
]
<
tw
);
j
--
)
{
pi
Weight
[
j
+
1
]
=
piWeight
[
j
];
pi
List
[
j
+
1
]
=
piList
[
j
];
}
pi
w
[
j
+
1
]
=
tw
;
pi
s
[
j
+
1
]
=
ti
;
pi
Weight
[
j
+
1
]
=
tw
;
pi
List
[
j
+
1
]
=
ti
;
}
addReferences
(
0
,
pi
s
,
keywords
);
if
(
pi
s
.
length
==
0
)
{
addReferences
(
0
,
pi
List
,
keywords
);
if
(
pi
List
.
length
==
0
)
{
noResults
(
table
);
}
}
function
addReferences
(
x
,
pi
s
,
word
)
{
function
addReferences
(
x
,
pi
List
,
word
)
{
var
table
=
document
.
getElementById
(
'result'
);
for
(
var
j
=
0
;
j
<
pi
s
.
length
;
j
++
)
{
var
pi
=
pi
s
[
j
];
for
(
var
j
=
0
;
j
<
pi
List
.
length
;
j
++
)
{
var
pi
=
pi
List
[
j
];
if
(
pi
.
charAt
(
0
)
==
't'
)
{
pi
=
pi
.
substring
(
1
);
}
else
if
(
pi
.
charAt
(
0
)
==
'h'
)
{
...
...
@@ -194,18 +194,18 @@ function addReferences(x, pis, word) {
}
var
tr
=
table
.
insertRow
(
x
++
);
var
td
=
document
.
createElement
(
'td'
);
var
td
c
=
document
.
createAttribute
(
'class'
);
td
c
.
nodeValue
=
'searchLink'
;
td
.
setAttributeNode
(
td
c
);
var
td
Class
=
document
.
createAttribute
(
'class'
);
td
Class
.
nodeValue
=
'searchLink'
;
td
.
setAttributeNode
(
td
Class
);
var
ah
=
document
.
createElement
(
'a'
);
var
hre
=
document
.
createAttribute
(
'href'
);
var
hre
f
=
document
.
createAttribute
(
'href'
);
var
thisLink
=
'javascript:go('
+
pi
+
', "'
+
word
+
'")'
;
if
(
firstLink
==
null
)
{
firstLink
=
pi
;
firstLinkWord
=
word
;
}
hre
.
nodeValue
=
thisLink
;
ah
.
setAttributeNode
(
hre
);
hre
f
.
nodeValue
=
thisLink
;
ah
.
setAttributeNode
(
hre
f
);
var
page
=
pages
[
pi
];
var
link
=
document
.
createTextNode
(
page
.
title
);
ah
.
appendChild
(
link
);
...
...
@@ -240,9 +240,9 @@ function replaceOtherChars(s) {
function
noResults
(
table
)
{
var
tr
=
table
.
insertRow
(
0
);
var
td
=
document
.
createElement
(
'td'
);
var
td
c
=
document
.
createAttribute
(
'class'
);
td
c
.
nodeValue
=
'searchKeyword'
;
td
.
setAttributeNode
(
td
c
);
var
td
Class
=
document
.
createAttribute
(
'class'
);
td
Class
.
nodeValue
=
'searchKeyword'
;
td
.
setAttributeNode
(
td
Class
);
var
text
=
document
.
createTextNode
(
'No results found'
);
td
.
appendChild
(
text
);
tr
.
appendChild
(
td
);
...
...
h2/src/docsrc/html/tutorial.html
浏览文件 @
9cf66529
...
...
@@ -27,7 +27,7 @@ Tutorial
CSV (Comma Separated Values) Support
</a><br>
<a
href=
"#upgrade_backup_restore"
>
Upgrade, Backup, and Restore
</a><br>
<a
href=
"#openoffice"
>
<a
href=
"#open
_
office"
>
Using OpenOffice Base
</a><br>
<br><a
name=
"tutorial_starting_h2_console"
></a>
...
...
@@ -384,8 +384,8 @@ SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addColumn("EMAIL", 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[]{"John Jones", "john
jones@abcde.fgh
", "+41976543210"});
rs.addRow(new String[]{"Bob Meier", "bob.meier@abcde.
abc
", "+41123456789"});
rs.addRow(new String[]{"John Jones", "john
.jones@abcde.abc
", "+41976543210"});
Csv.write("test.csv", rs, null);
</pre>
...
...
@@ -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
need to be available on the server side.
<br><a
name=
"openoffice"
></a>
<br><a
name=
"open
_
office"
></a>
<h2>
Using OpenOffice Base
</h2>
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.
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
9cf66529
...
...
@@ -1705,7 +1705,9 @@ public class Parser {
Sequence
sequence
=
database
.
getSchema
(
schemaName
).
findSequence
(
objectName
);
if
(
sequence
!=
null
)
{
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
;
}
}
...
...
@@ -1931,6 +1933,7 @@ public class Parser {
function
.
setParameter
(
0
,
when
);
function
.
setParameter
(
1
,
then
);
function
.
setParameter
(
2
,
elsePart
);
function
.
doneWithParameters
();
return
function
;
}
...
...
@@ -3587,12 +3590,12 @@ public class Parser {
command
.
setStartWith
(
start
);
return
command
;
}
else
if
(
readIf
(
"SELECTIVITY"
))
{
int
sel
=
getPositiveInt
();
int
sel
ectivity
=
getPositiveInt
();
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
tableSchema
);
command
.
setTable
(
table
);
command
.
setType
(
AlterTableAlterColumn
.
SELECTIVITY
);
command
.
setOldColumn
(
column
);
command
.
setStartWith
(
sel
);
command
.
setStartWith
(
sel
ectivity
);
return
command
;
}
else
{
Column
newColumn
=
parseColumnForTable
(
columnName
);
...
...
h2/src/main/org/h2/command/dml/Backup.java
浏览文件 @
9cf66529
/*
* 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
;
import
java.io.FileInputStream
;
...
...
@@ -50,38 +54,32 @@ public class Backup extends Prepared {
name
=
FileUtils
.
getFileName
(
name
);
FileOutputStream
zip
=
new
FileOutputStream
(
fileName
);
ZipOutputStream
out
=
new
ZipOutputStream
(
zip
);
out
.
putNextEntry
(
new
ZipEntry
(
name
+
Constants
.
SUFFIX_DATA_FILE
));
DiskFile
file
=
db
.
getDataFile
();
LogSystem
log
=
db
.
getLog
();
try
{
log
.
flush
();
log
.
updateKeepFiles
(
1
);
int
pos
=
-
1
;
int
max
=
file
.
getReadCount
();
while
(
true
)
{
pos
=
file
.
readDirect
(
pos
,
out
);
if
(
pos
<
0
)
{
break
;
}
db
.
setProgress
(
DatabaseEventListener
.
STATE_BACKUP_FILE
,
name
,
pos
,
max
);
}
out
.
closeEntry
();
String
fn
=
db
.
getName
()
+
Constants
.
SUFFIX_DATA_FILE
;
backupDiskFile
(
out
,
fn
,
db
.
getDataFile
());
fn
=
db
.
getName
()
+
Constants
.
SUFFIX_INDEX_FILE
;
backupDiskFile
(
out
,
fn
,
db
.
getIndexFile
());
ObjectArray
list
=
log
.
getActiveLogFiles
();
max
=
list
.
size
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
LogFile
lf
=
(
LogFile
)
list
.
get
(
i
);
String
fn
=
lf
.
getFileName
();
out
.
putNextEntry
(
new
ZipEntry
(
FileUtils
.
getFileName
(
fn
)));
FileInputStream
in
=
new
FileInputStream
(
fn
);
IOUtils
.
copyAndCloseInput
(
in
,
out
);
out
.
closeEntry
();
db
.
setProgress
(
DatabaseEventListener
.
STATE_BACKUP_FILE
,
name
,
i
,
max
);
}
int
todoLockDatabaseSomehow
;
ArrayList
fileList
=
FileBase
.
getDatabaseFiles
(
db
.
getDatabasePath
(),
name
,
true
);
for
(
int
i
=
0
;
i
<
fileList
.
size
();
i
++)
{
String
fn
=
(
String
)
fileList
.
get
(
i
);
int
max
=
list
.
size
();
// synchronize on the database, to avoid concurrent temp file creation / deletion / backup
synchronized
(
db
.
getLobSyncObject
())
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
LogFile
lf
=
(
LogFile
)
list
.
get
(
i
);
fn
=
lf
.
getFileName
();
backupFile
(
out
,
fn
);
db
.
setProgress
(
DatabaseEventListener
.
STATE_BACKUP_FILE
,
name
,
i
,
max
);
}
ArrayList
fileList
=
FileBase
.
getDatabaseFiles
(
db
.
getDatabasePath
(),
name
,
true
);
for
(
int
i
=
0
;
i
<
fileList
.
size
();
i
++)
{
fn
=
(
String
)
fileList
.
get
(
i
);
if
(
fn
.
endsWith
(
Constants
.
SUFFIX_HASH_FILE
)
||
fn
.
endsWith
(
Constants
.
SUFFIX_LOB_FILE
))
{
backupFile
(
out
,
fn
);
}
}
}
int
todoCopyLobFiles
;
out
.
close
();
zip
.
close
();
}
finally
{
...
...
@@ -91,6 +89,29 @@ public class Backup extends Prepared {
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
()
{
return
true
;
...
...
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
9cf66529
...
...
@@ -83,8 +83,10 @@ public abstract class Query extends Prepared {
if
(
lastResult
!=
null
&&
limit
==
lastLimit
)
{
if
(
sameResultAsLast
(
session
,
params
,
lastParameters
,
lastEvaluated
))
{
lastResult
=
lastResult
.
createShallowCopy
(
session
);
lastResult
.
reset
();
return
lastResult
;
if
(
lastResult
!=
null
)
{
lastResult
.
reset
();
return
lastResult
;
}
}
}
lastParameters
=
params
;
...
...
h2/src/main/org/h2/command/dml/ScriptBase.java
浏览文件 @
9cf66529
...
...
@@ -201,4 +201,8 @@ public class ScriptBase extends Prepared implements DataHandler {
this
.
compressionAlgorithm
=
algorithm
;
}
public
Object
getLobSyncObject
()
{
return
this
;
}
}
h2/src/main/org/h2/command/dml/TransactionCommand.java
浏览文件 @
9cf66529
...
...
@@ -4,19 +4,12 @@
*/
package
org
.
h2
.
command
.
dml
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
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.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.message.Message
;
import
org.h2.store.DiskFile
;
/**
...
...
@@ -124,32 +117,6 @@ public class TransactionCommand extends Prepared {
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
()
{
return
true
;
}
...
...
h2/src/main/org/h2/compress/CompressLZF.java
浏览文件 @
9cf66529
...
...
@@ -49,11 +49,10 @@ public class CompressLZF implements Compressor {
return
Compressor
.
LZF
;
}
static
final
int
HLOG
=
14
;
static
final
int
HASH_SIZE
=
(
1
<<
14
);
static
final
int
MAX_LITERAL
=
(
1
<<
5
);
static
final
int
MAX_OFF
=
(
1
<<
13
);
static
final
int
MAX_REF
=
((
1
<<
8
)
+
(
1
<<
3
));
private
static
final
int
HASH_SIZE
=
(
1
<<
14
);
private
static
final
int
MAX_LITERAL
=
(
1
<<
5
);
private
static
final
int
MAX_OFF
=
(
1
<<
13
);
private
static
final
int
MAX_REF
=
((
1
<<
8
)
+
(
1
<<
3
));
int
first
(
byte
[]
in
,
int
inPos
)
{
return
(
in
[
inPos
]
<<
8
)
+
(
in
[
inPos
+
1
]
&
255
);
...
...
@@ -79,11 +78,11 @@ public class CompressLZF implements Compressor {
System
.
arraycopy
(
empty
,
0
,
hashTab
,
0
,
HASH_SIZE
);
}
int
literals
=
0
;
int
h
val
=
first
(
in
,
inPos
);
int
h
ash
=
first
(
in
,
inPos
);
while
(
true
)
{
if
(
inPos
<
inLen
-
4
)
{
h
val
=
next
(
hval
,
in
,
inPos
);
int
off
=
hash
(
h
val
);
h
ash
=
next
(
hash
,
in
,
inPos
);
int
off
=
hash
(
h
ash
);
int
ref
=
hashTab
[
off
];
hashTab
[
off
]
=
inPos
;
off
=
inPos
-
ref
-
1
;
...
...
@@ -110,11 +109,11 @@ public class CompressLZF implements Compressor {
}
out
[
outPos
++]
=
(
byte
)
off
;
inPos
+=
len
;
h
val
=
first
(
in
,
inPos
);
h
val
=
next
(
hval
,
in
,
inPos
);
hashTab
[
hash
(
h
val
)]
=
inPos
++;
h
val
=
next
(
hval
,
in
,
inPos
);
hashTab
[
hash
(
h
val
)]
=
inPos
++;
h
ash
=
first
(
in
,
inPos
);
h
ash
=
next
(
hash
,
in
,
inPos
);
hashTab
[
hash
(
h
ash
)]
=
inPos
++;
h
ash
=
next
(
hash
,
in
,
inPos
);
hashTab
[
hash
(
h
ash
)]
=
inPos
++;
continue
;
}
}
else
if
(
inPos
==
inLen
)
{
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
9cf66529
...
...
@@ -17,7 +17,11 @@ package org.h2.engine;
* - Compiling with JDK 1.3, 1.4, 1.5 and 1.6
*
* 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 compile
*
...
...
@@ -38,7 +42,7 @@ package org.h2.engine;
* - Change version(s) in performance.html; use latest versions of other databases
* - Run 'ant benchmark' (with JDK 1.4 currently)
* - 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: check if all javadoc files are in the index
...
...
@@ -69,8 +73,8 @@ package org.h2.engine;
*/
public
class
Constants
{
public
static
final
int
BUILD_ID
=
4
0
;
private
static
final
String
BUILD
=
"2007-01-
17
"
;
public
static
final
int
BUILD_ID
=
4
1
;
private
static
final
String
BUILD
=
"2007-01-
30
"
;
public
static
final
int
VERSION_MAJOR
=
1
;
public
static
final
int
VERSION_MINOR
=
0
;
...
...
@@ -118,7 +122,6 @@ public class Constants {
public
static
final
String
SUFFIX_TRACE_FILE
=
".trace.db"
;
public
static
final
String
SUFFIX_LOB_FILE
=
".lob.db"
;
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
UTF8
=
"UTF8"
;
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
9cf66529
...
...
@@ -133,6 +133,7 @@ public class Database implements DataHandler {
private
boolean
optimizeReuseResults
=
true
;
private
String
cacheType
;
private
boolean
indexSummaryValid
=
true
;
private
Object
lobSyncObject
=
new
Object
();
public
static
void
setInitialPowerOffCount
(
int
count
)
{
initialPowerOffCount
=
count
;
...
...
@@ -1483,4 +1484,8 @@ public class Database implements DataHandler {
return
indexSummaryValid
;
}
public
Object
getLobSyncObject
()
{
return
lobSyncObject
;
}
}
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
9cf66529
...
...
@@ -153,7 +153,7 @@ public class FunctionAlias extends DbObject {
// need to set to default value otherwise the function can't be called at all
o
=
DataType
.
getDefaultForPrimitiveType
(
paramClass
);
}
else
{
// NULL
value
for a java primitive: return NULL
// NULL for a java primitive: return NULL
return
ValueNull
.
INSTANCE
;
}
}
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
9cf66529
...
...
@@ -203,7 +203,7 @@ public class Session implements SessionInterface {
Iterator
it
=
unlinkSet
.
iterator
();
while
(
it
.
hasNext
())
{
Value
v
=
(
Value
)
it
.
next
();
v
.
unlink
(
database
);
v
.
unlink
();
}
unlinkSet
=
null
;
}
...
...
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
9cf66529
...
...
@@ -53,6 +53,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
private
String
databaseName
;
private
String
cipher
;
private
byte
[]
fileEncryptionKey
;
private
Object
lobSyncObject
=
new
Object
();
private
Transfer
initTransfer
(
ConnectionInfo
ci
,
String
db
,
String
server
)
throws
IOException
,
SQLException
{
int
port
=
Constants
.
DEFAULT_SERVER_PORT
;
...
...
@@ -91,12 +92,12 @@ public class SessionRemote implements SessionInterface, DataHandler {
return
trans
;
}
private
void
switchOffAuto
c
ommitIfCluster
()
throws
SQLException
{
private
void
switchOffAuto
C
ommitIfCluster
()
throws
SQLException
{
if
(
autoCommit
&&
transferList
.
size
()
>
1
)
{
if
(
switchOffAutoCommit
==
null
)
{
switchOffAutoCommit
=
prepareCommand
(
"SET AUTOCOMMIT FALSE"
);
}
// this will call setAuto
c
ommit(false)
// this will call setAuto
C
ommit(false)
switchOffAutoCommit
.
executeUpdate
();
// so we need to switch it on
autoCommit
=
true
;
...
...
@@ -109,7 +110,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
public
void
autoCommitIfCluster
()
throws
SQLException
{
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)
for
(
int
i
=
0
;
i
<
transferList
.
size
();
i
++)
{
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
...
...
@@ -217,7 +218,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
if
(
switchOffCluster
)
{
switchOffCluster
();
}
switchOffAuto
c
ommitIfCluster
();
switchOffAuto
C
ommitIfCluster
();
}
private
void
switchOffCluster
()
throws
SQLException
{
...
...
@@ -379,4 +380,8 @@ public class SessionRemote implements SessionInterface, DataHandler {
return
this
;
}
public
Object
getLobSyncObject
()
{
return
lobSyncObject
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论