Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0bf4da12
提交
0bf4da12
authored
8月 02, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Various improvements in the page store mechanism.
上级
6e8730ae
全部展开
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
1105 行增加
和
1045 行删除
+1105
-1045
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
_docs_en.utf8.txt
h2/src/docsrc/text/_docs_en.utf8.txt
+333
-330
_docs_ja.utf8.txt
h2/src/docsrc/text/_docs_ja.utf8.txt
+333
-330
_docs_en.properties
h2/src/docsrc/textbase/_docs_en.properties
+332
-331
PageBtree.java
h2/src/main/org/h2/index/PageBtree.java
+1
-1
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+4
-0
PageScanCursor.java
h2/src/main/org/h2/index/PageScanCursor.java
+1
-1
ViewCursor.java
h2/src/main/org/h2/index/ViewCursor.java
+1
-1
ResultTempTable.java
h2/src/main/org/h2/result/ResultTempTable.java
+5
-5
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+27
-8
TableData.java
h2/src/main/org/h2/table/TableData.java
+14
-13
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+11
-9
TestScript.java
h2/src/test/org/h2/test/db/TestScript.java
+16
-14
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+4
-1
TestPageStore.java
h2/src/test/org/h2/test/unit/TestPageStore.java
+21
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
0bf4da12
...
@@ -18,7 +18,8 @@ Change Log
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
The functions LENGTH, OCTET_LENGTH, and BIT_LENGTH now return BIGINT.
<ul><li>
Various improvements in the page store mechanism (still experimental).
</li><li>
The functions LENGTH, OCTET_LENGTH, and BIT_LENGTH now return BIGINT.
</li><li>
Data types CLOB and BLOB: the maximum precision was Integer.MAX_VALUE, it is now Long.MAX_VALUE.
</li><li>
Data types CLOB and BLOB: the maximum precision was Integer.MAX_VALUE, it is now Long.MAX_VALUE.
</li><li>
Multi-threaded kernel: creating and dropping temporary database objects
</li><li>
Multi-threaded kernel: creating and dropping temporary database objects
and the potentially free pages list was not correctly synchronized. Thanks a lot
and the potentially free pages list was not correctly synchronized. Thanks a lot
...
...
h2/src/docsrc/text/_docs_en.utf8.txt
浏览文件 @
0bf4da12
差异被折叠。
点击展开。
h2/src/docsrc/text/_docs_ja.utf8.txt
浏览文件 @
0bf4da12
差异被折叠。
点击展开。
h2/src/docsrc/textbase/_docs_en.properties
浏览文件 @
0bf4da12
差异被折叠。
点击展开。
h2/src/main/org/h2/index/PageBtree.java
浏览文件 @
0bf4da12
...
@@ -107,7 +107,7 @@ abstract class PageBtree extends Record {
...
@@ -107,7 +107,7 @@ abstract class PageBtree extends Record {
SearchRow
row
=
getRow
(
i
);
SearchRow
row
=
getRow
(
i
);
comp
=
index
.
compareRows
(
row
,
compare
);
comp
=
index
.
compareRows
(
row
,
compare
);
if
(
comp
==
0
&&
add
)
{
if
(
comp
==
0
&&
add
)
{
if
(
index
.
indexType
.
get
Unique
())
{
if
(
index
.
indexType
.
is
Unique
())
{
if
(!
index
.
containsNullAndAllowMultipleNull
(
compare
))
{
if
(!
index
.
containsNullAndAllowMultipleNull
(
compare
))
{
throw
index
.
getDuplicateKeyException
();
throw
index
.
getDuplicateKeyException
();
}
}
...
...
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
0bf4da12
...
@@ -9,6 +9,7 @@ package org.h2.index;
...
@@ -9,6 +9,7 @@ package org.h2.index;
import
java.lang.ref.SoftReference
;
import
java.lang.ref.SoftReference
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.message.Message
;
import
org.h2.message.Message
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
...
@@ -115,6 +116,9 @@ class PageDataLeaf extends PageData {
...
@@ -115,6 +116,9 @@ class PageDataLeaf extends PageData {
}
else
{
}
else
{
readAllRows
();
readAllRows
();
x
=
find
(
row
.
getPos
());
x
=
find
(
row
.
getPos
());
if
(
SysProperties
.
CHECK
&&
x
<
keys
.
length
&&
keys
[
x
]
==
row
.
getPos
())
{
throw
Message
.
throwInternalError
(
""
+
row
.
getPos
());
}
System
.
arraycopy
(
offsets
,
0
,
newOffsets
,
0
,
x
);
System
.
arraycopy
(
offsets
,
0
,
newOffsets
,
0
,
x
);
System
.
arraycopy
(
keys
,
0
,
newKeys
,
0
,
x
);
System
.
arraycopy
(
keys
,
0
,
newKeys
,
0
,
x
);
System
.
arraycopy
(
rows
,
0
,
newRows
,
0
,
x
);
System
.
arraycopy
(
rows
,
0
,
newRows
,
0
,
x
);
...
...
h2/src/main/org/h2/index/PageScanCursor.java
浏览文件 @
0bf4da12
...
@@ -60,7 +60,7 @@ class PageScanCursor implements Cursor {
...
@@ -60,7 +60,7 @@ class PageScanCursor implements Cursor {
continue
;
continue
;
}
}
row
=
delta
.
next
();
row
=
delta
.
next
();
if
(!
row
.
get
Deleted
()
||
row
.
getSessionId
()
==
session
.
getId
())
{
if
(!
row
.
is
Deleted
()
||
row
.
getSessionId
()
==
session
.
getId
())
{
continue
;
continue
;
}
}
}
else
{
}
else
{
...
...
h2/src/main/org/h2/index/ViewCursor.java
浏览文件 @
0bf4da12
...
@@ -45,7 +45,7 @@ public class ViewCursor implements Cursor {
...
@@ -45,7 +45,7 @@ public class ViewCursor implements Cursor {
public
boolean
next
()
throws
SQLException
{
public
boolean
next
()
throws
SQLException
{
boolean
res
=
result
.
next
();
boolean
res
=
result
.
next
();
if
(!
res
)
{
if
(!
res
)
{
result
.
reset
();
result
.
close
();
current
=
null
;
current
=
null
;
return
false
;
return
false
;
}
}
...
...
h2/src/main/org/h2/result/ResultTempTable.java
浏览文件 @
0bf4da12
...
@@ -44,7 +44,8 @@ public class ResultTempTable implements ResultExternal {
...
@@ -44,7 +44,8 @@ public class ResultTempTable implements ResultExternal {
columns
.
add
(
column
);
columns
.
add
(
column
);
int
tableId
=
session
.
getDatabase
().
allocateObjectId
(
true
,
true
);
int
tableId
=
session
.
getDatabase
().
allocateObjectId
(
true
,
true
);
String
tableName
=
"TEMP_RESULT_SET_"
+
tableId
;
String
tableName
=
"TEMP_RESULT_SET_"
+
tableId
;
table
=
schema
.
createTable
(
tableName
,
tableId
,
columns
,
false
,
true
,
false
,
Index
.
EMPTY_HEAD
,
session
);
table
=
schema
.
createTable
(
tableName
,
tableId
,
columns
,
true
,
false
,
true
,
false
,
Index
.
EMPTY_HEAD
,
session
);
session
.
addLocalTempTable
(
table
);
int
indexId
=
session
.
getDatabase
().
allocateObjectId
(
true
,
false
);
int
indexId
=
session
.
getDatabase
().
allocateObjectId
(
true
,
false
);
IndexColumn
indexColumn
=
new
IndexColumn
();
IndexColumn
indexColumn
=
new
IndexColumn
();
indexColumn
.
column
=
column
;
indexColumn
.
column
=
column
;
...
@@ -57,6 +58,8 @@ public class ResultTempTable implements ResultExternal {
...
@@ -57,6 +58,8 @@ public class ResultTempTable implements ResultExternal {
}
else
{
}
else
{
index
=
new
BtreeIndex
(
session
,
table
,
indexId
,
tableName
,
indexCols
,
indexType
,
Index
.
EMPTY_HEAD
);
index
=
new
BtreeIndex
(
session
,
table
,
indexId
,
tableName
,
indexCols
,
indexType
,
Index
.
EMPTY_HEAD
);
}
}
index
.
setTemporary
(
true
);
session
.
addLocalTempTableIndex
(
index
);
table
.
getIndexes
().
add
(
index
);
table
.
getIndexes
().
add
(
index
);
}
}
...
@@ -95,10 +98,7 @@ public class ResultTempTable implements ResultExternal {
...
@@ -95,10 +98,7 @@ public class ResultTempTable implements ResultExternal {
public
void
close
()
{
public
void
close
()
{
try
{
try
{
if
(
table
!=
null
)
{
if
(
table
!=
null
)
{
index
.
remove
(
session
);
session
.
removeLocalTempTable
(
table
);
ObjectArray
<
Index
>
indexes
=
table
.
getIndexes
();
indexes
.
remove
(
indexes
.
indexOf
(
index
));
table
.
removeChildrenAndResources
(
session
);
}
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
Message
.
convertToInternal
(
e
);
throw
Message
.
convertToInternal
(
e
);
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
0bf4da12
...
@@ -733,24 +733,35 @@ public class PageStore implements CacheWriter {
...
@@ -733,24 +733,35 @@ public class PageStore implements CacheWriter {
openMetaIndex
();
openMetaIndex
();
readMetaData
();
readMetaData
();
log
.
recover
(
PageLog
.
RECOVERY_STAGE_REDO
);
log
.
recover
(
PageLog
.
RECOVERY_STAGE_REDO
);
boolean
setReadOnly
=
false
;
if
(!
database
.
isReadOnly
())
{
if
(!
database
.
isReadOnly
())
{
if
(
log
.
getInDoubtTransactions
().
size
()
==
0
)
{
if
(
log
.
getInDoubtTransactions
().
size
()
==
0
)
{
log
.
recoverEnd
();
log
.
recoverEnd
();
switchLog
();
switchLog
();
}
else
{
}
else
{
database
.
setReadOnly
(
true
)
;
setReadOnly
=
true
;
}
}
}
}
PageScanIndex
index
=
(
PageScanIndex
)
metaObjects
.
get
(
0
);
PageScanIndex
systemTable
=
(
PageScanIndex
)
metaObjects
.
get
(
0
);
if
(
index
==
null
)
{
if
(
systemTable
==
null
)
{
systemTableHeadPos
=
Index
.
EMPTY_HEAD
;
systemTableHeadPos
=
Index
.
EMPTY_HEAD
;
}
else
{
}
else
{
systemTableHeadPos
=
index
.
getHeadPos
();
systemTableHeadPos
=
systemTable
.
getHeadPos
();
}
}
for
(
Index
openIndex
:
metaObjects
.
values
())
{
for
(
Index
openIndex
:
metaObjects
.
values
())
{
if
(
openIndex
.
getTable
().
isTemporary
())
{
openIndex
.
remove
(
systemSession
);
this
.
removeMetaIndex
(
openIndex
,
systemSession
);
}
openIndex
.
close
(
systemSession
);
openIndex
.
close
(
systemSession
);
}
}
recoveryRunning
=
false
;
recoveryRunning
=
false
;
writeBack
();
// clear the cache because it contains pages with closed indexes
cache
.
clear
();
if
(
setReadOnly
)
{
database
.
setReadOnly
(
true
);
}
trace
.
debug
(
"log recover done"
);
trace
.
debug
(
"log recover done"
);
}
}
...
@@ -844,7 +855,7 @@ public class PageStore implements CacheWriter {
...
@@ -844,7 +855,7 @@ public class PageStore implements CacheWriter {
metaSchema
=
new
Schema
(
database
,
0
,
""
,
null
,
true
);
metaSchema
=
new
Schema
(
database
,
0
,
""
,
null
,
true
);
int
headPos
=
PAGE_ID_META_ROOT
;
int
headPos
=
PAGE_ID_META_ROOT
;
metaTable
=
new
TableData
(
metaSchema
,
"PAGE_INDEX"
,
metaTable
=
new
TableData
(
metaSchema
,
"PAGE_INDEX"
,
META_TABLE_ID
,
cols
,
true
,
true
,
false
,
headPos
,
systemSession
);
META_TABLE_ID
,
cols
,
false
,
true
,
true
,
false
,
headPos
,
systemSession
);
metaIndex
=
(
PageScanIndex
)
metaTable
.
getScanIndex
(
metaIndex
=
(
PageScanIndex
)
metaTable
.
getScanIndex
(
systemSession
);
systemSession
);
metaObjects
=
New
.
hashMap
();
metaObjects
=
New
.
hashMap
();
...
@@ -892,8 +903,9 @@ public class PageStore implements CacheWriter {
...
@@ -892,8 +903,9 @@ public class PageStore implements CacheWriter {
Column
col
=
new
Column
(
"C"
+
i
,
Value
.
INT
);
Column
col
=
new
Column
(
"C"
+
i
,
Value
.
INT
);
columnArray
.
add
(
col
);
columnArray
.
add
(
col
);
}
}
TableData
table
=
new
TableData
(
metaSchema
,
"T"
+
id
,
id
,
columnArray
,
true
,
true
,
false
,
headPos
,
session
);
String
[]
ops
=
StringUtils
.
arraySplit
(
options
,
','
,
true
);
String
[]
ops
=
StringUtils
.
arraySplit
(
options
,
','
,
true
);
boolean
temp
=
ops
.
length
==
3
&&
ops
[
2
].
equals
(
"temp"
);
TableData
table
=
new
TableData
(
metaSchema
,
"T"
+
id
,
id
,
columnArray
,
temp
,
true
,
true
,
false
,
headPos
,
session
);
CompareMode
mode
=
CompareMode
.
getInstance
(
ops
[
0
],
Integer
.
parseInt
(
ops
[
1
]));
CompareMode
mode
=
CompareMode
.
getInstance
(
ops
[
0
],
Integer
.
parseInt
(
ops
[
1
]));
table
.
setCompareMode
(
mode
);
table
.
setCompareMode
(
mode
);
meta
=
table
.
getScanIndex
(
session
);
meta
=
table
.
getScanIndex
(
session
);
...
@@ -948,6 +960,9 @@ public class PageStore implements CacheWriter {
...
@@ -948,6 +960,9 @@ public class PageStore implements CacheWriter {
Table
table
=
index
.
getTable
();
Table
table
=
index
.
getTable
();
CompareMode
mode
=
table
.
getCompareMode
();
CompareMode
mode
=
table
.
getCompareMode
();
String
options
=
mode
.
getName
()+
","
+
mode
.
getStrength
();
String
options
=
mode
.
getName
()+
","
+
mode
.
getStrength
();
if
(
table
.
isTemporary
())
{
options
+=
",temp"
;
}
Row
row
=
metaTable
.
getTemplateRow
();
Row
row
=
metaTable
.
getTemplateRow
();
row
.
setValue
(
0
,
ValueInt
.
get
(
index
.
getId
()));
row
.
setValue
(
0
,
ValueInt
.
get
(
index
.
getId
()));
row
.
setValue
(
1
,
ValueInt
.
get
(
type
));
row
.
setValue
(
1
,
ValueInt
.
get
(
type
));
...
@@ -967,10 +982,14 @@ public class PageStore implements CacheWriter {
...
@@ -967,10 +982,14 @@ public class PageStore implements CacheWriter {
*/
*/
public
void
removeMeta
(
Index
index
,
Session
session
)
throws
SQLException
{
public
void
removeMeta
(
Index
index
,
Session
session
)
throws
SQLException
{
if
(!
recoveryRunning
)
{
if
(!
recoveryRunning
)
{
removeMetaIndex
(
index
,
session
);
}
}
private
void
removeMetaIndex
(
Index
index
,
Session
session
)
throws
SQLException
{
Row
row
=
metaIndex
.
getRow
(
session
,
index
.
getId
()
+
1
);
Row
row
=
metaIndex
.
getRow
(
session
,
index
.
getId
()
+
1
);
metaIndex
.
remove
(
session
,
row
);
metaIndex
.
remove
(
session
,
row
);
}
}
}
/**
/**
* Set the maximum log file size in megabytes.
* Set the maximum log file size in megabytes.
...
...
h2/src/main/org/h2/table/TableData.java
浏览文件 @
0bf4da12
...
@@ -66,11 +66,12 @@ public class TableData extends Table implements RecordReader {
...
@@ -66,11 +66,12 @@ public class TableData extends Table implements RecordReader {
private
boolean
containsLargeObject
;
private
boolean
containsLargeObject
;
public
TableData
(
Schema
schema
,
String
tableName
,
int
id
,
ObjectArray
<
Column
>
columns
,
public
TableData
(
Schema
schema
,
String
tableName
,
int
id
,
ObjectArray
<
Column
>
columns
,
boolean
persistIndexes
,
boolean
persistData
,
boolean
clustered
,
int
headPos
,
Session
session
)
throws
SQLException
{
boolean
temporary
,
boolean
persistIndexes
,
boolean
persistData
,
boolean
clustered
,
int
headPos
,
Session
session
)
throws
SQLException
{
super
(
schema
,
id
,
tableName
,
persistIndexes
,
persistData
);
super
(
schema
,
id
,
tableName
,
persistIndexes
,
persistData
);
Column
[]
cols
=
new
Column
[
columns
.
size
()];
Column
[]
cols
=
new
Column
[
columns
.
size
()];
columns
.
toArray
(
cols
);
columns
.
toArray
(
cols
);
setColumns
(
cols
);
setColumns
(
cols
);
setTemporary
(
temporary
);
this
.
clustered
=
clustered
;
this
.
clustered
=
clustered
;
if
(!
clustered
)
{
if
(!
clustered
)
{
if
(
database
.
isPageStoreEnabled
()
&&
persistData
&&
database
.
isPersistent
())
{
if
(
database
.
isPageStoreEnabled
()
&&
persistData
&&
database
.
isPersistent
())
{
...
@@ -159,7 +160,7 @@ public class TableData extends Table implements RecordReader {
...
@@ -159,7 +160,7 @@ public class TableData extends Table implements RecordReader {
public
Index
getUniqueIndex
()
{
public
Index
getUniqueIndex
()
{
for
(
Index
idx
:
indexes
)
{
for
(
Index
idx
:
indexes
)
{
if
(
idx
.
getIndexType
().
get
Unique
())
{
if
(
idx
.
getIndexType
().
is
Unique
())
{
return
idx
;
return
idx
;
}
}
}
}
...
@@ -172,24 +173,24 @@ public class TableData extends Table implements RecordReader {
...
@@ -172,24 +173,24 @@ public class TableData extends Table implements RecordReader {
public
Index
addIndex
(
Session
session
,
String
indexName
,
int
indexId
,
IndexColumn
[]
cols
,
IndexType
indexType
,
public
Index
addIndex
(
Session
session
,
String
indexName
,
int
indexId
,
IndexColumn
[]
cols
,
IndexType
indexType
,
int
headPos
,
String
indexComment
)
throws
SQLException
{
int
headPos
,
String
indexComment
)
throws
SQLException
{
if
(
indexType
.
get
PrimaryKey
())
{
if
(
indexType
.
is
PrimaryKey
())
{
for
(
IndexColumn
c
:
cols
)
{
for
(
IndexColumn
c
:
cols
)
{
Column
column
=
c
.
column
;
Column
column
=
c
.
column
;
if
(
column
.
get
Nullable
())
{
if
(
column
.
is
Nullable
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
COLUMN_MUST_NOT_BE_NULLABLE_1
,
column
.
getName
());
throw
Message
.
getSQLException
(
ErrorCode
.
COLUMN_MUST_NOT_BE_NULLABLE_1
,
column
.
getName
());
}
}
column
.
setPrimaryKey
(
true
);
column
.
setPrimaryKey
(
true
);
}
}
}
}
Index
index
;
Index
index
;
if
(
isPersistIndexes
()
&&
indexType
.
get
Persistent
())
{
if
(
isPersistIndexes
()
&&
indexType
.
is
Persistent
())
{
if
(
database
.
isPageStoreEnabled
())
{
if
(
database
.
isPageStoreEnabled
())
{
index
=
new
PageBtreeIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
,
headPos
,
session
);
index
=
new
PageBtreeIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
,
headPos
,
session
);
}
else
{
}
else
{
index
=
new
BtreeIndex
(
session
,
this
,
indexId
,
indexName
,
cols
,
indexType
,
headPos
);
index
=
new
BtreeIndex
(
session
,
this
,
indexId
,
indexName
,
cols
,
indexType
,
headPos
);
}
}
}
else
{
}
else
{
if
(
indexType
.
get
Hash
())
{
if
(
indexType
.
is
Hash
())
{
index
=
new
HashIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
);
index
=
new
HashIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
);
}
else
{
}
else
{
index
=
new
TreeIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
);
index
=
new
TreeIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
);
...
@@ -237,11 +238,11 @@ public class TableData extends Table implements RecordReader {
...
@@ -237,11 +238,11 @@ public class TableData extends Table implements RecordReader {
throw
e
;
throw
e
;
}
}
}
}
boolean
temporary
=
get
Temporary
();
boolean
temporary
=
is
Temporary
();
index
.
setTemporary
(
temporary
);
index
.
setTemporary
(
temporary
);
if
(
index
.
getCreateSQL
()
!=
null
)
{
if
(
index
.
getCreateSQL
()
!=
null
)
{
index
.
setComment
(
indexComment
);
index
.
setComment
(
indexComment
);
if
(
temporary
&&
!
get
GlobalTemporary
())
{
if
(
temporary
&&
!
is
GlobalTemporary
())
{
session
.
addLocalTempTableIndex
(
index
);
session
.
addLocalTempTableIndex
(
index
);
}
else
{
}
else
{
database
.
addSchemaObject
(
session
,
index
);
database
.
addSchemaObject
(
session
,
index
);
...
@@ -252,7 +253,7 @@ public class TableData extends Table implements RecordReader {
...
@@ -252,7 +253,7 @@ public class TableData extends Table implements RecordReader {
// need to update, because maybe the index is rebuilt at startup,
// need to update, because maybe the index is rebuilt at startup,
// and so the head pos may have changed, which needs to be stored now.
// and so the head pos may have changed, which needs to be stored now.
// addSchemaObject doesn't update the sys table at startup
// addSchemaObject doesn't update the sys table at startup
if
(
index
.
getIndexType
().
get
Persistent
()
&&
!
database
.
isReadOnly
()
if
(
index
.
getIndexType
().
is
Persistent
()
&&
!
database
.
isReadOnly
()
&&
!
database
.
getLog
().
containsInDoubtTransactions
())
{
&&
!
database
.
getLog
().
containsInDoubtTransactions
())
{
// can not save anything in the log file if it contains in-doubt transactions
// can not save anything in the log file if it contains in-doubt transactions
database
.
update
(
session
,
index
);
database
.
update
(
session
,
index
);
...
@@ -302,7 +303,7 @@ public class TableData extends Table implements RecordReader {
...
@@ -302,7 +303,7 @@ public class TableData extends Table implements RecordReader {
public
void
removeRow
(
Session
session
,
Row
row
)
throws
SQLException
{
public
void
removeRow
(
Session
session
,
Row
row
)
throws
SQLException
{
if
(
database
.
isMultiVersion
())
{
if
(
database
.
isMultiVersion
())
{
if
(
row
.
get
Deleted
())
{
if
(
row
.
is
Deleted
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
CONCURRENT_UPDATE_1
,
getName
());
throw
Message
.
getSQLException
(
ErrorCode
.
CONCURRENT_UPDATE_1
,
getName
());
}
}
int
old
=
row
.
getSessionId
();
int
old
=
row
.
getSessionId
();
...
@@ -547,7 +548,7 @@ public class TableData extends Table implements RecordReader {
...
@@ -547,7 +548,7 @@ public class TableData extends Table implements RecordReader {
public
String
getCreateSQL
()
{
public
String
getCreateSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"CREATE "
);
StatementBuilder
buff
=
new
StatementBuilder
(
"CREATE "
);
if
(
get
Temporary
())
{
if
(
is
Temporary
())
{
if
(
globalTemporary
)
{
if
(
globalTemporary
)
{
buff
.
append
(
"GLOBAL "
);
buff
.
append
(
"GLOBAL "
);
}
else
{
}
else
{
...
@@ -569,7 +570,7 @@ public class TableData extends Table implements RecordReader {
...
@@ -569,7 +570,7 @@ public class TableData extends Table implements RecordReader {
buff
.
append
(
column
.
getCreateSQL
());
buff
.
append
(
column
.
getCreateSQL
());
}
}
buff
.
append
(
"\n)"
);
buff
.
append
(
"\n)"
);
if
(!
get
Temporary
()
&&
!
isPersistIndexes
()
&&
!
isPersistData
())
{
if
(!
is
Temporary
()
&&
!
isPersistIndexes
()
&&
!
isPersistData
())
{
buff
.
append
(
"\nNOT PERSISTENT"
);
buff
.
append
(
"\nNOT PERSISTENT"
);
}
}
return
buff
.
toString
();
return
buff
.
toString
();
...
@@ -687,7 +688,7 @@ public class TableData extends Table implements RecordReader {
...
@@ -687,7 +688,7 @@ public class TableData extends Table implements RecordReader {
this
.
globalTemporary
=
globalTemporary
;
this
.
globalTemporary
=
globalTemporary
;
}
}
public
boolean
get
GlobalTemporary
()
{
public
boolean
is
GlobalTemporary
()
{
return
globalTemporary
;
return
globalTemporary
;
}
}
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
0bf4da12
...
@@ -349,10 +349,10 @@ kill -9 `jps -l | grep "org.h2.test.TestAll" | cut -d " " -f 1`
...
@@ -349,10 +349,10 @@ kill -9 `jps -l | grep "org.h2.test.TestAll" | cut -d " " -f 1`
test
.
runTests
();
test
.
runTests
();
TestPerformance
.
main
(
new
String
[]{
"-init"
,
"-db"
,
"1"
});
TestPerformance
.
main
(
new
String
[]{
"-init"
,
"-db"
,
"1"
});
System
.
setProperty
(
SysProperties
.
H2_PAGE_STORE
,
"false"
);
//
System.setProperty(SysProperties.H2_PAGE_STORE, "false");
test
.
pageStore
=
false
;
//
test.pageStore = false;
test
.
runTests
();
//
test.runTests();
TestPerformance
.
main
(
new
String
[]{
"-init"
,
"-db"
,
"1"
});
//
TestPerformance.main(new String[]{ "-init", "-db", "1"});
}
}
System
.
out
.
println
(
TestBase
.
formatTime
(
System
.
currentTimeMillis
()
-
time
)
+
" total"
);
System
.
out
.
println
(
TestBase
.
formatTime
(
System
.
currentTimeMillis
()
-
time
)
+
" total"
);
}
}
...
@@ -436,16 +436,18 @@ kill -9 `jps -l | grep "org.h2.test.TestAll" | cut -d " " -f 1`
...
@@ -436,16 +436,18 @@ kill -9 `jps -l | grep "org.h2.test.TestAll" | cut -d " " -f 1`
smallLog
=
false
;
smallLog
=
false
;
networked
=
false
;
networked
=
false
;
ssl
=
false
;
ssl
=
false
;
logMode
=
0
;
logMode
=
1
;
traceLevelFile
=
0
;
traceLevelFile
=
0
;
cipher
=
"AES"
;
test
();
test
();
big
=
false
;
big
=
false
;
networked
=
false
;
logMode
=
0
;
logMode
=
1
;
cipher
=
"AES"
;
cipher
=
null
;
test
();
mvcc
=
true
;
mvcc
=
true
;
cipher
=
null
;
logMode
=
1
;
test
();
test
();
memory
=
true
;
memory
=
true
;
...
...
h2/src/test/org/h2/test/db/TestScript.java
浏览文件 @
0bf4da12
...
@@ -73,13 +73,12 @@ public class TestScript extends TestBase {
...
@@ -73,13 +73,12 @@ public class TestScript extends TestBase {
return
;
return
;
}
}
alwaysReconnect
=
false
;
alwaysReconnect
=
false
;
testScript
();
if
(!
config
.
memory
)
{
if
(!
config
.
memory
)
{
if
(
config
.
big
)
{
if
(
config
.
big
)
{
alwaysReconnect
=
true
;
alwaysReconnect
=
true
;
testScript
();
}
}
}
}
testScript
();
deleteDb
(
"script"
);
deleteDb
(
"script"
);
}
}
...
@@ -192,9 +191,9 @@ public class TestScript extends TestBase {
...
@@ -192,9 +191,9 @@ public class TestScript extends TestBase {
}
}
count
+=
processPrepared
(
sql
,
prep
,
param
);
count
+=
processPrepared
(
sql
,
prep
,
param
);
}
}
writeResult
(
"update count: "
+
count
,
null
);
writeResult
(
sql
,
"update count: "
+
count
,
null
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
writeException
(
e
);
writeException
(
sql
,
e
);
}
}
}
}
write
(
""
);
write
(
""
);
...
@@ -237,7 +236,7 @@ public class TestScript extends TestBase {
...
@@ -237,7 +236,7 @@ public class TestScript extends TestBase {
}
}
return
prep
.
getUpdateCount
();
return
prep
.
getUpdateCount
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
writeException
(
e
);
writeException
(
sql
,
e
);
return
0
;
return
0
;
}
}
}
}
...
@@ -248,10 +247,10 @@ public class TestScript extends TestBase {
...
@@ -248,10 +247,10 @@ public class TestScript extends TestBase {
writeResultSet
(
sql
,
stat
.
getResultSet
());
writeResultSet
(
sql
,
stat
.
getResultSet
());
}
else
{
}
else
{
int
count
=
stat
.
getUpdateCount
();
int
count
=
stat
.
getUpdateCount
();
writeResult
(
count
<
1
?
"ok"
:
"update count: "
+
count
,
null
);
writeResult
(
sql
,
count
<
1
?
"ok"
:
"update count: "
+
count
,
null
);
}
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
writeException
(
e
);
writeException
(
sql
,
e
);
}
}
return
0
;
return
0
;
}
}
...
@@ -287,8 +286,8 @@ public class TestScript extends TestBase {
...
@@ -287,8 +286,8 @@ public class TestScript extends TestBase {
result
.
add
(
row
);
result
.
add
(
row
);
}
}
rs
.
close
();
rs
.
close
();
writeResult
(
format
(
head
,
max
),
null
);
writeResult
(
sql
,
format
(
head
,
max
),
null
);
writeResult
(
format
(
null
,
max
),
null
);
writeResult
(
sql
,
format
(
null
,
max
),
null
);
String
[]
array
=
new
String
[
result
.
size
()];
String
[]
array
=
new
String
[
result
.
size
()];
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++)
{
array
[
i
]
=
format
(
result
.
get
(
i
),
max
);
array
[
i
]
=
format
(
result
.
get
(
i
),
max
);
...
@@ -298,9 +297,9 @@ public class TestScript extends TestBase {
...
@@ -298,9 +297,9 @@ public class TestScript extends TestBase {
}
}
int
i
=
0
;
int
i
=
0
;
for
(;
i
<
array
.
length
;
i
++)
{
for
(;
i
<
array
.
length
;
i
++)
{
writeResult
(
array
[
i
],
null
);
writeResult
(
sql
,
array
[
i
],
null
);
}
}
writeResult
((
ordered
?
"rows (ordered): "
:
"rows: "
)
+
i
,
null
);
writeResult
(
sql
,
(
ordered
?
"rows (ordered): "
:
"rows: "
)
+
i
,
null
);
}
}
private
String
format
(
String
[]
row
,
int
[]
max
)
{
private
String
format
(
String
[]
row
,
int
[]
max
)
{
...
@@ -327,16 +326,19 @@ public class TestScript extends TestBase {
...
@@ -327,16 +326,19 @@ public class TestScript extends TestBase {
return
buff
.
toString
();
return
buff
.
toString
();
}
}
private
void
writeException
(
SQLException
e
)
throws
Exception
{
private
void
writeException
(
S
tring
sql
,
S
QLException
e
)
throws
Exception
{
writeResult
(
"exception"
,
e
);
writeResult
(
sql
,
"exception"
,
e
);
}
}
private
void
writeResult
(
String
s
,
SQLException
e
)
throws
Exception
{
private
void
writeResult
(
String
s
ql
,
String
s
,
SQLException
e
)
throws
Exception
{
assertKnownException
(
e
);
assertKnownException
(
e
);
s
=
(
"> "
+
s
).
trim
();
s
=
(
"> "
+
s
).
trim
();
String
compare
=
readLine
();
String
compare
=
readLine
();
if
(
compare
!=
null
&&
compare
.
startsWith
(
">"
))
{
if
(
compare
!=
null
&&
compare
.
startsWith
(
">"
))
{
if
(!
compare
.
equals
(
s
))
{
if
(!
compare
.
equals
(
s
))
{
if
(
alwaysReconnect
&&
sql
.
toUpperCase
().
startsWith
(
"EXPLAIN"
))
{
return
;
}
errors
.
append
(
"line: "
);
errors
.
append
(
"line: "
);
errors
.
append
(
line
);
errors
.
append
(
line
);
errors
.
append
(
"\n"
+
"exp: "
);
errors
.
append
(
"\n"
+
"exp: "
);
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
0bf4da12
...
@@ -41,6 +41,9 @@ public class TestMetaData extends TestBase {
...
@@ -41,6 +41,9 @@ public class TestMetaData extends TestBase {
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
deleteDb
(
"metaData"
);
deleteDb
(
"metaData"
);
testTempTable
();
conn
=
getConnection
(
"metaData"
);
conn
=
getConnection
(
"metaData"
);
testColumnLobMeta
();
testColumnLobMeta
();
...
@@ -206,7 +209,7 @@ public class TestMetaData extends TestBase {
...
@@ -206,7 +209,7 @@ public class TestMetaData extends TestBase {
// meta.getUDTs()
// meta.getUDTs()
conn
.
close
();
conn
.
close
();
testTempTable
();
deleteDb
(
"metaData"
);
deleteDb
(
"metaData"
);
}
}
...
...
h2/src/test/org/h2/test/unit/TestPageStore.java
浏览文件 @
0bf4da12
...
@@ -31,10 +31,31 @@ public class TestPageStore extends TestBase {
...
@@ -31,10 +31,31 @@ public class TestPageStore extends TestBase {
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
testUniqueIndex
();
testCreateIndexLater
();
testCreateIndexLater
();
testFuzzOperations
();
testFuzzOperations
();
}
}
private
void
testUniqueIndex
()
throws
SQLException
{
if
(
config
.
memory
)
{
return
;
}
deleteDb
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT UNIQUE)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1)"
);
conn
.
close
();
conn
=
getConnection
(
"pageStore"
);
try
{
conn
.
createStatement
().
execute
(
"INSERT INTO TEST VALUES(1)"
);
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
conn
.
close
();
}
private
void
testCreateIndexLater
()
throws
SQLException
{
private
void
testCreateIndexLater
()
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论