Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c1a0982e
提交
c1a0982e
authored
5月 29, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New experimental page store.
上级
724518e5
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
1327 行增加
和
1219 行删除
+1327
-1219
changelog.html
h2/src/docsrc/html/changelog.html
+1
-1
roadmap.html
h2/src/docsrc/html/roadmap.html
+2
-0
_docs_en.utf8.txt
h2/src/docsrc/text/_docs_en.utf8.txt
+407
-395
_docs_ja.utf8.txt
h2/src/docsrc/text/_docs_ja.utf8.txt
+407
-395
_docs_en.properties
h2/src/docsrc/textbase/_docs_en.properties
+400
-396
Set.java
h2/src/main/org/h2/command/dml/Set.java
+2
-2
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+3
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-1
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+1
-1
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+16
-6
Table.java
h2/src/main/org/h2/table/Table.java
+24
-0
TableData.java
h2/src/main/org/h2/table/TableData.java
+5
-0
CompareMode.java
h2/src/main/org/h2/value/CompareMode.java
+34
-12
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-5
TestPattern.java
h2/src/test/org/h2/test/unit/TestPattern.java
+19
-1
TestValueHashMap.java
h2/src/test/org/h2/test/unit/TestValueHashMap.java
+1
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+2
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
c1a0982e
...
...
@@ -20,7 +20,7 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<ul><li>
ResultSetMetaData.getColumnClassName returned the wrong
class for CLOB and BLOB columns.
</li><li>
Fulltext search: Data is no longer deleted and
</li><li>
Fulltext search: Data is no longer deleted and
re-inserted if the indexed columns didn't change.
</li><li>
In some situations, an ArrayIndexOutOfBoundsException was thrown when adding rows.
This was caused by a bug in the b-tree code.
...
...
h2/src/docsrc/html/roadmap.html
浏览文件 @
c1a0982e
...
...
@@ -419,6 +419,8 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>
MySQL compatibility: DatabaseMetaData.stores*() methods should return the same values. Test with SquirrelSQL.
</li><li>
MS SQL Server compatibility: support DATEPART syntax.
</li><li>
Oracle compatibility: support CREATE OR REPLACE VIEW syntax.
</li><li>
Sybase/DB2/Oracle compatibility: support out parameters in stored procedures - See http://code.google.com/p/h2database/issues/detail?id=83
</li><li>
Support INTERVAL data type (see Oracle and others).
</li></ul>
<h2>
Not Planned
</h2>
...
...
h2/src/docsrc/text/_docs_en.utf8.txt
浏览文件 @
c1a0982e
差异被折叠。
点击展开。
h2/src/docsrc/text/_docs_ja.utf8.txt
浏览文件 @
c1a0982e
差异被折叠。
点击展开。
h2/src/docsrc/textbase/_docs_en.properties
浏览文件 @
c1a0982e
差异被折叠。
点击展开。
h2/src/main/org/h2/command/dml/Set.java
浏览文件 @
c1a0982e
...
...
@@ -97,7 +97,7 @@ public class Set extends Prepared {
CompareMode
compareMode
;
StringBuilder
buff
=
new
StringBuilder
(
stringValue
);
if
(
stringValue
.
equals
(
CompareMode
.
OFF
))
{
compareMode
=
new
CompareMod
e
(
null
,
0
);
compareMode
=
CompareMode
.
getInstanc
e
(
null
,
0
);
}
else
{
int
strength
=
getIntValue
();
buff
.
append
(
" STRENGTH "
);
...
...
@@ -110,7 +110,7 @@ public class Set extends Prepared {
}
else
if
(
strength
==
Collator
.
TERTIARY
)
{
buff
.
append
(
"TERTIARY"
);
}
compareMode
=
new
CompareMod
e
(
stringValue
,
strength
);
compareMode
=
CompareMode
.
getInstanc
e
(
stringValue
,
strength
);
}
addOrUpdateSetting
(
name
,
buff
.
toString
(),
0
);
database
.
setCompareMode
(
compareMode
);
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
c1a0982e
...
...
@@ -330,7 +330,8 @@ public class ConstraintReferential extends Constraint {
}
private
boolean
found
(
Session
session
,
Index
searchIndex
,
SearchRow
check
,
Row
excluding
)
throws
SQLException
{
searchIndex
.
getTable
().
lock
(
session
,
false
,
false
);
Table
table
=
searchIndex
.
getTable
();
table
.
lock
(
session
,
false
,
false
);
Cursor
cursor
=
searchIndex
.
find
(
session
,
check
,
check
);
while
(
cursor
.
next
())
{
SearchRow
found
;
...
...
@@ -344,7 +345,7 @@ public class ConstraintReferential extends Constraint {
int
idx
=
cols
[
i
].
getColumnId
();
Value
c
=
check
.
getValue
(
idx
);
Value
f
=
found
.
getValue
(
idx
);
if
(
databas
e
.
compareTypeSave
(
c
,
f
)
!=
0
)
{
if
(
tabl
e
.
compareTypeSave
(
c
,
f
)
!=
0
)
{
allEqual
=
false
;
break
;
}
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
c1a0982e
...
...
@@ -169,7 +169,7 @@ public class Database implements DataHandler {
private
boolean
reconnectChangePending
;
public
Database
(
String
name
,
ConnectionInfo
ci
,
String
cipher
)
throws
SQLException
{
this
.
compareMode
=
new
CompareMod
e
(
null
,
0
);
this
.
compareMode
=
CompareMode
.
getInstanc
e
(
null
,
0
);
this
.
persistent
=
ci
.
isPersistent
();
this
.
filePasswordHash
=
ci
.
getFilePasswordHash
();
this
.
databaseName
=
name
;
...
...
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
c1a0982e
...
...
@@ -291,7 +291,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
}
return
SortOrder
.
compareNull
(
aNull
,
bNull
,
sortType
);
}
int
comp
=
databas
e
.
compareTypeSave
(
a
,
b
);
int
comp
=
tabl
e
.
compareTypeSave
(
a
,
b
);
if
((
sortType
&
SortOrder
.
DESCENDING
)
!=
0
)
{
comp
=
-
comp
;
}
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
c1a0982e
...
...
@@ -21,6 +21,7 @@ import org.h2.index.PageScanIndex;
import
org.h2.log.SessionState
;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
import
org.h2.message.TraceSystem
;
import
org.h2.result.Row
;
import
org.h2.schema.Schema
;
import
org.h2.table.Column
;
...
...
@@ -35,6 +36,7 @@ import org.h2.util.FileUtils;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.StringUtils
;
import
org.h2.value.CompareMode
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueString
;
...
...
@@ -174,7 +176,7 @@ public class PageStore implements CacheWriter {
this
.
database
=
database
;
trace
=
database
.
getTrace
(
Trace
.
PAGE_STORE
);
int
test
;
//
trace.setLevel(TraceSystem.DEBUG);
trace
.
setLevel
(
TraceSystem
.
DEBUG
);
this
.
cacheSize
=
cacheSizeDefault
;
String
cacheType
=
database
.
getCacheType
();
this
.
cache
=
CacheLRU
.
getCache
(
this
,
cacheType
,
cacheSize
);
...
...
@@ -809,8 +811,8 @@ public class PageStore implements CacheWriter {
cols
.
add
(
new
Column
(
"TYPE"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"PARENT"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"HEAD"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"OPTIONS"
,
Value
.
STRING
));
cols
.
add
(
new
Column
(
"COLUMNS"
,
Value
.
STRING
));
// new CompareMode()
metaSchema
=
new
Schema
(
database
,
0
,
""
,
null
,
true
);
int
headPos
=
metaTableRootPageId
;
metaTable
=
new
TableData
(
metaSchema
,
"PAGE_INDEX"
,
...
...
@@ -843,7 +845,8 @@ public class PageStore implements CacheWriter {
int
type
=
row
.
getValue
(
1
).
getInt
();
int
parent
=
row
.
getValue
(
2
).
getInt
();
int
headPos
=
row
.
getValue
(
3
).
getInt
();
String
columnList
=
row
.
getValue
(
4
).
getString
();
String
options
=
row
.
getValue
(
4
).
getString
();
String
columnList
=
row
.
getValue
(
5
).
getString
();
String
[]
columns
=
StringUtils
.
arraySplit
(
columnList
,
','
,
false
);
IndexType
indexType
=
IndexType
.
createNonUnique
(
true
);
Index
meta
;
...
...
@@ -857,6 +860,9 @@ public class PageStore implements CacheWriter {
columnArray
.
add
(
col
);
}
TableData
table
=
new
TableData
(
metaSchema
,
"T"
+
id
,
id
,
columnArray
,
true
,
true
,
false
,
headPos
,
session
);
String
[]
ops
=
StringUtils
.
arraySplit
(
options
,
','
,
true
);
CompareMode
mode
=
CompareMode
.
getInstance
(
ops
[
0
],
Integer
.
parseInt
(
ops
[
1
]));
table
.
setCompareMode
(
mode
);
meta
=
table
.
getScanIndex
(
session
);
}
else
{
PageScanIndex
p
=
(
PageScanIndex
)
metaObjects
.
get
(
parent
);
...
...
@@ -889,16 +895,20 @@ public class PageStore implements CacheWriter {
columnIndexes
[
i
]
=
String
.
valueOf
(
columns
[
i
].
getColumnId
());
}
String
columnList
=
StringUtils
.
arrayCombine
(
columnIndexes
,
','
);
addMeta
(
index
.
getId
(),
type
,
index
.
getTable
().
getId
(),
index
.
getHeadPos
(),
columnList
,
session
);
Table
table
=
index
.
getTable
();
CompareMode
mode
=
table
.
getCompareMode
();
String
options
=
mode
.
getName
()+
","
+
mode
.
getStrength
();
addMeta
(
index
.
getId
(),
type
,
table
.
getId
(),
index
.
getHeadPos
(),
options
,
columnList
,
session
);
}
private
void
addMeta
(
int
id
,
int
type
,
int
parent
,
int
headPos
,
String
columnList
,
Session
session
)
throws
SQLException
{
private
void
addMeta
(
int
id
,
int
type
,
int
parent
,
int
headPos
,
String
options
,
String
columnList
,
Session
session
)
throws
SQLException
{
Row
row
=
metaTable
.
getTemplateRow
();
row
.
setValue
(
0
,
ValueInt
.
get
(
id
));
row
.
setValue
(
1
,
ValueInt
.
get
(
type
));
row
.
setValue
(
2
,
ValueInt
.
get
(
parent
));
row
.
setValue
(
3
,
ValueInt
.
get
(
headPos
));
row
.
setValue
(
4
,
ValueString
.
get
(
columnList
));
row
.
setValue
(
4
,
ValueString
.
get
(
options
));
row
.
setValue
(
5
,
ValueString
.
get
(
columnList
));
row
.
setPos
(
id
+
1
);
metaIndex
.
add
(
session
,
row
);
}
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
c1a0982e
...
...
@@ -35,6 +35,7 @@ import org.h2.schema.Sequence;
import
org.h2.schema.TriggerObject
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.value.CompareMode
;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -85,6 +86,11 @@ public abstract class Table extends SchemaObjectBase {
*/
protected
int
memoryPerRow
;
/**
* The compare mode used for this table.
*/
protected
CompareMode
compareMode
;
private
final
HashMap
<
String
,
Column
>
columnMap
=
New
.
hashMap
();
private
boolean
persistIndexes
;
private
boolean
persistData
;
...
...
@@ -100,6 +106,7 @@ public abstract class Table extends SchemaObjectBase {
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
TABLE
);
this
.
persistIndexes
=
persistIndexes
;
this
.
persistData
=
persistData
;
compareMode
=
schema
.
getDatabase
().
getCompareMode
();
}
public
void
rename
(
String
newName
)
throws
SQLException
{
...
...
@@ -904,4 +911,21 @@ public abstract class Table extends SchemaObjectBase {
return
persistData
;
}
/**
* Compare two values with the current comparison mode. The values must be
* of the same type.
*
* @param a the first value
* @param b the second value
* @return 0 if both values are equal, -1 if the first value is smaller, and
* 1 otherwise
*/
public
int
compareTypeSave
(
Value
a
,
Value
b
)
throws
SQLException
{
return
a
.
compareTypeSave
(
b
,
compareMode
);
}
public
CompareMode
getCompareMode
()
{
return
compareMode
;
}
}
h2/src/main/org/h2/table/TableData.java
浏览文件 @
c1a0982e
...
...
@@ -43,6 +43,7 @@ import org.h2.util.New;
import
org.h2.util.ObjectArray
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.value.CompareMode
;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
...
...
@@ -699,4 +700,8 @@ public class TableData extends Table implements RecordReader {
return
scanIndex
.
getRowCountApproximation
();
}
public
void
setCompareMode
(
CompareMode
compareMode
)
{
this
.
compareMode
=
compareMode
;
}
}
h2/src/main/org/h2/value/CompareMode.java
浏览文件 @
c1a0982e
...
...
@@ -27,19 +27,16 @@ public class CompareMode {
*/
public
static
final
String
OFF
=
"OFF"
;
private
final
Collator
collator
;
private
static
CompareMode
lastUsed
;
private
final
String
name
;
private
final
int
strength
;
private
final
Collator
collator
;
private
final
SmallLRUCache
<
String
,
CollationKey
>
collationKeys
;
/**
* Create a new compare mode with the given collator and cache size.
* The cache is used to speed up comparison when using a collator;
* CollationKey objects are cached.
*
* @param name the collation name or null
* @param strength the collation strength
*/
public
CompareMode
(
String
name
,
int
strength
)
{
private
CompareMode
(
String
name
,
int
strength
)
{
this
.
name
=
name
;
this
.
strength
=
strength
;
this
.
collator
=
CompareMode
.
getCollator
(
name
);
int
cacheSize
=
0
;
if
(
collator
!=
null
)
{
...
...
@@ -51,7 +48,28 @@ public class CompareMode {
}
else
{
collationKeys
=
null
;
}
this
.
name
=
name
==
null
?
OFF
:
name
;
}
/**
* Create a new compare mode with the given collator and strength. If
* required, a new CompareMode is created, or if possible the last one is
* returned. A cache is used to speed up comparison when using a collator;
* CollationKey objects are cached.
*
* @param name the collation name or null
* @param strength the collation strength
* @return the compare mode
*/
public
static
CompareMode
getInstance
(
String
name
,
int
strength
)
{
if
(
lastUsed
!=
null
)
{
if
(
StringUtils
.
equals
(
lastUsed
.
name
,
name
))
{
if
(
lastUsed
.
strength
==
strength
)
{
return
lastUsed
;
}
}
}
lastUsed
=
new
CompareMode
(
name
,
strength
);
return
lastUsed
;
}
/**
...
...
@@ -178,7 +196,11 @@ public class CompareMode {
}
public
String
getName
()
{
return
name
;
return
name
==
null
?
OFF
:
name
;
}
public
int
getStrength
()
{
return
strength
;
}
}
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
c1a0982e
...
...
@@ -295,12 +295,9 @@ java org.h2.test.TestAll timer
shell tool: document encoding problem. mac: use
java -Dfile.encoding=UTF-8;
BaseIndex or TableData should have its own compareMode
(default is: Database.compareMode when created).
standard: COLLATE for each column (MySQL, SQL Server)
TableData should have its own compareMode
(copy of Database.compareMode when created).
stored in the pageStore as well.
check syntax in other databases.
this mean changing the collation is allowed if there are tables.
test case for running out of disk space (using a special file system)
...
...
h2/src/test/org/h2/test/unit/TestPattern.java
浏览文件 @
c1a0982e
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
test
.
unit
;
import
java.sql.SQLException
;
import
java.text.Collator
;
import
org.h2.expression.CompareLike
;
import
org.h2.test.TestBase
;
...
...
@@ -27,7 +28,24 @@ public class TestPattern extends TestBase {
}
public
void
test
()
throws
SQLException
{
CompareMode
mode
=
new
CompareMode
(
null
,
0
);
testCompareModeReuse
();
testPattern
();
}
private
void
testCompareModeReuse
()
{
CompareMode
mode1
,
mode2
;
mode1
=
CompareMode
.
getInstance
(
null
,
0
);
mode2
=
CompareMode
.
getInstance
(
null
,
0
);
assertTrue
(
mode1
==
mode2
);
mode1
=
CompareMode
.
getInstance
(
"DE"
,
Collator
.
SECONDARY
);
assertFalse
(
mode1
==
mode2
);
mode2
=
CompareMode
.
getInstance
(
"DE"
,
Collator
.
SECONDARY
);
assertTrue
(
mode1
==
mode2
);
}
private
void
testPattern
()
throws
SQLException
{
CompareMode
mode
=
CompareMode
.
getInstance
(
null
,
0
);
CompareLike
comp
=
new
CompareLike
(
mode
,
null
,
null
,
null
,
false
);
test
(
comp
,
"B"
,
"%_"
);
test
(
comp
,
"A"
,
"A%"
);
...
...
h2/src/test/org/h2/test/unit/TestValueHashMap.java
浏览文件 @
c1a0982e
...
...
@@ -31,7 +31,7 @@ import org.h2.value.ValueInt;
*/
public
class
TestValueHashMap
extends
TestBase
implements
DataHandler
{
CompareMode
compareMode
=
new
CompareMod
e
(
null
,
0
);
CompareMode
compareMode
=
CompareMode
.
getInstanc
e
(
null
,
0
);
/**
* Run just this test.
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
c1a0982e
...
...
@@ -589,4 +589,5 @@ handing bonita placed euros embeds reliability singular unregister quotas
overall httpdocs tigris eclemma separates underscore yajsw she her truncating
relocating smtps smtp osde joist catching guesses delimiters shortlist sheet
rowspan cheat partitioning datepart dreamsource toussi locates fred
longnvarchar collate localdb nan bootclasspath bcp retrotranslator iterable
\ No newline at end of file
longnvarchar collate localdb nan bootclasspath bcp retrotranslator iterable
ops
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论