Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3db03fa6
提交
3db03fa6
authored
4月 03, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support for not persistent in-memory tables in regular (persistent) databases.
上级
22e939fe
隐藏空白字符变更
内嵌
并排
正在显示
23 个修改的文件
包含
77 行增加
和
51 行删除
+77
-51
changelog.html
h2/src/docsrc/html/changelog.html
+3
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+6
-3
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+3
-3
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+1
-2
CreateIndex.java
h2/src/main/org/h2/command/ddl/CreateIndex.java
+1
-1
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+10
-5
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-1
PageBtreeIndex.java
h2/src/main/org/h2/index/PageBtreeIndex.java
+1
-1
PageScanIndex.java
h2/src/main/org/h2/index/PageScanIndex.java
+1
-1
ScanIndex.java
h2/src/main/org/h2/index/ScanIndex.java
+2
-2
help.csv
h2/src/main/org/h2/res/help.csv
+2
-1
ResultTempTable.java
h2/src/main/org/h2/result/ResultTempTable.java
+1
-1
Schema.java
h2/src/main/org/h2/schema/Schema.java
+4
-3
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+2
-2
FunctionTable.java
h2/src/main/org/h2/table/FunctionTable.java
+1
-1
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+2
-2
RangeTable.java
h2/src/main/org/h2/table/RangeTable.java
+1
-1
Table.java
h2/src/main/org/h2/table/Table.java
+13
-7
TableData.java
h2/src/main/org/h2/table/TableData.java
+10
-7
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+1
-1
TableView.java
h2/src/main/org/h2/table/TableView.java
+1
-1
testSimple.in.txt
h2/src/test/org/h2/test/testSimple.in.txt
+8
-0
TestPageStore.java
h2/src/test/org/h2/test/unit/TestPageStore.java
+2
-4
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
3db03fa6
...
@@ -18,7 +18,9 @@ Change Log
...
@@ -18,7 +18,9 @@ Change Log
<h1>
Change Log
</h1>
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
The H2 Console trimmed the password (removed leading and trailing spaces).
<ul><li>
Support for not persistent in-memory tables in regular (persistent) databases
using CREATE MEMORY TABLE(..) NOT PERSISTENT. Thanks a lot to Sergi Vladykin for the patch!
</li><li>
The H2 Console trimmed the password (removed leading and trailing spaces).
This is no longer the case, to support encrypted H2 database with an empty user password.
This is no longer the case, to support encrypted H2 database with an empty user password.
</li><li>
The data type of a SUBSTRING method was wrong.
</li><li>
The data type of a SUBSTRING method was wrong.
</li><li>
ResultSet.findColumn and get methods with column label parameters
</li><li>
ResultSet.findColumn and get methods with column label parameters
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
3db03fa6
...
@@ -3781,7 +3781,7 @@ public class Parser {
...
@@ -3781,7 +3781,7 @@ public class Parser {
columns
.
add
(
new
Column
(
cols
[
i
],
Value
.
STRING
));
columns
.
add
(
new
Column
(
cols
[
i
],
Value
.
STRING
));
}
}
int
id
=
database
.
allocateObjectId
(
true
,
true
);
int
id
=
database
.
allocateObjectId
(
true
,
true
);
recursiveTable
=
schema
.
createTable
(
tempViewName
,
id
,
columns
,
false
,
false
,
Index
.
EMPTY_HEAD
);
recursiveTable
=
schema
.
createTable
(
tempViewName
,
id
,
columns
,
false
,
true
,
false
,
Index
.
EMPTY_HEAD
);
recursiveTable
.
setTemporary
(
true
);
recursiveTable
.
setTemporary
(
true
);
session
.
addLocalTempTable
(
recursiveTable
);
session
.
addLocalTempTable
(
recursiveTable
);
String
querySQL
=
StringCache
.
getNew
(
sqlCommand
.
substring
(
parseIndex
));
String
querySQL
=
StringCache
.
getNew
(
sqlCommand
.
substring
(
parseIndex
));
...
@@ -4590,7 +4590,7 @@ public class Parser {
...
@@ -4590,7 +4590,7 @@ public class Parser {
return
command
;
return
command
;
}
}
private
CreateTable
parseCreateTable
(
boolean
temp
,
boolean
globalTemp
,
boolean
persist
ent
)
throws
SQLException
{
private
CreateTable
parseCreateTable
(
boolean
temp
,
boolean
globalTemp
,
boolean
persist
Indexes
)
throws
SQLException
{
boolean
ifNotExists
=
readIfNoExists
();
boolean
ifNotExists
=
readIfNoExists
();
String
tableName
=
readIdentifierWithSchema
();
String
tableName
=
readIdentifierWithSchema
();
if
(
temp
&&
globalTemp
&&
"SESSION"
.
equals
(
schemaName
))
{
if
(
temp
&&
globalTemp
&&
"SESSION"
.
equals
(
schemaName
))
{
...
@@ -4601,7 +4601,7 @@ public class Parser {
...
@@ -4601,7 +4601,7 @@ public class Parser {
}
}
Schema
schema
=
getSchema
();
Schema
schema
=
getSchema
();
CreateTable
command
=
new
CreateTable
(
session
,
schema
);
CreateTable
command
=
new
CreateTable
(
session
,
schema
);
command
.
setPersist
ent
(
persistent
);
command
.
setPersist
Indexes
(
persistIndexes
);
command
.
setTemporary
(
temp
);
command
.
setTemporary
(
temp
);
command
.
setGlobalTemporary
(
globalTemp
);
command
.
setGlobalTemporary
(
globalTemp
);
command
.
setIfNotExists
(
ifNotExists
);
command
.
setIfNotExists
(
ifNotExists
);
...
@@ -4698,6 +4698,9 @@ public class Parser {
...
@@ -4698,6 +4698,9 @@ public class Parser {
}
else
if
(
readIf
(
"NOT"
))
{
}
else
if
(
readIf
(
"NOT"
))
{
read
(
"LOGGED"
);
read
(
"LOGGED"
);
}
}
}
else
if
(!
persistIndexes
&&
readIf
(
"NOT"
))
{
read
(
"PERSISTENT"
);
command
.
setPersistData
(
false
);
}
}
if
(
readIf
(
"CLUSTERED"
))
{
if
(
readIf
(
"CLUSTERED"
))
{
command
.
setClustered
(
true
);
command
.
setClustered
(
true
);
...
...
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
3db03fa6
...
@@ -134,7 +134,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
...
@@ -134,7 +134,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
}
}
}
if
(
index
==
null
)
{
if
(
index
==
null
)
{
IndexType
indexType
=
IndexType
.
createPrimaryKey
(
table
.
getPersistent
(),
primaryKeyHash
);
IndexType
indexType
=
IndexType
.
createPrimaryKey
(
table
.
isPersistIndexes
(),
primaryKeyHash
);
String
indexName
=
table
.
getSchema
().
getUniqueIndexName
(
session
,
table
,
Constants
.
PREFIX_PRIMARY_KEY
);
String
indexName
=
table
.
getSchema
().
getUniqueIndexName
(
session
,
table
,
Constants
.
PREFIX_PRIMARY_KEY
);
int
id
=
getObjectId
(
true
,
false
);
int
id
=
getObjectId
(
true
,
false
);
try
{
try
{
...
@@ -262,10 +262,10 @@ public class AlterTableAddConstraint extends SchemaCommand {
...
@@ -262,10 +262,10 @@ public class AlterTableAddConstraint extends SchemaCommand {
IndexType
indexType
;
IndexType
indexType
;
if
(
unique
)
{
if
(
unique
)
{
// for unique constraints
// for unique constraints
indexType
=
IndexType
.
createUnique
(
t
.
getPersistent
(),
false
);
indexType
=
IndexType
.
createUnique
(
t
.
isPersistIndexes
(),
false
);
}
else
{
}
else
{
// constraints
// constraints
indexType
=
IndexType
.
createNonUnique
(
t
.
getPersistent
());
indexType
=
IndexType
.
createNonUnique
(
t
.
isPersistIndexes
());
}
}
indexType
.
setBelongsToConstraint
(
true
);
indexType
.
setBelongsToConstraint
(
true
);
String
prefix
=
constraintName
==
null
?
"CONSTRAINT"
:
constraintName
;
String
prefix
=
constraintName
==
null
?
"CONSTRAINT"
:
constraintName
;
...
...
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
3db03fa6
...
@@ -234,14 +234,13 @@ public class AlterTableAlterColumn extends SchemaCommand {
...
@@ -234,14 +234,13 @@ public class AlterTableAlterColumn extends SchemaCommand {
newColumns
.
remove
(
position
);
newColumns
.
remove
(
position
);
newColumns
.
add
(
position
,
newColumn
);
newColumns
.
add
(
position
,
newColumn
);
}
}
boolean
persistent
=
table
.
getPersistent
();
// create a table object in order to get the SQL statement
// create a table object in order to get the SQL statement
// can't just use this table, because most column objects are 'shared'
// can't just use this table, because most column objects are 'shared'
// with the old table
// with the old table
// still need a new id because using 0 would mean: the new table tries
// still need a new id because using 0 would mean: the new table tries
// to use the rows of the table 0 (the meta table)
// to use the rows of the table 0 (the meta table)
int
id
=
db
.
allocateObjectId
(
true
,
true
);
int
id
=
db
.
allocateObjectId
(
true
,
true
);
TableData
newTable
=
getSchema
().
createTable
(
tempName
,
id
,
newColumns
,
persistent
,
false
,
Index
.
EMPTY_HEAD
);
TableData
newTable
=
getSchema
().
createTable
(
tempName
,
id
,
newColumns
,
table
.
isPersistIndexes
(),
table
.
isPersistData
()
,
false
,
Index
.
EMPTY_HEAD
);
newTable
.
setComment
(
table
.
getComment
());
newTable
.
setComment
(
table
.
getComment
());
StringBuffer
buff
=
new
StringBuffer
(
newTable
.
getCreateSQL
());
StringBuffer
buff
=
new
StringBuffer
(
newTable
.
getCreateSQL
());
StringBuffer
columnList
=
new
StringBuffer
();
StringBuffer
columnList
=
new
StringBuffer
();
...
...
h2/src/main/org/h2/command/ddl/CreateIndex.java
浏览文件 @
3db03fa6
...
@@ -59,7 +59,7 @@ public class CreateIndex extends SchemaCommand {
...
@@ -59,7 +59,7 @@ public class CreateIndex extends SchemaCommand {
Table
table
=
getSchema
().
getTableOrView
(
session
,
tableName
);
Table
table
=
getSchema
().
getTableOrView
(
session
,
tableName
);
session
.
getUser
().
checkRight
(
table
,
Right
.
ALL
);
session
.
getUser
().
checkRight
(
table
,
Right
.
ALL
);
table
.
lock
(
session
,
true
,
true
);
table
.
lock
(
session
,
true
,
true
);
if
(!
table
.
getPersistent
())
{
if
(!
table
.
isPersistIndexes
())
{
persistent
=
false
;
persistent
=
false
;
}
}
int
id
=
getObjectId
(
true
,
false
);
int
id
=
getObjectId
(
true
,
false
);
...
...
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
3db03fa6
...
@@ -35,7 +35,8 @@ public class CreateTable extends SchemaCommand {
...
@@ -35,7 +35,8 @@ public class CreateTable extends SchemaCommand {
private
ObjectArray
columns
=
new
ObjectArray
();
private
ObjectArray
columns
=
new
ObjectArray
();
private
IndexColumn
[]
pkColumns
;
private
IndexColumn
[]
pkColumns
;
private
boolean
ifNotExists
;
private
boolean
ifNotExists
;
private
boolean
persistent
=
true
;
private
boolean
persistIndexes
=
true
;
private
boolean
persistData
=
true
;
private
boolean
temporary
;
private
boolean
temporary
;
private
boolean
globalTemporary
;
private
boolean
globalTemporary
;
private
boolean
onCommitDrop
;
private
boolean
onCommitDrop
;
...
@@ -103,7 +104,7 @@ public class CreateTable extends SchemaCommand {
...
@@ -103,7 +104,7 @@ public class CreateTable extends SchemaCommand {
session
.
commit
(
true
);
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
Database
db
=
session
.
getDatabase
();
if
(!
db
.
isPersistent
())
{
if
(!
db
.
isPersistent
())
{
persist
ent
=
false
;
persist
Indexes
=
false
;
}
}
if
(
getSchema
().
findTableOrView
(
session
,
tableName
)
!=
null
)
{
if
(
getSchema
().
findTableOrView
(
session
,
tableName
)
!=
null
)
{
if
(
ifNotExists
)
{
if
(
ifNotExists
)
{
...
@@ -143,7 +144,7 @@ public class CreateTable extends SchemaCommand {
...
@@ -143,7 +144,7 @@ public class CreateTable extends SchemaCommand {
}
}
}
}
int
id
=
getObjectId
(
true
,
true
);
int
id
=
getObjectId
(
true
,
true
);
TableData
table
=
getSchema
().
createTable
(
tableName
,
id
,
columns
,
persist
ent
,
clustered
,
headPos
);
TableData
table
=
getSchema
().
createTable
(
tableName
,
id
,
columns
,
persist
Indexes
,
persistData
,
clustered
,
headPos
);
table
.
setComment
(
comment
);
table
.
setComment
(
comment
);
table
.
setTemporary
(
temporary
);
table
.
setTemporary
(
temporary
);
table
.
setGlobalTemporary
(
globalTemporary
);
table
.
setGlobalTemporary
(
globalTemporary
);
...
@@ -239,8 +240,8 @@ public class CreateTable extends SchemaCommand {
...
@@ -239,8 +240,8 @@ public class CreateTable extends SchemaCommand {
return
false
;
return
false
;
}
}
public
void
setPersist
ent
(
boolean
persistent
)
{
public
void
setPersist
Indexes
(
boolean
persistIndexes
)
{
this
.
persist
ent
=
persistent
;
this
.
persist
Indexes
=
persistIndexes
;
}
}
public
void
setGlobalTemporary
(
boolean
globalTemporary
)
{
public
void
setGlobalTemporary
(
boolean
globalTemporary
)
{
...
@@ -269,4 +270,8 @@ public class CreateTable extends SchemaCommand {
...
@@ -269,4 +270,8 @@ public class CreateTable extends SchemaCommand {
this
.
clustered
=
clustered
;
this
.
clustered
=
clustered
;
}
}
public
void
setPersistData
(
boolean
persistData
)
{
this
.
persistData
=
persistData
;
}
}
}
h2/src/main/org/h2/engine/Database.java
浏览文件 @
3db03fa6
...
@@ -596,7 +596,7 @@ public class Database implements DataHandler {
...
@@ -596,7 +596,7 @@ public class Database implements DataHandler {
if
(
pageStore
!=
null
)
{
if
(
pageStore
!=
null
)
{
headPos
=
pageStore
.
getSystemTableHeadPos
();
headPos
=
pageStore
.
getSystemTableHeadPos
();
}
}
meta
=
mainSchema
.
createTable
(
"SYS"
,
0
,
cols
,
persistent
,
false
,
headPos
);
meta
=
mainSchema
.
createTable
(
"SYS"
,
0
,
cols
,
persistent
,
persistent
,
false
,
headPos
);
tableMap
.
put
(
0
,
meta
);
tableMap
.
put
(
0
,
meta
);
IndexColumn
[]
pkCols
=
IndexColumn
.
wrap
(
new
Column
[]
{
columnId
});
IndexColumn
[]
pkCols
=
IndexColumn
.
wrap
(
new
Column
[]
{
columnId
});
metaIdIndex
=
meta
.
addIndex
(
systemSession
,
"SYS_ID"
,
0
,
pkCols
,
IndexType
.
createPrimaryKey
(
metaIdIndex
=
meta
.
addIndex
(
systemSession
,
"SYS_ID"
,
0
,
pkCols
,
IndexType
.
createPrimaryKey
(
...
...
h2/src/main/org/h2/index/PageBtreeIndex.java
浏览文件 @
3db03fa6
...
@@ -219,7 +219,7 @@ public class PageBtreeIndex extends BaseIndex {
...
@@ -219,7 +219,7 @@ public class PageBtreeIndex extends BaseIndex {
trace
.
debug
(
"truncate"
);
trace
.
debug
(
"truncate"
);
}
}
removeAllRows
();
removeAllRows
();
if
(
tableData
.
getContainsLargeObject
()
&&
tableData
.
getPersistent
()
)
{
if
(
tableData
.
getContainsLargeObject
())
{
ValueLob
.
removeAllForTable
(
database
,
table
.
getId
());
ValueLob
.
removeAllForTable
(
database
,
table
.
getId
());
}
}
tableData
.
setRowCount
(
0
);
tableData
.
setRowCount
(
0
);
...
...
h2/src/main/org/h2/index/PageScanIndex.java
浏览文件 @
3db03fa6
...
@@ -239,7 +239,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
...
@@ -239,7 +239,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
trace
.
debug
(
"truncate"
);
trace
.
debug
(
"truncate"
);
}
}
removeAllRows
();
removeAllRows
();
if
(
tableData
.
getContainsLargeObject
()
&&
tableData
.
getPersistent
())
{
if
(
tableData
.
getContainsLargeObject
()
&&
tableData
.
isPersistData
())
{
ValueLob
.
removeAllForTable
(
database
,
table
.
getId
());
ValueLob
.
removeAllForTable
(
database
,
table
.
getId
());
}
}
tableData
.
setRowCount
(
0
);
tableData
.
setRowCount
(
0
);
...
...
h2/src/main/org/h2/index/ScanIndex.java
浏览文件 @
3db03fa6
...
@@ -49,7 +49,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
...
@@ -49,7 +49,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
sessionRowCount
=
new
HashMap
();
sessionRowCount
=
new
HashMap
();
}
}
tableData
=
table
;
tableData
=
table
;
if
(!
database
.
isPersistent
()
||
id
<
0
)
{
if
(!
database
.
isPersistent
()
||
id
<
0
||
!
indexType
.
getPersistent
()
)
{
return
;
return
;
}
}
this
.
storage
=
database
.
getStorage
(
table
,
id
,
true
);
this
.
storage
=
database
.
getStorage
(
table
,
id
,
true
);
...
@@ -74,7 +74,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
...
@@ -74,7 +74,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
}
else
{
}
else
{
storage
.
truncate
(
session
);
storage
.
truncate
(
session
);
}
}
if
(
tableData
.
getContainsLargeObject
()
&&
tableData
.
getPersistent
())
{
if
(
tableData
.
getContainsLargeObject
()
&&
tableData
.
isPersistData
())
{
ValueLob
.
removeAllForTable
(
database
,
table
.
getId
());
ValueLob
.
removeAllForTable
(
database
,
table
.
getId
());
}
}
tableData
.
setRowCount
(
0
);
tableData
.
setRowCount
(
0
);
...
...
h2/src/main/org/h2/res/help.csv
浏览文件 @
3db03fa6
...
@@ -480,11 +480,12 @@ TABLE [IF NOT EXISTS] name
...
@@ -480,11 +480,12 @@ TABLE [IF NOT EXISTS] name
[{AUTO_INCREMENT | IDENTITY}[(startInt [, incrementInt])]]
[{AUTO_INCREMENT | IDENTITY}[(startInt [, incrementInt])]]
[SELECTIVITY selectivity]
[SELECTIVITY selectivity]
[PRIMARY KEY [HASH] | UNIQUE]
[PRIMARY KEY [HASH] | UNIQUE]
| constraint} [,...] ) [
AS select
] } | { AS select }
| constraint} [,...] ) [
AS select] [NOT PERSISTENT
] } | { AS select }
","
","
Creates a new table.
Creates a new table.
Cached tables (the default) are persistent, and the number or rows is not limited by the main memory.
Cached tables (the default) are persistent, and the number or rows is not limited by the main memory.
Memory tables are persistent, but the index data is kept in the main memory, so memory tables should not get too large.
Memory tables are persistent, but the index data is kept in the main memory, so memory tables should not get too large.
Tables with the NOT PERSISTENT modifier are kept fully in memory, and all rows are lost when the database is closed.
Temporary tables are not persistent. Temporary tables can be global (accessible by all connections)
Temporary tables are not persistent. Temporary tables can be global (accessible by all connections)
or local (only accessible by the current connection). The default is for temporary tables is global.
or local (only accessible by the current connection). The default is for temporary tables is global.
Identity and auto-increment columns are columns with a sequence as the default.
Identity and auto-increment columns are columns with a sequence as the default.
...
...
h2/src/main/org/h2/result/ResultTempTable.java
浏览文件 @
3db03fa6
...
@@ -46,7 +46,7 @@ public class ResultTempTable implements ResultExternal {
...
@@ -46,7 +46,7 @@ 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
,
false
,
Index
.
EMPTY_HEAD
);
table
=
schema
.
createTable
(
tableName
,
tableId
,
columns
,
false
,
true
,
false
,
Index
.
EMPTY_HEAD
);
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
;
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
3db03fa6
...
@@ -470,14 +470,15 @@ public class Schema extends DbObjectBase {
...
@@ -470,14 +470,15 @@ public class Schema extends DbObjectBase {
* @param tableName the table name
* @param tableName the table name
* @param id the object id
* @param id the object id
* @param columns the column list
* @param columns the column list
* @param persistent if the table should be persistent
* @param persistIndexes if indexes of the table should be persistent
* @param persistData if data of the table should be persistent
* @param clustered if a clustered table should be created
* @param clustered if a clustered table should be created
* @param headPos the position (page number) of the head
* @param headPos the position (page number) of the head
* @return the created {@link TableData} object
* @return the created {@link TableData} object
*/
*/
public
TableData
createTable
(
String
tableName
,
int
id
,
ObjectArray
columns
,
boolean
persist
ent
,
boolean
clustered
,
int
headPos
)
public
TableData
createTable
(
String
tableName
,
int
id
,
ObjectArray
columns
,
boolean
persist
Indexes
,
boolean
persistData
,
boolean
clustered
,
int
headPos
)
throws
SQLException
{
throws
SQLException
{
return
new
TableData
(
this
,
tableName
,
id
,
columns
,
persist
ent
,
clustered
,
headPos
);
return
new
TableData
(
this
,
tableName
,
id
,
columns
,
persist
Indexes
,
persistData
,
clustered
,
headPos
);
}
}
/**
/**
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
3db03fa6
...
@@ -823,7 +823,7 @@ trace.setLevel(TraceSystem.DEBUG);
...
@@ -823,7 +823,7 @@ trace.setLevel(TraceSystem.DEBUG);
metaSchema
=
new
Schema
(
database
,
0
,
""
,
null
,
true
);
metaSchema
=
new
Schema
(
database
,
0
,
""
,
null
,
true
);
int
headPos
=
metaTableRootPageId
;
int
headPos
=
metaTableRootPageId
;
metaTable
=
new
TableData
(
metaSchema
,
"PAGE_INDEX"
,
metaTable
=
new
TableData
(
metaSchema
,
"PAGE_INDEX"
,
META_TABLE_ID
,
cols
,
true
,
false
,
headPos
);
META_TABLE_ID
,
cols
,
true
,
true
,
false
,
headPos
);
metaIndex
=
(
PageScanIndex
)
metaTable
.
getScanIndex
(
metaIndex
=
(
PageScanIndex
)
metaTable
.
getScanIndex
(
database
.
getSystemSession
());
database
.
getSystemSession
());
metaObjects
=
new
HashMap
();
metaObjects
=
new
HashMap
();
...
@@ -865,7 +865,7 @@ trace.setLevel(TraceSystem.DEBUG);
...
@@ -865,7 +865,7 @@ trace.setLevel(TraceSystem.DEBUG);
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
,
false
,
headPos
);
TableData
table
=
new
TableData
(
metaSchema
,
"T"
+
id
,
id
,
columnArray
,
true
,
true
,
false
,
headPos
);
meta
=
table
.
getScanIndex
(
database
.
getSystemSession
());
meta
=
table
.
getScanIndex
(
database
.
getSystemSession
());
}
else
{
}
else
{
PageScanIndex
p
=
(
PageScanIndex
)
metaObjects
.
get
(
ObjectUtils
.
getInteger
(
parent
));
PageScanIndex
p
=
(
PageScanIndex
)
metaObjects
.
get
(
ObjectUtils
.
getInteger
(
parent
));
...
...
h2/src/main/org/h2/table/FunctionTable.java
浏览文件 @
3db03fa6
...
@@ -40,7 +40,7 @@ public class FunctionTable extends Table {
...
@@ -40,7 +40,7 @@ public class FunctionTable extends Table {
private
Value
cachedValue
;
private
Value
cachedValue
;
public
FunctionTable
(
Schema
schema
,
Session
session
,
Expression
functionExpr
,
FunctionCall
function
)
throws
SQLException
{
public
FunctionTable
(
Schema
schema
,
Session
session
,
Expression
functionExpr
,
FunctionCall
function
)
throws
SQLException
{
super
(
schema
,
0
,
function
.
getName
(),
false
);
super
(
schema
,
0
,
function
.
getName
(),
false
,
true
);
this
.
functionExpr
=
functionExpr
;
this
.
functionExpr
=
functionExpr
;
this
.
function
=
function
;
this
.
function
=
function
;
if
(
function
instanceof
TableFunction
)
{
if
(
function
instanceof
TableFunction
)
{
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
3db03fa6
...
@@ -117,7 +117,7 @@ public class MetaTable extends Table {
...
@@ -117,7 +117,7 @@ public class MetaTable extends Table {
*/
*/
public
MetaTable
(
Schema
schema
,
int
id
,
int
type
)
throws
SQLException
{
public
MetaTable
(
Schema
schema
,
int
id
,
int
type
)
throws
SQLException
{
// tableName will be set later
// tableName will be set later
super
(
schema
,
id
,
null
,
true
);
super
(
schema
,
id
,
null
,
true
,
true
);
this
.
type
=
type
;
this
.
type
=
type
;
Column
[]
cols
;
Column
[]
cols
;
String
indexColumnName
=
null
;
String
indexColumnName
=
null
;
...
@@ -632,7 +632,7 @@ public class MetaTable extends Table {
...
@@ -632,7 +632,7 @@ public class MetaTable extends Table {
storageType
=
"LOCAL TEMPORARY"
;
storageType
=
"LOCAL TEMPORARY"
;
}
}
}
else
{
}
else
{
storageType
=
table
.
getPersistent
()
?
"CACHED"
:
"MEMORY"
;
storageType
=
table
.
isPersistIndexes
()
?
"CACHED"
:
"MEMORY"
;
}
}
add
(
rows
,
new
String
[]
{
add
(
rows
,
new
String
[]
{
// TABLE_CATALOG
// TABLE_CATALOG
...
...
h2/src/main/org/h2/table/RangeTable.java
浏览文件 @
3db03fa6
...
@@ -41,7 +41,7 @@ public class RangeTable extends Table {
...
@@ -41,7 +41,7 @@ public class RangeTable extends Table {
* @param max the end expression
* @param max the end expression
*/
*/
public
RangeTable
(
Schema
schema
,
Expression
min
,
Expression
max
)
throws
SQLException
{
public
RangeTable
(
Schema
schema
,
Expression
min
,
Expression
max
)
throws
SQLException
{
super
(
schema
,
0
,
NAME
,
true
);
super
(
schema
,
0
,
NAME
,
true
,
true
);
Column
[]
cols
=
new
Column
[]{
Column
[]
cols
=
new
Column
[]{
new
Column
(
"X"
,
Value
.
LONG
)
new
Column
(
"X"
,
Value
.
LONG
)
};
};
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
3db03fa6
...
@@ -84,7 +84,8 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -84,7 +84,8 @@ public abstract class Table extends SchemaObjectBase {
protected
int
memoryPerRow
;
protected
int
memoryPerRow
;
private
final
HashMap
columnMap
=
new
HashMap
();
private
final
HashMap
columnMap
=
new
HashMap
();
private
final
boolean
persistent
;
private
boolean
persistIndexes
;
private
boolean
persistData
;
private
ObjectArray
triggers
;
private
ObjectArray
triggers
;
private
ObjectArray
constraints
;
private
ObjectArray
constraints
;
private
ObjectArray
sequences
;
private
ObjectArray
sequences
;
...
@@ -93,9 +94,10 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -93,9 +94,10 @@ public abstract class Table extends SchemaObjectBase {
private
boolean
onCommitDrop
,
onCommitTruncate
;
private
boolean
onCommitDrop
,
onCommitTruncate
;
private
Row
nullRow
;
private
Row
nullRow
;
Table
(
Schema
schema
,
int
id
,
String
name
,
boolean
persist
ent
)
{
Table
(
Schema
schema
,
int
id
,
String
name
,
boolean
persist
Indexes
,
boolean
persistData
)
{
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
TABLE
);
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
TABLE
);
this
.
persistent
=
persistent
;
this
.
persistIndexes
=
persistIndexes
;
this
.
persistData
=
persistData
;
}
}
public
void
rename
(
String
newName
)
throws
SQLException
{
public
void
rename
(
String
newName
)
throws
SQLException
{
...
@@ -583,10 +585,6 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -583,10 +585,6 @@ public abstract class Table extends SchemaObjectBase {
}
}
}
}
public
boolean
getPersistent
()
{
return
persistent
;
}
private
void
remove
(
ObjectArray
list
,
DbObject
obj
)
{
private
void
remove
(
ObjectArray
list
,
DbObject
obj
)
{
if
(
list
!=
null
)
{
if
(
list
!=
null
)
{
int
i
=
list
.
indexOf
(
obj
);
int
i
=
list
.
indexOf
(
obj
);
...
@@ -899,4 +897,12 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -899,4 +897,12 @@ public abstract class Table extends SchemaObjectBase {
return
null
;
return
null
;
}
}
public
boolean
isPersistIndexes
()
{
return
persistIndexes
;
}
public
boolean
isPersistData
()
{
return
persistData
;
}
}
}
h2/src/main/org/h2/table/TableData.java
浏览文件 @
3db03fa6
...
@@ -61,17 +61,17 @@ public class TableData extends Table implements RecordReader {
...
@@ -61,17 +61,17 @@ public class TableData extends Table implements RecordReader {
private
boolean
containsLargeObject
;
private
boolean
containsLargeObject
;
public
TableData
(
Schema
schema
,
String
tableName
,
int
id
,
ObjectArray
columns
,
public
TableData
(
Schema
schema
,
String
tableName
,
int
id
,
ObjectArray
columns
,
boolean
persist
ent
,
boolean
clustered
,
int
headPos
)
throws
SQLException
{
boolean
persist
Indexes
,
boolean
persistData
,
boolean
clustered
,
int
headPos
)
throws
SQLException
{
super
(
schema
,
id
,
tableName
,
persist
ent
);
super
(
schema
,
id
,
tableName
,
persist
Indexes
,
persistData
);
Column
[]
cols
=
new
Column
[
columns
.
size
()];
Column
[]
cols
=
new
Column
[
columns
.
size
()];
columns
.
toArray
(
cols
);
columns
.
toArray
(
cols
);
setColumns
(
cols
);
setColumns
(
cols
);
this
.
clustered
=
clustered
;
this
.
clustered
=
clustered
;
if
(!
clustered
)
{
if
(!
clustered
)
{
if
(
SysProperties
.
PAGE_STORE
&&
database
.
isPersistent
())
{
if
(
SysProperties
.
PAGE_STORE
&&
persistData
&&
database
.
isPersistent
())
{
scanIndex
=
new
PageScanIndex
(
this
,
id
,
IndexColumn
.
wrap
(
cols
),
IndexType
.
createScan
(
persist
ent
),
headPos
);
scanIndex
=
new
PageScanIndex
(
this
,
id
,
IndexColumn
.
wrap
(
cols
),
IndexType
.
createScan
(
persist
Data
),
headPos
);
}
else
{
}
else
{
scanIndex
=
new
ScanIndex
(
this
,
id
,
IndexColumn
.
wrap
(
cols
),
IndexType
.
createScan
(
persist
ent
));
scanIndex
=
new
ScanIndex
(
this
,
id
,
IndexColumn
.
wrap
(
cols
),
IndexType
.
createScan
(
persist
Data
));
}
}
indexes
.
add
(
scanIndex
);
indexes
.
add
(
scanIndex
);
}
}
...
@@ -176,7 +176,7 @@ public class TableData extends Table implements RecordReader {
...
@@ -176,7 +176,7 @@ public class TableData extends Table implements RecordReader {
}
}
}
}
Index
index
;
Index
index
;
if
(
getPersistent
()
&&
indexType
.
getPersistent
())
{
if
(
isPersistIndexes
()
&&
indexType
.
getPersistent
())
{
if
(
SysProperties
.
PAGE_STORE
)
{
if
(
SysProperties
.
PAGE_STORE
)
{
index
=
new
PageBtreeIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
,
headPos
);
index
=
new
PageBtreeIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
,
headPos
);
}
else
{
}
else
{
...
@@ -545,7 +545,7 @@ public class TableData extends Table implements RecordReader {
...
@@ -545,7 +545,7 @@ public class TableData extends Table implements RecordReader {
buff
.
append
(
"LOCAL "
);
buff
.
append
(
"LOCAL "
);
}
}
buff
.
append
(
"TEMPORARY "
);
buff
.
append
(
"TEMPORARY "
);
}
else
if
(
getPersistent
())
{
}
else
if
(
isPersistIndexes
())
{
buff
.
append
(
"CACHED "
);
buff
.
append
(
"CACHED "
);
}
else
{
}
else
{
buff
.
append
(
"MEMORY "
);
buff
.
append
(
"MEMORY "
);
...
@@ -565,6 +565,9 @@ public class TableData extends Table implements RecordReader {
...
@@ -565,6 +565,9 @@ public class TableData extends Table implements RecordReader {
buff
.
append
(
column
.
getCreateSQL
());
buff
.
append
(
column
.
getCreateSQL
());
}
}
buff
.
append
(
"\n)"
);
buff
.
append
(
"\n)"
);
if
(!
getTemporary
()
&&
!
isPersistIndexes
()
&&
!
isPersistData
())
{
buff
.
append
(
"\nNOT PERSISTENT"
);
}
return
buff
.
toString
();
return
buff
.
toString
();
}
}
...
...
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
3db03fa6
...
@@ -59,7 +59,7 @@ public class TableLink extends Table {
...
@@ -59,7 +59,7 @@ public class TableLink extends Table {
public
TableLink
(
Schema
schema
,
int
id
,
String
name
,
String
driver
,
String
url
,
String
user
,
String
password
,
public
TableLink
(
Schema
schema
,
int
id
,
String
name
,
String
driver
,
String
url
,
String
user
,
String
password
,
String
originalSchema
,
String
originalTable
,
boolean
emitUpdates
,
boolean
force
)
throws
SQLException
{
String
originalSchema
,
String
originalTable
,
boolean
emitUpdates
,
boolean
force
)
throws
SQLException
{
super
(
schema
,
id
,
name
,
false
);
super
(
schema
,
id
,
name
,
false
,
true
);
this
.
driver
=
driver
;
this
.
driver
=
driver
;
this
.
url
=
url
;
this
.
url
=
url
;
this
.
user
=
user
;
this
.
user
=
user
;
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
3db03fa6
...
@@ -48,7 +48,7 @@ public class TableView extends Table {
...
@@ -48,7 +48,7 @@ public class TableView extends Table {
public
TableView
(
Schema
schema
,
int
id
,
String
name
,
String
querySQL
,
ObjectArray
params
,
String
[]
columnNames
,
public
TableView
(
Schema
schema
,
int
id
,
String
name
,
String
querySQL
,
ObjectArray
params
,
String
[]
columnNames
,
Session
session
,
boolean
recursive
)
throws
SQLException
{
Session
session
,
boolean
recursive
)
throws
SQLException
{
super
(
schema
,
id
,
name
,
false
);
super
(
schema
,
id
,
name
,
false
,
true
);
this
.
querySQL
=
querySQL
;
this
.
querySQL
=
querySQL
;
this
.
columnNames
=
columnNames
;
this
.
columnNames
=
columnNames
;
this
.
recursive
=
recursive
;
this
.
recursive
=
recursive
;
...
...
h2/src/test/org/h2/test/testSimple.in.txt
浏览文件 @
3db03fa6
create memory table test(id int) as select 1 from dual not persistent;
insert into test values(1);
select count(1) from test;
> 2;
@reconnect;
select count(1) from test;
> 0;
drop table test;
create table test(t clob) as select 1;
create table test(t clob) as select 1;
select distinct t from test;
select distinct t from test;
> 1;
> 1;
...
...
h2/src/test/org/h2/test/unit/TestPageStore.java
浏览文件 @
3db03fa6
...
@@ -167,8 +167,7 @@ public class TestPageStore extends TestBase {
...
@@ -167,8 +167,7 @@ public class TestPageStore extends TestBase {
ObjectArray
cols
=
new
ObjectArray
();
ObjectArray
cols
=
new
ObjectArray
();
cols
.
add
(
new
Column
(
"ID"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"ID"
,
Value
.
INT
));
schema
=
new
Schema
(
db
,
0
,
""
,
null
,
true
);
schema
=
new
Schema
(
db
,
0
,
""
,
null
,
true
);
table
=
new
TableData
(
schema
,
"PAGE_INDEX"
,
table
=
new
TableData
(
schema
,
"PAGE_INDEX"
,
1
,
cols
,
true
,
true
,
false
,
100
);
1
,
cols
,
true
,
false
,
100
);
index
=
(
PageScanIndex
)
table
.
getScanIndex
(
index
=
(
PageScanIndex
)
table
.
getScanIndex
(
db
.
getSystemSession
());
db
.
getSystemSession
());
}
}
...
@@ -178,8 +177,7 @@ public class TestPageStore extends TestBase {
...
@@ -178,8 +177,7 @@ public class TestPageStore extends TestBase {
cols
.
add
(
new
Column
(
"ID"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"ID"
,
Value
.
INT
));
schema
=
new
Schema
(
db
,
0
,
""
,
null
,
true
);
schema
=
new
Schema
(
db
,
0
,
""
,
null
,
true
);
int
id
=
db
.
allocateObjectId
(
true
,
true
);
int
id
=
db
.
allocateObjectId
(
true
,
true
);
table
=
new
TableData
(
schema
,
"BTREE_INDEX"
,
table
=
new
TableData
(
schema
,
"BTREE_INDEX"
,
id
,
cols
,
true
,
true
,
false
,
100
);
id
,
cols
,
true
,
false
,
100
);
id
=
db
.
allocateObjectId
(
true
,
true
);
id
=
db
.
allocateObjectId
(
true
,
true
);
table
.
addIndex
(
db
.
getSystemSession
(),
"BTREE"
,
id
,
table
.
addIndex
(
db
.
getSystemSession
(),
"BTREE"
,
id
,
IndexColumn
.
wrap
(
table
.
getColumns
()),
IndexColumn
.
wrap
(
table
.
getColumns
()),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论