Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e9b4498c
提交
e9b4498c
authored
12月 11, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
8bd9aeaa
全部展开
显示空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
270 行增加
和
149 行删除
+270
-149
ant-build.properties
h2/ant-build.properties
+1
-1
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+7
-6
CreateIndex.java
h2/src/main/org/h2/command/ddl/CreateIndex.java
+1
-1
Constants.java
h2/src/main/org/h2/engine/Constants.java
+2
-1
BtreeIndex.java
h2/src/main/org/h2/index/BtreeIndex.java
+21
-9
JdbcPreparedStatement.java
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
+2
-1
JdbcResultSet.java
h2/src/main/org/h2/jdbc/JdbcResultSet.java
+11
-7
Schema.java
h2/src/main/org/h2/schema/Schema.java
+14
-5
WebServer.java
h2/src/main/org/h2/server/web/WebServer.java
+1
-1
WebThread.java
h2/src/main/org/h2/server/web/WebThread.java
+2
-1
_test_uk.properties
h2/src/main/org/h2/server/web/res/_test_uk.properties
+0
-0
query.jsp
h2/src/main/org/h2/server/web/res/query.jsp
+39
-23
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+34
-5
FileSystemDisk.java
h2/src/main/org/h2/store/fs/FileSystemDisk.java
+1
-1
TableData.java
h2/src/main/org/h2/table/TableData.java
+1
-1
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+7
-14
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+5
-2
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+45
-1
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+9
-9
TestCrashAPI.java
h2/src/test/org/h2/test/synth/TestCrashAPI.java
+9
-2
test.in.txt
h2/src/test/org/h2/test/test.in.txt
+58
-58
没有找到文件。
h2/ant-build.properties
浏览文件 @
e9b4498c
#
Sat Dec 01 09:41:2
0 CET 2007
#
Mon Dec 10 07:25:4
0 CET 2007
javac
=
javac
benchmark.drivers.dir
=
C
\:
/data/java
path.servlet.jar
=
C
\:
/data/classpath/servlet-api.jar
...
...
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
e9b4498c
...
...
@@ -14,6 +14,7 @@ import org.h2.constraint.ConstraintCheck;
import
org.h2.constraint.ConstraintReferential
;
import
org.h2.constraint.ConstraintUnique
;
import
org.h2.engine.Database
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.Right
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
...
...
@@ -52,9 +53,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
super
(
session
,
schema
);
}
private
String
generateConstraintName
(
int
id
)
throws
SQLException
{
private
String
generateConstraintName
(
DbObject
obj
,
int
id
)
throws
SQLException
{
if
(
constraintName
==
null
)
{
constraintName
=
getSchema
().
getUniqueConstraintName
();
constraintName
=
getSchema
().
getUniqueConstraintName
(
obj
);
}
return
constraintName
;
}
...
...
@@ -72,7 +73,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
switch
(
type
)
{
case
CHECK:
{
int
id
=
getObjectId
(
true
,
true
);
String
name
=
generateConstraintName
(
id
);
String
name
=
generateConstraintName
(
table
,
id
);
ConstraintCheck
check
=
new
ConstraintCheck
(
getSchema
(),
id
,
name
,
table
);
TableFilter
filter
=
new
TableFilter
(
session
,
table
,
null
,
false
,
null
);
checkExpression
.
mapColumns
(
filter
,
0
);
...
...
@@ -99,7 +100,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
}
int
id
=
getObjectId
(
true
,
true
);
String
name
=
generateConstraintName
(
id
);
String
name
=
generateConstraintName
(
table
,
id
);
ConstraintUnique
unique
=
new
ConstraintUnique
(
getSchema
(),
id
,
name
,
table
);
unique
.
setColumns
(
columns
);
unique
.
setIndex
(
index
,
isOwner
);
...
...
@@ -146,7 +147,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
}
int
id
=
getObjectId
(
true
,
true
);
String
name
=
generateConstraintName
(
id
);
String
name
=
generateConstraintName
(
table
,
id
);
ConstraintReferential
ref
=
new
ConstraintReferential
(
getSchema
(),
id
,
name
,
table
);
ref
.
setColumns
(
columns
);
ref
.
setIndex
(
index
,
isOwner
);
...
...
@@ -186,7 +187,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
indexType
.
setBelongsToConstraint
(
true
);
String
prefix
=
constraintName
==
null
?
"CONSTRAINT"
:
constraintName
;
String
indexName
=
getSchema
().
getUniqueIndexName
(
prefix
+
"_INDEX_"
);
String
indexName
=
getSchema
().
getUniqueIndexName
(
t
,
prefix
+
"_INDEX_"
);
IndexColumn
[]
idxCols
=
IndexColumn
.
wrap
(
cols
);
return
t
.
addIndex
(
session
,
indexName
,
indexId
,
idxCols
,
indexType
,
Index
.
EMPTY_HEAD
,
null
);
}
...
...
h2/src/main/org/h2/command/ddl/CreateIndex.java
浏览文件 @
e9b4498c
...
...
@@ -70,7 +70,7 @@ public class CreateIndex extends SchemaCommand {
}
int
id
=
getObjectId
(
true
,
false
);
if
(
indexName
==
null
)
{
indexName
=
getSchema
().
getUniqueIndexName
(
"INDEX_"
);
indexName
=
getSchema
().
getUniqueIndexName
(
table
,
"INDEX_"
);
}
if
(
getSchema
().
findIndex
(
indexName
)
!=
null
)
{
if
(
ifNotExists
)
{
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
e9b4498c
...
...
@@ -56,7 +56,8 @@ import org.h2.constant.SysProperties;
* - Make sure the build files are removed
* - ant zip
* - Windows installer (nsis)
* - Test
* - Test Console
* - Test all languages
* - Test the windows service
* - Scan for viruses
* - ant mavenDeployCentral
...
...
h2/src/main/org/h2/index/BtreeIndex.java
浏览文件 @
e9b4498c
...
...
@@ -33,7 +33,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
// final static int MAX_PAGE_SIZE = 256;
private
Storage
storage
;
private
BtreePage
root
;
private
BtreePage
root
Page
;
private
TableData
tableData
;
private
BtreeHead
head
;
private
boolean
needRebuild
;
...
...
@@ -57,7 +57,8 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
head
=
(
BtreeHead
)
rec
;
}
if
(
head
!=
null
&&
head
.
getConsistent
())
{
setRoot
((
BtreePage
)
storage
.
getRecord
(
session
,
head
.
getRootPosition
()));
int
testing
;
// setRoot((BtreePage) storage.getRecord(session, head.getRootPosition()));
needRebuild
=
false
;
rowCount
=
table
.
getRowCount
(
session
);
}
else
{
...
...
@@ -67,12 +68,20 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
}
}
private
void
setRoot
(
BtreePage
newRoot
)
{
if
(
root
!=
null
)
{
root
.
setRoot
(
false
);
private
BtreePage
getRoot
(
Session
session
)
throws
SQLException
{
if
(
rootPage
==
null
)
{
setRoot
((
BtreePage
)
storage
.
getRecord
(
session
,
head
.
getRootPosition
()));
}
return
rootPage
;
}
private
BtreePage
setRoot
(
BtreePage
newRoot
)
{
if
(
rootPage
!=
null
)
{
rootPage
.
setRoot
(
false
);
}
newRoot
.
setRoot
(
true
);
root
=
newRoot
;
rootPage
=
newRoot
;
return
rootPage
;
}
public
int
getHeadPos
()
{
...
...
@@ -151,12 +160,13 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
Value
v
=
r
.
getValue
(
idx
);
row
.
setValue
(
idx
,
v
);
}
BtreePage
root
=
getRoot
(
session
);
int
splitPoint
=
root
.
add
(
row
,
session
);
if
(
splitPoint
!=
0
)
{
SearchRow
pivot
=
root
.
getData
(
splitPoint
);
BtreePage
page1
=
root
;
BtreePage
page2
=
root
.
split
(
session
,
splitPoint
);
setRoot
(
new
BtreeNode
(
this
,
page1
,
pivot
,
page2
));
root
=
setRoot
(
new
BtreeNode
(
this
,
page1
,
pivot
,
page2
));
addPage
(
session
,
root
);
deletePage
(
session
,
head
);
head
.
setRootPosition
(
root
.
getPos
());
...
...
@@ -171,6 +181,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
// TODO performance: maybe improve truncate performance in this case
truncate
(
session
);
}
else
{
BtreePage
root
=
getRoot
(
session
);
root
.
remove
(
session
,
row
,
0
);
rowCount
--;
}
...
...
@@ -180,6 +191,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
if
(
SysProperties
.
CHECK
&&
storage
==
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
OBJECT_CLOSED
);
}
BtreePage
root
=
getRoot
(
session
);
if
(
first
==
null
)
{
BtreeCursor
cursor
=
new
BtreeCursor
(
session
,
this
,
last
);
root
.
first
(
cursor
);
...
...
@@ -257,7 +269,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
storage
.
truncate
(
session
);
head
=
new
BtreeHead
();
addPage
(
session
,
head
);
setRoot
(
new
BtreeLeaf
(
this
,
new
ObjectArray
()));
BtreePage
root
=
setRoot
(
new
BtreeLeaf
(
this
,
new
ObjectArray
()));
addPage
(
session
,
root
);
deletePage
(
session
,
head
);
head
.
setRootPosition
(
root
.
getPos
());
...
...
@@ -301,7 +313,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
}
return
null
;
}
else
{
return
root
.
getLast
(
session
);
return
getRoot
(
session
)
.
getLast
(
session
);
}
}
...
...
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
浏览文件 @
e9b4498c
...
...
@@ -839,7 +839,8 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
* Sets the value of a parameter as an input stream.
*
* @param parameterIndex the parameter index (1, 2, ...)
* @param x the value * @throws SQLException if this object is closed
* @param x the value
* @throws SQLException if this object is closed
*/
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
)
throws
SQLException
{
setBinaryStream
(
parameterIndex
,
x
,
-
1
);
...
...
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
e9b4498c
...
...
@@ -24,6 +24,14 @@ import java.util.Calendar;
import
java.util.HashMap
;
import
java.util.Map
;
//#ifdef JDK16
/*
import java.sql.NClob;
import java.sql.RowId;
import java.sql.SQLXML;
*/
//#endif
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
...
...
@@ -2668,7 +2676,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/**
* Detects if the row was updated (by somebody else or the caller).
*
* @return false because this driver does detect this
* @return false because this driver does
not
detect this
*/
public
boolean
rowUpdated
()
throws
SQLException
{
try
{
...
...
@@ -2682,7 +2690,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/**
* Detects if the row was inserted.
*
* @return false because this driver does detect this
* @return false because this driver does
not
detect this
*/
public
boolean
rowInserted
()
throws
SQLException
{
try
{
...
...
@@ -2696,7 +2704,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/**
* Detects if the row was deleted (by somebody else or the caller).
*
* @return false because this driver does detect this
* @return false because this driver does
not
detect this
*/
public
boolean
rowDeleted
()
throws
SQLException
{
try
{
...
...
@@ -2928,10 +2936,6 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
return
super
.
getTraceId
();
}
JdbcConnection
getConnection
()
{
return
conn
;
}
private
boolean
nextRow
()
throws
SQLException
{
boolean
next
=
result
.
next
();
if
(!
next
&&
!
scrollable
)
{
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
e9b4498c
...
...
@@ -6,6 +6,7 @@ package org.h2.schema;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.constraint.Constraint
;
...
...
@@ -185,7 +186,15 @@ public class Schema extends DbObjectBase {
return
(
Constant
)
constants
.
get
(
constantName
);
}
private
String
getUniqueName
(
HashMap
map
,
String
prefix
)
{
private
String
getUniqueName
(
DbObject
obj
,
HashMap
map
,
String
prefix
)
{
String
hash
=
Integer
.
toHexString
(
obj
.
getName
().
hashCode
()).
toUpperCase
();
for
(
int
i
=
1
;
i
<
hash
.
length
();
i
++)
{
String
name
=
prefix
+
hash
.
substring
(
0
,
i
);
if
(
map
.
get
(
name
)
==
null
)
{
return
name
;
}
}
prefix
=
prefix
+
hash
+
"_"
;
for
(
int
i
=
0
;;
i
++)
{
String
name
=
prefix
+
i
;
if
(
map
.
get
(
name
)
==
null
)
{
...
...
@@ -194,12 +203,12 @@ public class Schema extends DbObjectBase {
}
}
public
String
getUniqueConstraintName
()
{
return
getUniqueName
(
constraints
,
"CONSTRAINT_"
);
public
String
getUniqueConstraintName
(
DbObject
obj
)
{
return
getUniqueName
(
obj
,
constraints
,
"CONSTRAINT_"
);
}
public
String
getUniqueIndexName
(
String
prefix
)
{
return
getUniqueName
(
indexes
,
prefix
);
public
String
getUniqueIndexName
(
DbObject
obj
,
String
prefix
)
{
return
getUniqueName
(
obj
,
indexes
,
prefix
);
}
public
Table
getTableOrView
(
Session
session
,
String
name
)
throws
SQLException
{
...
...
h2/src/main/org/h2/server/web/WebServer.java
浏览文件 @
e9b4498c
...
...
@@ -70,7 +70,7 @@ public class WebServer implements Service {
"Generic OneDollarDB|in.co.daffodil.db.jdbc.DaffodilDBDriver|jdbc:daffodilDB_embedded:school;path=C:/temp;create=true|sa"
,
"Generic DB2|COM.ibm.db2.jdbc.net.DB2Driver|jdbc:db2://<host>/<db>|"
,
"Generic Oracle|oracle.jdbc.driver.OracleDriver|jdbc:oracle:thin:@<host>:1521:<instance>|scott"
,
"Generic MS SQL Server
|com.microsoft.jdbc.sqlserver.SQLServerDriver|jdbc:M
icrosoft:sqlserver://localhost:1433;DatabaseName=sqlexpress|sa"
,
"Generic MS SQL Server
2000|com.microsoft.jdbc.sqlserver.SQLServerDriver|jdbc:m
icrosoft:sqlserver://localhost:1433;DatabaseName=sqlexpress|sa"
,
"Generic MS SQL Server 2005|com.microsoft.sqlserver.jdbc.SQLServerDriver|jdbc:sqlserver://localhost;DatabaseName=test|sa"
,
"Generic PostgreSQL|org.postgresql.Driver|jdbc:postgresql:<db>|"
,
"Generic MySQL|com.mysql.jdbc.Driver|jdbc:mysql://<host>:<port>/<db>|"
,
...
...
h2/src/main/org/h2/server/web/WebThread.java
浏览文件 @
e9b4498c
...
...
@@ -1429,7 +1429,8 @@ class WebThread extends Thread implements DatabaseEventListener {
stat
.
close
();
}
return
buff
.
toString
();
}
catch
(
Exception
e
)
{
}
catch
(
Throwable
e
)
{
// throwable: including OutOfMemoryError and so on
return
getStackTrace
(
id
,
e
);
}
finally
{
session
.
executingStatement
=
null
;
...
...
h2/src/main/org/h2/server/web/res/_te
xt_ua
.properties
→
h2/src/main/org/h2/server/web/res/_te
st_uk
.properties
浏览文件 @
e9b4498c
File moved
h2/src/main/org/h2/server/web/res/query.jsp
浏览文件 @
e9b4498c
...
...
@@ -13,13 +13,14 @@ Initial Developer: H2 Group
var
agent
=
navigator
.
userAgent
.
toLowerCase
();
var
is_opera
=
agent
.
indexOf
(
"opera"
)
>=
0
;
var
autoComplete
=
1
;
var
autoComplete
=
1
;
// 0: off, 1: normal, 2: full
var
selectedRow
=
-
1
;
var
lastList
=
''
;
var
lastQuery
=
null
;
var
columnsByTable
=
new
Object
();
var
tableAliases
=
new
Object
();
var
showAutoCompleteWait
=
0
;
var
autoCompleteManual
=
false
;
var
req
;
function
refreshTables
()
{
...
...
@@ -172,13 +173,6 @@ function insertText(s, isTable) {
field
.
focus
();
}
function
keyUp
()
{
if
(
autoComplete
!=
0
)
{
showAutoComplete
();
}
return
true
;
}
function
showAutoComplete
()
{
if
(
showAutoCompleteWait
==
0
)
{
showAutoCompleteWait
=
5
;
...
...
@@ -206,24 +200,32 @@ function keyDown(event) {
return
false
;
}
if
(
key
==
13
&&
event
.
ctrlKey
)
{
// ctrl + return
document
.
h2query
.
submit
();
return
false
;
}
else
if
(
key
==
32
&&
event
.
ctrlKey
)
{
showAutoComplete
();
// ctrl + space
autoCompleteManual
=
true
;
lastQuery
=
null
;
lastList
=
''
;
showAutoCompleteNow
();
return
false
;
}
else
if
(
key
==
190
&&
autoComplete
==
0
)
{
// dot
help
();
return
true
;
}
var
table
=
getAutoCompleteTable
();
if
(
table
.
rows
.
length
>
0
)
{
if
(
key
==
27
)
{
// escape
while
(
table
.
rows
.
length
>
0
)
{
table
.
deleteRow
(
0
);
}
showOutput
(
''
);
return
false
;
}
else
if
((
key
==
13
&&
!
event
.
shiftKey
)
||
(
key
==
9
&&
!
event
.
shiftKey
))
{
// enter or tab
if
(
table
.
rows
.
length
>
selectedRow
)
{
var
row
=
table
.
rows
[
selectedRow
];
if
(
row
.
cells
.
length
>
1
)
{
...
...
@@ -235,12 +237,14 @@ function keyDown(event) {
return
false
;
}
}
else
if
(
key
==
38
&&
!
event
.
shiftKey
)
{
// up
if
(
table
.
rows
.
length
>
selectedRow
)
{
selectedRow
=
selectedRow
<=
0
?
table
.
rows
.
length
-
1
:
selectedRow
-
1
;
highlightRow
(
selectedRow
);
}
return
false
;
}
else
if
(
key
==
40
&&
!
event
.
shiftKey
)
{
// down
if
(
table
.
rows
.
length
>
selectedRow
)
{
selectedRow
=
selectedRow
>=
table
.
rows
.
length
-
1
?
0
:
selectedRow
+
1
;
highlightRow
(
selectedRow
);
...
...
@@ -252,10 +256,21 @@ function keyDown(event) {
// alert('key:' + key);
// bs:8 ret:13 lt:37 up:38 rt:39 dn:40 tab:9
// pgup:33 pgdn:34 home:36 end:35 del:46 shift:16
// ctrl,alt gr:17 alt:18 caps:20 5(num):12 ins:45
// ctrl,
alt gr:17 alt:18 caps:20 5(num):12 ins:45
// pause:19 f1..13:112..123 win-start:91 win-ctx:93 esc:27
}
function
keyUp
(
event
)
{
if
(
autoComplete
!=
0
)
{
var
key
=
event
==
null
?
0
:
(
event
.
keyCode
?
event
.
keyCode
:
event
.
charCode
);
if
(
key
!=
37
&&
key
!=
38
&&
key
!=
39
&&
key
!=
40
)
{
// left, right, up, down: don't show autocomplete
showAutoComplete
();
}
}
return
true
;
}
function
setAutoComplete
(
value
)
{
autoComplete
=
value
;
if
(
value
!=
1
)
{
...
...
@@ -325,7 +340,7 @@ function showList(s) {
for
(
var
i
=
0
;
list
!=
null
&&
i
<
list
.
length
;
i
++
)
{
var
kv
=
list
[
i
].
split
(
'#'
);
var
type
=
kv
[
0
];
if
(
type
>
0
&&
autoComplete
!=
2
)
{
if
(
type
>
0
&&
autoComplete
!=
2
&&
!
autoCompleteManual
)
{
continue
;
}
var
row
=
doc
.
createElement
(
"tr"
);
...
...
@@ -365,6 +380,7 @@ function showList(s) {
}
// scroll to the top left
top
.
h2result
.
scrollTo
(
0
,
0
);
autoCompleteManual
=
false
;
}
function
retrieveList
(
s
)
{
...
...
@@ -436,7 +452,7 @@ function processAsyncResponse() {
<div
style=
"display:none"
>
<iframe
id=
"h2iframeTransport"
src=
""
onload=
"showList(this.contentWindow.document.body.innerHTML);"
></iframe>
</div>
<textarea
id=
"sql"
name=
"sql"
cols=
"80"
rows=
"5"
onkeydown=
"return keyDown(event)"
onkeyup=
"return keyUp(
)"
<textarea
id=
"sql"
name=
"sql"
cols=
"80"
rows=
"5"
onkeydown=
"return keyDown(event)"
onkeyup=
"return keyUp(
event)"
onfocus=
"keyUp()"
onchange=
"return keyUp()"
>
${query}
</textarea>
</form>
</body>
...
...
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
e9b4498c
...
...
@@ -351,6 +351,33 @@ public class DiskFile implements CacheWriter {
}
}
public
void
flushNew
()
throws
SQLException
{
int
todoTest
;
synchronized
(
database
)
{
database
.
checkPowerOff
();
ObjectArray
list
=
cache
.
getAllChanged
();
CacheObject
.
sort
(
list
);
int
deletePos
=
deleted
.
nextSetBit
(
0
);
int
writeIndex
=
0
;
Record
writeRecord
=
null
;
while
(
true
)
{
if
(
writeRecord
==
null
&&
writeIndex
<
list
.
size
())
{
writeRecord
=
(
Record
)
list
.
get
(
writeIndex
++);
}
if
(
writeRecord
!=
null
&&
(
deletePos
<
0
||
writeRecord
.
getPos
()
<
deletePos
))
{
writeBack
(
writeRecord
);
writeRecord
=
null
;
}
else
if
(
deletePos
<
fileBlockCount
&&
deletePos
>=
0
)
{
writeDirectDeleted
(
deletePos
,
1
);
deleted
.
clear
(
deletePos
);
deletePos
=
deleted
.
nextSetBit
(
deletePos
);
}
else
{
break
;
}
}
}
}
public
void
close
()
throws
SQLException
{
synchronized
(
database
)
{
SQLException
closeException
=
null
;
...
...
@@ -888,8 +915,6 @@ public class DiskFile implements CacheWriter {
if
(
last
!=
null
&&
last
.
data
!=
null
)
{
writeRedoLog
(
last
);
}
redoBuffer
.
clear
();
redoBufferSize
=
0
;
}
...
...
@@ -917,4 +942,8 @@ public class DiskFile implements CacheWriter {
}
}
public
String
toString
()
{
return
getClass
().
getName
()
+
":"
+
fileName
;
}
}
h2/src/main/org/h2/store/fs/FileSystemDisk.java
浏览文件 @
e9b4498c
...
...
@@ -36,7 +36,7 @@ public class FileSystemDisk extends FileSystem {
return
INSTANCE
;
}
pr
ivate
FileSystemDisk
()
{
pr
otected
FileSystemDisk
()
{
}
public
long
length
(
String
fileName
)
{
...
...
h2/src/main/org/h2/table/TableData.java
浏览文件 @
e9b4498c
...
...
@@ -143,7 +143,7 @@ public class TableData extends Table implements RecordReader {
public
Index
addIndex
(
Session
session
,
String
indexName
,
int
indexId
,
IndexColumn
[]
cols
,
IndexType
indexType
,
int
headPos
,
String
indexComment
)
throws
SQLException
{
if
(
indexType
.
isPrimaryKey
())
{
indexName
=
getSchema
().
getUniqueIndexName
(
Constants
.
PRIMARY_KEY_PREFIX
);
indexName
=
getSchema
().
getUniqueIndexName
(
this
,
Constants
.
PRIMARY_KEY_PREFIX
);
for
(
int
i
=
0
;
i
<
cols
.
length
;
i
++)
{
Column
column
=
cols
[
i
].
column
;
if
(
column
.
getNullable
())
{
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
e9b4498c
...
...
@@ -152,24 +152,17 @@ java org.h2.test.TestAll timer
/*
History:
The performance has been improved for ResultSet methods with column name.
The method Trigger.init has been changed: the parameters 'before' and 'type', have been added to the init method.
The Ukrainian translation was not working in the last release. Fixed.
Creating many tables (many hundreds) was slow. Fixed.
Opening a database with many indexes (thousands) was slow. Fixed.
C:\temp\test\db
No more
@author
autocomplete only just after meaningful key (ctrl+space, space, bs, ...)
write more tests for the command line tools
C:\temp\test\db
Known Problems
:
Web site
:
link to history page, bug page
Add a link to the google code bug page
implement & test: checkpoint commits running transactions
test DbStarter
----
...
...
@@ -203,8 +196,6 @@ shrink newsletter list (migrate to google groups)
don't create @~ of not translated
test performance and document fulltext search
clustered tables: test, document
extend tests that simulate power off
...
...
@@ -297,6 +288,7 @@ Features of H2
if
(
args
.
length
>
0
)
{
if
(
"crash"
.
equals
(
args
[
0
]))
{
test
.
endless
=
true
;
new
TestCrashAPI
().
runTest
(
test
);
}
else
if
(
"synth"
.
equals
(
args
[
0
]))
{
new
TestSynth
().
runTest
(
test
);
...
...
@@ -620,6 +612,7 @@ Features of H2
new
TestMVCC
().
runTest
(
this
);
// synthetic
new
TestCrashAPI
().
runTest
(
this
);
new
TestRandomSQL
().
runTest
(
this
);
new
TestKillRestart
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
e9b4498c
...
...
@@ -52,6 +52,9 @@ public abstract class TestBase {
}
public
void
runTest
(
TestAll
conf
)
{
if
(
conf
.
networked
)
{
return
;
}
try
{
init
(
conf
);
start
=
System
.
currentTimeMillis
();
...
...
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
e9b4498c
...
...
@@ -5,8 +5,10 @@
package
org
.
h2
.
test
.
db
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
java.util.StringTokenizer
;
import
org.h2.test.TestBase
;
...
...
@@ -17,17 +19,59 @@ public class TestFullText extends TestBase {
return
;
}
test
(
false
);
testPerformance
(
false
);
String
luceneFullTextClassName
=
"org.h2.fulltext.FullTextLucene"
;
try
{
Class
.
forName
(
luceneFullTextClassName
);
test
(
true
);
testPerformance
(
true
);
}
catch
(
ClassNotFoundException
e
)
{
this
.
println
(
"Class not found, not tested: "
+
luceneFullTextClassName
);
println
(
"Class not found, not tested: "
+
luceneFullTextClassName
);
// ok
}
}
private
void
testPerformance
(
boolean
lucene
)
throws
Exception
{
deleteDb
(
"fullText"
);
Connection
conn
=
getConnection
(
"fullText"
);
String
prefix
=
lucene
?
"FTL"
:
"FT"
;
Statement
stat
=
conn
.
createStatement
();
String
className
=
lucene
?
"FullTextLucene"
:
"FullText"
;
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS "
+
prefix
+
"_INIT FOR \"org.h2.fulltext."
+
className
+
".init\""
);
stat
.
execute
(
"CALL "
+
prefix
+
"_INIT()"
);
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST AS SELECT * FROM INFORMATION_SCHEMA.HELP"
);
stat
.
execute
(
"ALTER TABLE TEST ALTER COLUMN ID INT NOT NULL"
);
stat
.
execute
(
"CREATE PRIMARY KEY ON TEST(ID)"
);
long
time
=
System
.
currentTimeMillis
();
stat
.
execute
(
"CALL "
+
prefix
+
"_CREATE_INDEX('PUBLIC', 'TEST', NULL)"
);
println
(
"Create index "
+
prefix
+
": "
+
(
System
.
currentTimeMillis
()
-
time
)
+
" ms"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT * FROM "
+
prefix
+
"_SEARCH(?, 0, 0)"
);
time
=
System
.
currentTimeMillis
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT TEXT FROM TEST"
);
int
count
=
0
;
while
(
rs
.
next
())
{
String
text
=
rs
.
getString
(
1
);
StringTokenizer
tokenizer
=
new
StringTokenizer
(
text
,
" ()[].,;:-+*/!?=<>{}#@'\"~$_%&|"
);
while
(
tokenizer
.
hasMoreTokens
())
{
String
word
=
tokenizer
.
nextToken
();
if
(
word
.
length
()
<
10
)
{
continue
;
}
prep
.
setString
(
1
,
word
);
ResultSet
rs2
=
prep
.
executeQuery
();
while
(
rs2
.
next
())
{
rs2
.
getString
(
1
);
count
++;
}
}
}
println
(
"Search "
+
prefix
+
": "
+
(
System
.
currentTimeMillis
()
-
time
)
+
" ms, count: "
+
count
);
stat
.
execute
(
"CALL "
+
prefix
+
"_DROP_ALL()"
);
conn
.
close
();
}
private
void
test
(
boolean
lucene
)
throws
Exception
{
deleteDb
(
"fullText"
);
Connection
conn
=
getConnection
(
"fullText"
);
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
e9b4498c
...
...
@@ -578,7 +578,7 @@ public class TestMetaData extends TestBase {
testResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"FALSE"
,
catalog
,
"IDX_DATE"
,
""
+
DatabaseMetaData
.
tableIndexOther
,
"1"
,
"DATE_V"
,
"A"
,
"0"
,
"0"
,
""
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"FALSE"
,
catalog
,
"PRIMARY_KEY_
1
"
,
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"FALSE"
,
catalog
,
"PRIMARY_KEY_
2
"
,
""
+
DatabaseMetaData
.
tableIndexOther
,
"1"
,
"ID"
,
"A"
,
"0"
,
"0"
,
""
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"TRUE"
,
catalog
,
"IDX_TEXT_DEC"
,
""
+
DatabaseMetaData
.
tableIndexOther
,
"1"
,
"TEXT_V"
,
"A"
,
"0"
,
"0"
,
""
},
...
...
@@ -593,14 +593,14 @@ public class TestMetaData extends TestBase {
DataType
.
TYPE_BOOLEAN
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
SMALLINT
,
Types
.
SMALLINT
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
INTEGER
},
null
,
null
);
testResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"FALSE"
,
catalog
,
"PRIMARY_KEY_
1
"
,
""
+
DatabaseMetaData
.
tableIndexOther
,
"1"
,
"ID"
,
"A"
,
"0"
,
"0"
,
""
}
});
"PRIMARY_KEY_
2
"
,
""
+
DatabaseMetaData
.
tableIndexOther
,
"1"
,
"ID"
,
"A"
,
"0"
,
"0"
,
""
}
});
trace
(
"getPrimaryKeys"
);
rs
=
meta
.
getPrimaryKeys
(
null
,
null
,
"TEST"
);
testResultSetMeta
(
rs
,
6
,
new
String
[]
{
"TABLE_CAT"
,
"TABLE_SCHEM"
,
"TABLE_NAME"
,
"COLUMN_NAME"
,
"KEY_SEQ"
,
"PK_NAME"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
SMALLINT
,
Types
.
VARCHAR
},
null
,
null
);
testResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"ID"
,
"1"
,
"PRIMARY_KEY_
1
"
},
});
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"ID"
,
"1"
,
"PRIMARY_KEY_
2
"
},
});
trace
(
"getTables - using a wildcard"
);
stat
.
executeUpdate
(
"CREATE TABLE T_2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))"
);
stat
.
executeUpdate
(
"CREATE TABLE TX2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))"
);
...
...
@@ -719,21 +719,21 @@ public class TestMetaData extends TestBase {
* null,
* null
*/
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TX2"
,
"FALSE"
,
catalog
,
"PRIMARY_KEY_
3
"
,
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TX2"
,
"FALSE"
,
catalog
,
"PRIMARY_KEY_
146
"
,
""
+
DatabaseMetaData
.
tableIndexOther
,
"1"
,
"C"
,
"A"
/*
* ,
* null,
* null,
* null
*/
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TX2"
,
"FALSE"
,
catalog
,
"PRIMARY_KEY_
3
"
,
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TX2"
,
"FALSE"
,
catalog
,
"PRIMARY_KEY_
146
"
,
""
+
DatabaseMetaData
.
tableIndexOther
,
"2"
,
"A"
,
"A"
/*
* ,
* null,
* null,
* null
*/
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TX2"
,
"FALSE"
,
catalog
,
"PRIMARY_KEY_
3
"
,
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TX2"
,
"FALSE"
,
catalog
,
"PRIMARY_KEY_
146
"
,
""
+
DatabaseMetaData
.
tableIndexOther
,
"3"
,
"B"
,
"A"
/*
* ,
* null,
...
...
@@ -763,9 +763,9 @@ public class TestMetaData extends TestBase {
*/
},
});
trace
(
"getPrimaryKeys"
);
rs
=
meta
.
getPrimaryKeys
(
null
,
null
,
"T_2"
);
testResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"A"
,
"2"
,
"PRIMARY_KEY_
2
"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"B"
,
"3"
,
"PRIMARY_KEY_
2
"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"C"
,
"1"
,
"PRIMARY_KEY_
2
"
},
});
testResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"A"
,
"2"
,
"PRIMARY_KEY_
14
"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"B"
,
"3"
,
"PRIMARY_KEY_
14
"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"C"
,
"1"
,
"PRIMARY_KEY_
14
"
},
});
stat
.
executeUpdate
(
"DROP TABLE TX2"
);
stat
.
executeUpdate
(
"DROP TABLE T_2"
);
stat
.
executeUpdate
(
"CREATE TABLE PARENT(ID INT PRIMARY KEY)"
);
...
...
h2/src/test/org/h2/test/synth/TestCrashAPI.java
浏览文件 @
e9b4498c
...
...
@@ -6,11 +6,16 @@ package org.h2.test.synth;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.sql.BatchUpdateException
;
import
java.sql.Blob
;
import
java.sql.CallableStatement
;
import
java.sql.Clob
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ParameterMetaData
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
...
...
@@ -33,7 +38,8 @@ import org.h2.util.RandomUtils;
*/
public
class
TestCrashAPI
extends
TestBase
{
public
static
final
Class
[]
INTERFACES
=
{
Connection
.
class
,
PreparedStatement
.
class
,
Statement
.
class
,
ResultSet
.
class
,
ResultSetMetaData
.
class
,
Savepoint
.
class
};
ResultSet
.
class
,
ResultSetMetaData
.
class
,
Savepoint
.
class
,
ParameterMetaData
.
class
,
Clob
.
class
,
Blob
.
class
,
Array
.
class
,
CallableStatement
.
class
};
private
ArrayList
objects
=
new
ArrayList
();
private
HashMap
classMethods
=
new
HashMap
();
private
RandomGen
random
=
new
RandomGen
(
null
);
...
...
@@ -376,7 +382,8 @@ public class TestCrashAPI extends TestBase {
}
public
void
test
()
throws
Exception
{
while
(
true
)
{
int
len
=
getSize
(
2
,
6
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
seed
=
RandomUtils
.
nextInt
(
Integer
.
MAX_VALUE
);
testCase
(
seed
);
deleteDb
();
...
...
h2/src/test/org/h2/test/test.in.txt
浏览文件 @
e9b4498c
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论