Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
86cb1379
提交
86cb1379
authored
1月 10, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
e5e6830b
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
305 行增加
和
288 行删除
+305
-288
history.html
h2/src/docsrc/html/history.html
+2
-0
mainWeb.html
h2/src/docsrc/html/mainWeb.html
+119
-119
Script.java
h2/src/main/org/h2/command/dml/Script.java
+36
-30
TransactionCommand.java
h2/src/main/org/h2/command/dml/TransactionCommand.java
+11
-6
Constants.java
h2/src/main/org/h2/engine/Constants.java
+4
-6
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+1
-4
BtreeIndex.java
h2/src/main/org/h2/index/BtreeIndex.java
+2
-1
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+1
-1
Recover.java
h2/src/main/org/h2/tools/Recover.java
+1
-1
JdbcUtils.java
h2/src/main/org/h2/util/JdbcUtils.java
+4
-0
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+6
-87
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+5
-3
TestPowerOff.java
h2/src/test/org/h2/test/db/TestPowerOff.java
+46
-0
test.in.txt
h2/src/test/org/h2/test/test.in.txt
+67
-30
没有找到文件。
h2/src/docsrc/html/history.html
浏览文件 @
86cb1379
...
@@ -35,6 +35,8 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
...
@@ -35,6 +35,8 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>
Version 1.0 (Current)
</h3>
<h3>
Version 1.0 (Current)
</h3>
<h3>
Version 1.0 / TODO
</h3><ul>
<h3>
Version 1.0 / TODO
</h3><ul>
<li>
Fixed a problem where data that was in the log file did not end up in the database (recovery failure) a crash, if an index was deleted previously.
<li>
SCRIPT NODATA now writes the row count for each table (this simplifies comparing databases).
<li>
Selecting a column using the syntax schemaName.tableName.columName did not work in all cases.
<li>
Selecting a column using the syntax schemaName.tableName.columName did not work in all cases.
<li>
Can now parse timestamps with timezone information (Z or +/-hh:mm) and dates before year 1.
<li>
Can now parse timestamps with timezone information (Z or +/-hh:mm) and dates before year 1.
However dates before year 1 are not formatted correctly (this is a Java problem).
However dates before year 1 are not formatted correctly (this is a Java problem).
...
...
h2/src/docsrc/html/mainWeb.html
浏览文件 @
86cb1379
差异被折叠。
点击展开。
h2/src/main/org/h2/command/dml/Script.java
浏览文件 @
86cb1379
...
@@ -194,44 +194,50 @@ public class Script extends ScriptBase {
...
@@ -194,44 +194,50 @@ public class Script extends ScriptBase {
}
}
String
tableType
=
table
.
getTableType
();
String
tableType
=
table
.
getTableType
();
add
(
sql
,
false
);
add
(
sql
,
false
);
if
(
data
&&
Table
.
TABLE
.
equals
(
tableType
))
{
if
(
Table
.
TABLE
.
equals
(
tableType
))
{
PlanItem
plan
=
table
.
getBestPlanItem
(
session
,
null
);
if
(
table
.
canGetRowCount
())
{
Index
index
=
plan
.
getIndex
();
String
rowcount
=
"-- "
+
table
.
getRowCount
()
+
" = SELECT COUNT(*) FROM "
+
table
.
getSQL
();
Cursor
cursor
=
index
.
find
(
session
,
null
,
null
);
add
(
rowcount
,
false
);
Column
[]
columns
=
table
.
getColumns
();
String
ins
=
"INSERT INTO "
+
table
.
getSQL
()
+
"("
;
for
(
int
j
=
0
;
j
<
columns
.
length
;
j
++)
{
if
(
j
>
0
)
{
ins
+=
", "
;
}
ins
+=
Parser
.
quoteIdentifier
(
columns
[
j
].
getName
());
}
}
ins
+=
") VALUES("
;
if
(
data
)
{
while
(
cursor
.
next
())
{
PlanItem
plan
=
table
.
getBestPlanItem
(
session
,
null
);
Row
row
=
cursor
.
get
();
Index
index
=
plan
.
getIndex
();
String
s
=
ins
;
Cursor
cursor
=
index
.
find
(
session
,
null
,
null
);
for
(
int
j
=
0
;
j
<
row
.
getColumnCount
();
j
++)
{
Column
[]
columns
=
table
.
getColumns
();
String
ins
=
"INSERT INTO "
+
table
.
getSQL
()
+
"("
;
for
(
int
j
=
0
;
j
<
columns
.
length
;
j
++)
{
if
(
j
>
0
)
{
if
(
j
>
0
)
{
s
+=
", "
;
in
s
+=
", "
;
}
}
Value
v
=
row
.
getValue
(
j
);
ins
+=
Parser
.
quoteIdentifier
(
columns
[
j
].
getName
());
if
(
v
.
getPrecision
()
>
lobBlockSize
)
{
}
int
id
;
ins
+=
") VALUES("
;
if
(
v
.
getType
()
==
Value
.
CLOB
)
{
while
(
cursor
.
next
())
{
id
=
writeLobStream
((
ValueLob
)
v
);
Row
row
=
cursor
.
get
();
s
+=
"SYSTEM_COMBINE_CLOB("
+
id
+
")"
;
String
s
=
ins
;
}
else
if
(
v
.
getType
()
==
Value
.
BLOB
)
{
for
(
int
j
=
0
;
j
<
row
.
getColumnCount
();
j
++)
{
id
=
writeLobStream
((
ValueLob
)
v
);
if
(
j
>
0
)
{
s
+=
"SYSTEM_COMBINE_BLOB("
+
id
+
")"
;
s
+=
", "
;
}
Value
v
=
row
.
getValue
(
j
);
if
(
v
.
getPrecision
()
>
lobBlockSize
)
{
int
id
;
if
(
v
.
getType
()
==
Value
.
CLOB
)
{
id
=
writeLobStream
((
ValueLob
)
v
);
s
+=
"SYSTEM_COMBINE_CLOB("
+
id
+
")"
;
}
else
if
(
v
.
getType
()
==
Value
.
BLOB
)
{
id
=
writeLobStream
((
ValueLob
)
v
);
s
+=
"SYSTEM_COMBINE_BLOB("
+
id
+
")"
;
}
else
{
s
+=
v
.
getSQL
();
}
}
else
{
}
else
{
s
+=
v
.
getSQL
();
s
+=
v
.
getSQL
();
}
}
}
else
{
s
+=
v
.
getSQL
();
}
}
s
+=
")"
;
add
(
s
,
true
);
}
}
s
+=
")"
;
add
(
s
,
true
);
}
}
}
}
ObjectArray
indexes
=
table
.
getIndexes
();
ObjectArray
indexes
=
table
.
getIndexes
();
...
...
h2/src/main/org/h2/command/dml/TransactionCommand.java
浏览文件 @
86cb1379
...
@@ -4,7 +4,10 @@
...
@@ -4,7 +4,10 @@
*/
*/
package
org
.
h2
.
command
.
dml
;
package
org
.
h2
.
command
.
dml
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
java.util.zip.ZipFile
;
import
java.util.zip.ZipOutputStream
;
import
java.util.zip.ZipOutputStream
;
...
@@ -127,13 +130,15 @@ public class TransactionCommand extends Prepared {
...
@@ -127,13 +130,15 @@ public class TransactionCommand extends Prepared {
return
0
;
return
0
;
}
}
private
void
backupTo
(
String
fileName
)
{
private
void
backupTo
(
String
fileName
)
throws
SQLException
{
// ZipOutputStream out = new ZipOutputStream("test.zip");
// int todoAddSpecialSQLStatement;
// out.putNextEntry(arg0)
// FileOutputStream fileout = new FileOutputStream("test.zip");
// ZipOutputStream out = new ZipOutputStream(fileout);
// out.putNextEntry(new ZipEntry("test.data.db"));
// DiskFile file = session.getDatabase().getDataFile();
// DiskFile file = session.getDatabase().getDataFile();
//
//
session.getDatabase().getLog().incStopDeleteFiles(true);
// session.getDatabase().getLog().incStopDeleteFiles(true);
//
// TODO Auto-generated method stub
// TODO Auto-generated method stub
//
//
session.getDatabase().getLog().setStopDeleteFiles(false);
// session.getDatabase().getLog().setStopDeleteFiles(false);
//
//
}
}
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
86cb1379
...
@@ -48,17 +48,15 @@ package org.h2.engine;
...
@@ -48,17 +48,15 @@ package org.h2.engine;
* - TestSystemExit
* - TestSystemExit
* - Test with hibernate
* - Test with hibernate
* - Scan for viruses
* - Scan for viruses
*
* - Send a mail to Google Groups
* - newsletter: prepare, send (always send to BCC!!)
* - newsletter: prepare, send (always send to BCC!!)
* - http://maven.apache.org/guides/mini/guide-ibiblio-upload.html
* - http://maven.apache.org/guides/mini/guide-ibiblio-upload.html
*
*
* @author Thomas
* @author Thomas
*/
*/
public
class
Constants
{
public
class
Constants
{
public
static
final
int
BUILD_ID
=
3
6
;
public
static
final
int
BUILD_ID
=
3
8
;
private
static
final
String
BUILD
=
"2007-01-
02
"
;
private
static
final
String
BUILD
=
"2007-01-
10
"
;
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
;
...
@@ -204,7 +202,7 @@ public class Constants {
...
@@ -204,7 +202,7 @@ public class Constants {
public
static
final
String
SCRIPT_SQL
=
"script.sql"
;
public
static
final
String
SCRIPT_SQL
=
"script.sql"
;
// for testing only
// for testing only
public
static
int
CACHE_MIN_RECORDS
=
16
;
public
static
final
int
CACHE_MIN_RECORDS
=
16
;
public
static
final
int
MIN_WRITE_DELAY
=
getIntSetting
(
"h2.minWriteDelay"
,
5
);
public
static
final
int
MIN_WRITE_DELAY
=
getIntSetting
(
"h2.minWriteDelay"
,
5
);
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
86cb1379
...
@@ -9,7 +9,6 @@ import java.util.HashMap;
...
@@ -9,7 +9,6 @@ import java.util.HashMap;
import
org.h2.command.Parser
;
import
org.h2.command.Parser
;
import
org.h2.command.dml.Select
;
import
org.h2.command.dml.Select
;
import
org.h2.engine.Constants
;
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
;
...
@@ -21,7 +20,6 @@ import org.h2.table.Table;
...
@@ -21,7 +20,6 @@ import org.h2.table.Table;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
/**
/**
* @author Thomas
* @author Thomas
*/
*/
...
@@ -60,8 +58,7 @@ public class ExpressionColumn extends Expression {
...
@@ -60,8 +58,7 @@ public class ExpressionColumn extends Expression {
if
(
tableAlias
!=
null
)
{
if
(
tableAlias
!=
null
)
{
sql
=
Parser
.
quoteIdentifier
(
tableAlias
)
+
"."
+
sql
;
sql
=
Parser
.
quoteIdentifier
(
tableAlias
)
+
"."
+
sql
;
}
}
if
(
schemaName
!=
null
&&
!
schemaName
.
equals
(
Constants
.
SCHEMA_MAIN
))
{
if
(
schemaName
!=
null
)
{
int
todoTempSolution
;
sql
=
Parser
.
quoteIdentifier
(
schemaName
)
+
"."
+
sql
;
sql
=
Parser
.
quoteIdentifier
(
schemaName
)
+
"."
+
sql
;
}
}
return
sql
;
return
sql
;
...
...
h2/src/main/org/h2/index/BtreeIndex.java
浏览文件 @
86cb1379
...
@@ -84,9 +84,10 @@ public class BtreeIndex extends Index implements RecordReader {
...
@@ -84,9 +84,10 @@ public class BtreeIndex extends Index implements RecordReader {
private
void
setChanged
(
Session
session
)
throws
SQLException
{
private
void
setChanged
(
Session
session
)
throws
SQLException
{
if
(
head
!=
null
&&
!
database
.
getLogIndexChanges
())
{
if
(
head
!=
null
&&
!
database
.
getLogIndexChanges
())
{
// maybe there was a checkpoint, need to invalidate the summary in this case too
database
.
invalidateIndexSummary
();
if
(
head
.
getConsistent
())
{
if
(
head
.
getConsistent
())
{
deletePage
(
session
,
head
);
deletePage
(
session
,
head
);
database
.
invalidateIndexSummary
();
head
.
setConsistent
(
false
);
head
.
setConsistent
(
false
);
flushHead
(
session
);
flushHead
(
session
);
}
}
...
...
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
86cb1379
...
@@ -196,7 +196,7 @@ public class DiskFile implements CacheWriter {
...
@@ -196,7 +196,7 @@ public class DiskFile implements CacheWriter {
ObjectArray
list
=
database
.
getAllStorages
();
ObjectArray
list
=
database
.
getAllStorages
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Storage
s
=
(
Storage
)
list
.
get
(
i
);
Storage
s
=
(
Storage
)
list
.
get
(
i
);
if
(
s
.
getDiskFile
()
==
this
)
{
if
(
s
!=
null
&&
s
.
getDiskFile
()
==
this
)
{
database
.
removeStorage
(
s
.
getId
(),
this
);
database
.
removeStorage
(
s
.
getId
(),
this
);
}
}
}
}
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
86cb1379
...
@@ -717,7 +717,7 @@ public class Recover implements DataHandler {
...
@@ -717,7 +717,7 @@ public class Recover implements DataHandler {
MetaRecord
m
=
(
MetaRecord
)
schema
.
get
(
i
);
MetaRecord
m
=
(
MetaRecord
)
schema
.
get
(
i
);
writer
.
println
(
m
.
getSQL
()
+
";"
);
writer
.
println
(
m
.
getSQL
()
+
";"
);
}
}
for
(
Iterator
it
=
tableMap
.
ke
ySet
().
iterator
();
it
.
hasNext
();
)
{
for
(
Iterator
it
=
tableMap
.
entr
ySet
().
iterator
();
it
.
hasNext
();
)
{
Map
.
Entry
entry
=
(
Entry
)
it
.
next
();
Map
.
Entry
entry
=
(
Entry
)
it
.
next
();
Integer
objectId
=
(
Integer
)
entry
.
getKey
();
Integer
objectId
=
(
Integer
)
entry
.
getKey
();
String
name
=
(
String
)
entry
.
getValue
();
String
name
=
(
String
)
entry
.
getValue
();
...
...
h2/src/main/org/h2/util/JdbcUtils.java
浏览文件 @
86cb1379
/*
* 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
.
util
;
package
org
.
h2
.
util
;
import
java.sql.Connection
;
import
java.sql.Connection
;
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
86cb1379
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
86cb1379
...
@@ -147,7 +147,7 @@ public class TestCases extends TestBase {
...
@@ -147,7 +147,7 @@ public class TestCases extends TestBase {
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
stat
.
execute
(
"INSERT INTO TEST() VALUES()"
);
stat
.
execute
(
"INSERT INTO TEST() VALUES()"
);
}
}
final
boolean
[]
stopped
=
new
boolea
n
[
1
];
final
SQLException
[]
stopped
=
new
SQLExceptio
n
[
1
];
Thread
t
=
new
Thread
(
new
Runnable
()
{
Thread
t
=
new
Thread
(
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
try
{
try
{
...
@@ -157,9 +157,9 @@ public class TestCases extends TestBase {
...
@@ -157,9 +157,9 @@ public class TestCases extends TestBase {
time
=
System
.
currentTimeMillis
()
-
time
;
time
=
System
.
currentTimeMillis
()
-
time
;
TestBase
.
logError
(
"query was too quick; result: "
+
rs
.
getInt
(
1
)
+
" time:"
+
time
,
null
);
TestBase
.
logError
(
"query was too quick; result: "
+
rs
.
getInt
(
1
)
+
" time:"
+
time
,
null
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
stopped
[
0
]
=
e
;
// ok
// ok
}
}
stopped
[
0
]
=
true
;
}
}
});
});
t
.
start
();
t
.
start
();
...
@@ -167,8 +167,10 @@ public class TestCases extends TestBase {
...
@@ -167,8 +167,10 @@ public class TestCases extends TestBase {
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
conn
.
close
();
conn
.
close
();
t
.
join
(
5000
);
t
.
join
(
5000
);
if
(
!
stopped
[
0
]
)
{
if
(
stopped
[
0
]
==
null
)
{
error
(
"query still running"
);
error
(
"query still running"
);
}
else
{
checkNotGeneralException
(
stopped
[
0
]);
}
}
time
=
System
.
currentTimeMillis
()
-
time
;
time
=
System
.
currentTimeMillis
()
-
time
;
if
(
time
>
5000
)
{
if
(
time
>
5000
)
{
...
...
h2/src/test/org/h2/test/db/TestPowerOff.java
浏览文件 @
86cb1379
...
@@ -18,6 +18,7 @@ import org.h2.jdbc.JdbcConnection;
...
@@ -18,6 +18,7 @@ import org.h2.jdbc.JdbcConnection;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.FileBase
;
import
org.h2.tools.FileBase
;
import
org.h2.util.FileUtils
;
import
org.h2.util.FileUtils
;
import
org.h2.util.JdbcUtils
;
public
class
TestPowerOff
extends
TestBase
{
public
class
TestPowerOff
extends
TestBase
{
...
@@ -36,6 +37,7 @@ public class TestPowerOff extends TestBase {
...
@@ -36,6 +37,7 @@ public class TestPowerOff extends TestBase {
dir
=
"inmemory:"
;
dir
=
"inmemory:"
;
}
}
url
=
dir
+
"/"
+
dbName
+
";file_lock=no"
;
url
=
dir
+
"/"
+
dbName
+
";file_lock=no"
;
testSummaryCrash
();
testCrash
();
testCrash
();
testShutdown
();
testShutdown
();
testNoIndexFile
();
testNoIndexFile
();
...
@@ -43,6 +45,50 @@ public class TestPowerOff extends TestBase {
...
@@ -43,6 +45,50 @@ public class TestPowerOff extends TestBase {
testPersistentTables
();
testPersistentTables
();
}
}
private
void
testSummaryCrash
()
throws
Exception
{
if
(
config
.
networked
)
{
return
;
}
deleteDb
(
dir
,
dbName
);
Connection
conn
=
getConnection
(
url
);
Statement
stat
=
conn
.
createStatement
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
stat
.
execute
(
"CREATE TABLE TEST"
+
i
+
"(ID INT PRIMARY KEY, NAME VARCHAR)"
);
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
stat
.
execute
(
"INSERT INTO TEST"
+
i
+
" VALUES("
+
j
+
", 'Hello')"
);
}
}
for
(
int
i
=
0
;
i
<
10
;
i
+=
2
)
{
stat
.
execute
(
"DROP TABLE TEST"
+
i
);
}
stat
.
execute
(
"SET WRITE_DELAY 0"
);
stat
.
execute
(
"CHECKPOINT"
);
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
stat
.
execute
(
"INSERT INTO TEST1 VALUES("
+(
10
+
j
)+
", 'World')"
);
}
stat
.
execute
(
"SHUTDOWN IMMEDIATELY"
);
JdbcUtils
.
closeSilently
(
conn
);
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
for
(
int
i
=
1
;
i
<
10
;
i
+=
2
)
{
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
+
i
+
" ORDER BY ID"
);
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
rs
.
next
();
check
(
rs
.
getInt
(
1
),
j
);
check
(
rs
.
getString
(
2
),
"Hello"
);
}
if
(
i
==
1
)
{
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
rs
.
next
();
check
(
rs
.
getInt
(
1
),
j
+
10
);
check
(
rs
.
getString
(
2
),
"World"
);
}
}
checkFalse
(
rs
.
next
());
}
conn
.
close
();
}
private
void
testCrash
()
throws
Exception
{
private
void
testCrash
()
throws
Exception
{
if
(
config
.
networked
)
{
if
(
config
.
networked
)
{
return
;
return
;
...
...
h2/src/test/org/h2/test/test.in.txt
浏览文件 @
86cb1379
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论