Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7d2c7659
提交
7d2c7659
authored
5月 24, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use generics
上级
16a375cc
隐藏空白字符变更
内嵌
并排
正在显示
30 个修改的文件
包含
158 行增加
和
234 行删除
+158
-234
CommandRemote.java
h2/src/main/org/h2/command/CommandRemote.java
+5
-11
Parser.java
h2/src/main/org/h2/command/Parser.java
+4
-6
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+8
-12
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+11
-22
AlterTableRenameColumn.java
h2/src/main/org/h2/command/ddl/AlterTableRenameColumn.java
+1
-4
Analyze.java
h2/src/main/org/h2/command/ddl/Analyze.java
+1
-4
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+7
-13
DropDatabase.java
h2/src/main/org/h2/command/ddl/DropDatabase.java
+8
-19
GrantRevoke.java
h2/src/main/org/h2/command/ddl/GrantRevoke.java
+3
-6
Query.java
h2/src/main/org/h2/command/dml/Query.java
+1
-2
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+19
-42
Select.java
h2/src/main/org/h2/command/dml/Select.java
+19
-32
TransactionCommand.java
h2/src/main/org/h2/command/dml/TransactionCommand.java
+1
-3
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+6
-6
ConstraintUnique.java
h2/src/main/org/h2/constraint/ConstraintUnique.java
+2
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+8
-16
Session.java
h2/src/main/org/h2/engine/Session.java
+1
-3
UndoLogRecord.java
h2/src/main/org/h2/log/UndoLogRecord.java
+1
-4
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+4
-8
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+1
-2
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+1
-3
TableData.java
h2/src/main/org/h2/table/TableData.java
+3
-5
Backup.java
h2/src/main/org/h2/tools/Backup.java
+2
-4
ConvertTraceFile.java
h2/src/main/org/h2/tools/ConvertTraceFile.java
+1
-2
New.java
h2/src/main/org/h2/util/New.java
+1
-0
ObjectArray.java
h2/src/main/org/h2/util/ObjectArray.java
+28
-1
SmallLRUCache.java
h2/src/main/org/h2/util/SmallLRUCache.java
+8
-0
ValueHashMap.java
h2/src/main/org/h2/util/ValueHashMap.java
+1
-0
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+1
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/main/org/h2/command/CommandRemote.java
浏览文件 @
7d2c7659
...
...
@@ -205,9 +205,7 @@ public class CommandRemote implements CommandInterface {
}
private
void
checkParameters
()
throws
SQLException
{
int
len
=
parameters
.
size
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ParameterInterface
p
=
parameters
.
get
(
i
);
for
(
ParameterInterface
p
:
parameters
)
{
p
.
checkSet
();
}
}
...
...
@@ -215,8 +213,7 @@ public class CommandRemote implements CommandInterface {
private
void
sendParameters
(
Transfer
transfer
)
throws
IOException
,
SQLException
{
int
len
=
parameters
.
size
();
transfer
.
writeInt
(
len
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ParameterInterface
p
=
parameters
.
get
(
i
);
for
(
ParameterInterface
p
:
parameters
)
{
transfer
.
writeValue
(
p
.
getParamValue
());
}
}
...
...
@@ -226,10 +223,9 @@ public class CommandRemote implements CommandInterface {
return
;
}
synchronized
(
session
)
{
for
(
int
i
=
0
;
i
<
transferList
.
size
();
i
++)
{
session
.
traceOperation
(
"COMMAND_CLOSE"
,
id
);
for
(
Transfer
transfer
:
transferList
)
{
try
{
Transfer
transfer
=
transferList
.
get
(
i
);
session
.
traceOperation
(
"COMMAND_CLOSE"
,
id
);
transfer
.
writeInt
(
SessionRemote
.
COMMAND_CLOSE
).
writeInt
(
id
);
}
catch
(
IOException
e
)
{
trace
.
error
(
"close"
,
e
);
...
...
@@ -237,10 +233,8 @@ public class CommandRemote implements CommandInterface {
}
}
session
=
null
;
int
len
=
parameters
.
size
();
try
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ParameterInterface
p
=
parameters
.
get
(
i
);
for
(
ParameterInterface
p
:
parameters
)
{
Value
v
=
p
.
getParamValue
();
if
(
v
!=
null
)
{
v
.
close
();
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
7d2c7659
...
...
@@ -450,9 +450,7 @@ public class Parser {
p
.
setValue
(
expr
.
getValue
(
session
));
}
while
(
readIf
(
","
));
read
(
"}"
);
int
len
=
parameters
.
size
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Parameter
p
=
parameters
.
get
(
i
);
for
(
Parameter
p
:
parameters
)
{
p
.
checkSet
();
}
parameters
.
clear
();
...
...
@@ -3778,10 +3776,10 @@ public class Parser {
Schema
schema
=
getSchema
();
TableData
recursiveTable
;
read
(
"("
);
String
[]
cols
=
parseColumnList
();
ObjectArray
<
Column
>
columns
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
cols
.
length
;
i
++)
{
columns
.
add
(
new
Column
(
cols
[
i
],
Value
.
STRING
));
String
[]
cols
=
parseColumnList
();
for
(
String
c
:
cols
)
{
columns
.
add
(
new
Column
(
c
,
Value
.
STRING
));
}
int
id
=
database
.
allocateObjectId
(
true
,
true
);
recursiveTable
=
schema
.
createTable
(
tempViewName
,
id
,
columns
,
false
,
true
,
false
,
Index
.
EMPTY_HEAD
,
session
);
...
...
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
7d2c7659
...
...
@@ -287,9 +287,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
private
Index
getUniqueIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
ObjectArray
<
Index
>
list
=
t
.
getIndexes
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Index
idx
=
list
.
get
(
i
);
for
(
Index
idx
:
t
.
getIndexes
())
{
if
(
canUseUniqueIndex
(
idx
,
t
,
cols
))
{
return
idx
;
}
...
...
@@ -298,11 +296,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
private
Index
getIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
ObjectArray
<
Index
>
list
=
t
.
getIndexes
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Index
existingIndex
=
list
.
get
(
i
);
if
(
canUseIndex
(
existingIndex
,
t
,
cols
))
{
return
existingIndex
;
for
(
Index
idx
:
t
.
getIndexes
())
{
if
(
canUseIndex
(
idx
,
t
,
cols
))
{
return
idx
;
}
}
return
null
;
...
...
@@ -317,13 +313,13 @@ public class AlterTableAddConstraint extends SchemaCommand {
return
false
;
}
HashSet
<
Column
>
set
=
New
.
hashSet
();
for
(
int
i
=
0
;
i
<
cols
.
length
;
i
++
)
{
set
.
add
(
c
ols
[
i
]
.
column
);
for
(
IndexColumn
c
:
cols
)
{
set
.
add
(
c
.
column
);
}
for
(
int
j
=
0
;
j
<
indexCols
.
length
;
j
++
)
{
for
(
Column
c
:
indexCols
)
{
// all columns of the index must be part of the list,
// but not all columns of the list need to be part of the index
if
(!
set
.
contains
(
indexCols
[
j
]
))
{
if
(!
set
.
contains
(
c
))
{
return
false
;
}
}
...
...
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
7d2c7659
...
...
@@ -199,9 +199,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
private
void
checkNoViews
()
throws
SQLException
{
ObjectArray
<
DbObject
>
children
=
table
.
getChildren
();
for
(
int
i
=
0
;
i
<
children
.
size
();
i
++)
{
DbObject
child
=
children
.
get
(
i
);
for
(
DbObject
child
:
table
.
getChildren
())
{
if
(
child
.
getType
()
==
DbObject
.
TABLE_OR_VIEW
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
OPERATION_NOT_SUPPORTED_WITH_VIEWS_2
,
new
String
[]
{
table
.
getName
(),
child
.
getName
()
});
...
...
@@ -214,9 +212,8 @@ public class AlterTableAlterColumn extends SchemaCommand {
String
tempName
=
db
.
getTempTableName
(
session
.
getId
());
Column
[]
columns
=
table
.
getColumns
();
ObjectArray
<
Column
>
newColumns
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
col
=
columns
[
i
].
getClone
();
newColumns
.
add
(
col
);
for
(
Column
col
:
columns
)
{
newColumns
.
add
(
col
.
getClone
());
}
if
(
type
==
DROP
)
{
int
position
=
oldColumn
.
getColumnId
();
...
...
@@ -245,8 +242,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
StringBuffer
buff
=
new
StringBuffer
();
buff
.
append
(
newTable
.
getCreateSQL
());
StringBuffer
columnList
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
newColumns
.
size
();
i
++)
{
Column
nc
=
newColumns
.
get
(
i
);
for
(
Column
nc
:
newColumns
)
{
if
(
columnList
.
length
()
>
0
)
{
columnList
.
append
(
", "
);
}
...
...
@@ -269,10 +265,8 @@ public class AlterTableAlterColumn extends SchemaCommand {
String
newTableSQL
=
buff
.
toString
();
execute
(
newTableSQL
,
true
);
newTable
=
(
TableData
)
newTable
.
getSchema
().
getTableOrView
(
session
,
newTable
.
getName
());
ObjectArray
<
DbObject
>
children
=
table
.
getChildren
();
ObjectArray
<
String
>
triggers
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
children
.
size
();
i
++)
{
DbObject
child
=
children
.
get
(
i
);
for
(
DbObject
child
:
table
.
getChildren
())
{
if
(
child
instanceof
Sequence
)
{
continue
;
}
else
if
(
child
instanceof
Index
)
{
...
...
@@ -309,24 +303,21 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
String
tableName
=
table
.
getName
();
table
.
setModified
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++
)
{
for
(
Column
col
:
columns
)
{
// if we don't do that, the sequence is dropped when the table is
// dropped
Sequence
seq
=
col
umns
[
i
]
.
getSequence
();
Sequence
seq
=
col
.
getSequence
();
if
(
seq
!=
null
)
{
table
.
removeSequence
(
session
,
seq
);
col
umns
[
i
]
.
setSequence
(
null
);
col
.
setSequence
(
null
);
}
}
for
(
int
i
=
0
;
i
<
triggers
.
size
();
i
++)
{
String
sql
=
triggers
.
get
(
i
);
for
(
String
sql
:
triggers
)
{
execute
(
sql
,
true
);
}
execute
(
"DROP TABLE "
+
table
.
getSQL
(),
true
);
db
.
renameSchemaObject
(
session
,
newTable
,
tableName
);
children
=
newTable
.
getChildren
();
for
(
int
i
=
0
;
i
<
children
.
size
();
i
++)
{
DbObject
child
=
children
.
get
(
i
);
for
(
DbObject
child
:
newTable
.
getChildren
())
{
if
(
child
instanceof
Sequence
)
{
continue
;
}
...
...
@@ -378,9 +369,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
private
void
checkNullable
()
throws
SQLException
{
ObjectArray
<
Index
>
indexes
=
table
.
getIndexes
();
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
for
(
Index
index
:
table
.
getIndexes
())
{
if
(
index
.
getColumnIndex
(
oldColumn
)
<
0
)
{
continue
;
}
...
...
h2/src/main/org/h2/command/ddl/AlterTableRenameColumn.java
浏览文件 @
7d2c7659
...
...
@@ -13,7 +13,6 @@ import org.h2.engine.Right;
import
org.h2.engine.Session
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.util.ObjectArray
;
/**
* This class represents the statement
...
...
@@ -49,9 +48,7 @@ public class AlterTableRenameColumn extends DefineCommand {
table
.
renameColumn
(
column
,
newName
);
table
.
setModified
();
db
.
update
(
session
,
table
);
ObjectArray
<
DbObject
>
children
=
table
.
getChildren
();
for
(
int
i
=
0
;
i
<
children
.
size
();
i
++)
{
DbObject
child
=
children
.
get
(
i
);
for
(
DbObject
child
:
table
.
getChildren
())
{
if
(
child
.
getCreateSQL
()
!=
null
)
{
db
.
update
(
session
,
child
);
}
...
...
h2/src/main/org/h2/command/ddl/Analyze.java
浏览文件 @
7d2c7659
...
...
@@ -15,7 +15,6 @@ import org.h2.result.LocalResult;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.table.TableData
;
import
org.h2.util.ObjectArray
;
/**
* This class represents the statement
...
...
@@ -33,10 +32,8 @@ public class Analyze extends DefineCommand {
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
session
.
getUser
().
checkAdmin
();
ObjectArray
<
Table
>
tables
=
db
.
getAllTablesAndViews
();
// TODO do we need to lock the table?
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
db
.
getAllTablesAndViews
())
{
if
(!(
table
instanceof
TableData
))
{
continue
;
}
...
...
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
7d2c7659
...
...
@@ -121,19 +121,16 @@ public class CreateTable extends SchemaCommand {
}
}
if
(
pkColumns
!=
null
)
{
int
len
=
pkColumns
.
length
;
for
(
int
i
=
0
;
i
<
columns
.
size
();
i
++)
{
Column
c
=
columns
.
get
(
i
);
for
(
int
j
=
0
;
j
<
len
;
j
++)
{
if
(
c
.
getName
().
equals
(
pkColumns
[
j
].
columnName
))
{
for
(
Column
c
:
columns
)
{
for
(
IndexColumn
idxCol
:
pkColumns
)
{
if
(
c
.
getName
().
equals
(
idxCol
.
columnName
))
{
c
.
setNullable
(
false
);
}
}
}
}
ObjectArray
<
Sequence
>
sequences
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
columns
.
size
();
i
++)
{
Column
c
=
columns
.
get
(
i
);
for
(
Column
c
:
columns
)
{
if
(
c
.
getAutoIncrement
())
{
int
objId
=
getObjectId
(
true
,
true
);
c
.
convertAutoIncrementToSequence
(
session
,
getSchema
(),
objId
,
temporary
);
...
...
@@ -160,16 +157,13 @@ public class CreateTable extends SchemaCommand {
db
.
addSchemaObject
(
session
,
table
);
}
try
{
for
(
int
i
=
0
;
i
<
columns
.
size
();
i
++)
{
Column
c
=
columns
.
get
(
i
);
for
(
Column
c
:
columns
)
{
c
.
prepareExpression
(
session
);
}
for
(
int
i
=
0
;
i
<
sequences
.
size
();
i
++)
{
Sequence
sequence
=
sequences
.
get
(
i
);
for
(
Sequence
sequence
:
sequences
)
{
table
.
addSequence
(
sequence
);
}
for
(
int
i
=
0
;
i
<
constraintCommands
.
size
();
i
++)
{
Prepared
command
=
constraintCommands
.
get
(
i
);
for
(
Prepared
command
:
constraintCommands
)
{
command
.
update
();
}
if
(
asQuery
!=
null
)
{
...
...
h2/src/main/org/h2/command/ddl/DropDatabase.java
浏览文件 @
7d2c7659
...
...
@@ -45,28 +45,23 @@ public class DropDatabase extends DefineCommand {
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
// TODO local temp tables are not removed
ObjectArray
<
Schema
>
schemas
=
db
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
schemas
.
size
();
i
++)
{
Schema
schema
=
schemas
.
get
(
i
);
for
(
Schema
schema
:
db
.
getAllSchemas
())
{
if
(
schema
.
canDrop
())
{
db
.
removeDatabaseObject
(
session
,
schema
);
}
}
ObjectArray
<
Table
>
tables
=
db
.
getAllTablesAndViews
();
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
tables
.
get
(
i
);
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
Table
.
VIEW
.
equals
(
t
.
getTableType
()))
{
db
.
removeSchemaObject
(
session
,
t
);
}
}
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
tables
.
get
(
i
);
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
Table
.
TABLE_LINK
.
equals
(
t
.
getTableType
()))
{
db
.
removeSchemaObject
(
session
,
t
);
}
}
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
tables
.
get
(
i
);
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
Table
.
TABLE
.
equals
(
t
.
getTableType
()))
{
db
.
removeSchemaObject
(
session
,
t
);
}
...
...
@@ -79,20 +74,15 @@ public class DropDatabase extends DefineCommand {
list
.
addAll
(
db
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
));
list
.
addAll
(
db
.
getAllSchemaObjects
(
DbObject
.
TRIGGER
));
list
.
addAll
(
db
.
getAllSchemaObjects
(
DbObject
.
CONSTANT
));
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
SchemaObject
obj
=
list
.
get
(
i
);
for
(
SchemaObject
obj
:
list
)
{
db
.
removeSchemaObject
(
session
,
obj
);
}
ObjectArray
<
User
>
users
=
db
.
getAllUsers
();
for
(
int
i
=
0
;
i
<
users
.
size
();
i
++)
{
User
user
=
users
.
get
(
i
);
for
(
User
user
:
db
.
getAllUsers
())
{
if
(
user
!=
session
.
getUser
())
{
db
.
removeDatabaseObject
(
session
,
user
);
}
}
ObjectArray
<
Role
>
roles
=
db
.
getAllRoles
();
for
(
int
i
=
0
;
i
<
roles
.
size
();
i
++)
{
Role
role
=
roles
.
get
(
i
);
for
(
Role
role
:
db
.
getAllRoles
())
{
String
sql
=
role
.
getCreateSQL
();
// the role PUBLIC must not be dropped
if
(
sql
!=
null
)
{
...
...
@@ -104,8 +94,7 @@ public class DropDatabase extends DefineCommand {
dbObjects
.
addAll
(
db
.
getAllFunctionAliases
());
dbObjects
.
addAll
(
db
.
getAllAggregates
());
dbObjects
.
addAll
(
db
.
getAllUserDataTypes
());
for
(
int
i
=
0
;
i
<
dbObjects
.
size
();
i
++)
{
DbObject
obj
=
dbObjects
.
get
(
i
);
for
(
DbObject
obj
:
dbObjects
)
{
String
sql
=
obj
.
getCreateSQL
();
// the role PUBLIC must not be dropped
if
(
sql
!=
null
)
{
...
...
h2/src/main/org/h2/command/ddl/GrantRevoke.java
浏览文件 @
7d2c7659
...
...
@@ -88,8 +88,7 @@ public class GrantRevoke extends DefineCommand {
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
if
(
roleNames
!=
null
)
{
for
(
int
i
=
0
;
i
<
roleNames
.
size
();
i
++)
{
String
name
=
roleNames
.
get
(
i
);
for
(
String
name
:
roleNames
)
{
Role
grantedRole
=
db
.
findRole
(
name
);
if
(
grantedRole
==
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
ROLE_NOT_FOUND_1
,
name
);
...
...
@@ -116,8 +115,7 @@ public class GrantRevoke extends DefineCommand {
private
void
grantRight
()
throws
SQLException
{
Database
db
=
session
.
getDatabase
();
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
tables
)
{
Right
right
=
grantee
.
getRightForTable
(
table
);
if
(
right
==
null
)
{
int
id
=
getObjectId
(
true
,
true
);
...
...
@@ -149,8 +147,7 @@ public class GrantRevoke extends DefineCommand {
}
private
void
revokeRight
()
throws
SQLException
{
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
tables
)
{
Right
right
=
grantee
.
getRightForTable
(
table
);
if
(
right
==
null
)
{
continue
;
...
...
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
7d2c7659
...
...
@@ -254,8 +254,7 @@ public abstract class Query extends Prepared {
*/
void
initOrder
(
ObjectArray
<
Expression
>
expressions
,
ObjectArray
<
String
>
expressionSQL
,
ObjectArray
<
SelectOrderBy
>
orderList
,
int
visible
,
boolean
mustBeInResult
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
orderList
.
get
(
i
);
for
(
SelectOrderBy
o
:
orderList
)
{
Expression
e
=
o
.
expression
;
if
(
e
==
null
)
{
continue
;
...
...
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
7d2c7659
...
...
@@ -126,9 +126,7 @@ public class ScriptCommand extends ScriptBase {
}
Database
db
=
session
.
getDatabase
();
if
(
settings
)
{
ObjectArray
<
Setting
>
settingList
=
db
.
getAllSettings
();
for
(
int
i
=
0
;
i
<
settingList
.
size
();
i
++)
{
Setting
setting
=
settingList
.
get
(
i
);
for
(
Setting
setting
:
db
.
getAllSettings
())
{
if
(
setting
.
getName
().
equals
(
SetTypes
.
getTypeName
(
SetTypes
.
CREATE_BUILD
)))
{
// don't add CREATE_BUILD to the script
// (it is only set when creating the database)
...
...
@@ -140,45 +138,32 @@ public class ScriptCommand extends ScriptBase {
if
(
out
!=
null
)
{
add
(
""
,
true
);
}
ObjectArray
<
User
>
users
=
db
.
getAllUsers
();
for
(
int
i
=
0
;
i
<
users
.
size
();
i
++)
{
User
user
=
users
.
get
(
i
);
for
(
User
user
:
db
.
getAllUsers
())
{
add
(
user
.
getCreateSQL
(
passwords
,
true
),
false
);
}
ObjectArray
<
Role
>
roles
=
db
.
getAllRoles
();
for
(
int
i
=
0
;
i
<
roles
.
size
();
i
++)
{
Role
role
=
roles
.
get
(
i
);
for
(
Role
role
:
db
.
getAllRoles
())
{
add
(
role
.
getCreateSQL
(
true
),
false
);
}
ObjectArray
<
Schema
>
schemas
=
db
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
schemas
.
size
();
i
++)
{
Schema
schema
=
schemas
.
get
(
i
);
for
(
Schema
schema
:
db
.
getAllSchemas
())
{
add
(
schema
.
getCreateSQL
(),
false
);
}
ObjectArray
<
UserDataType
>
datatypes
=
db
.
getAllUserDataTypes
();
for
(
int
i
=
0
;
i
<
datatypes
.
size
();
i
++)
{
UserDataType
datatype
=
datatypes
.
get
(
i
);
for
(
UserDataType
datatype
:
db
.
getAllUserDataTypes
())
{
if
(
drop
)
{
add
(
datatype
.
getDropSQL
(),
false
);
}
add
(
datatype
.
getCreateSQL
(),
false
);
}
ObjectArray
<
SchemaObject
>
constants
=
db
.
getAllSchemaObjects
(
DbObject
.
CONSTANT
);
for
(
int
i
=
0
;
i
<
constants
.
size
();
i
++)
{
Constant
constant
=
(
Constant
)
constants
.
get
(
i
);
for
(
SchemaObject
obj
:
db
.
getAllSchemaObjects
(
DbObject
.
CONSTANT
))
{
Constant
constant
=
(
Constant
)
obj
;
add
(
constant
.
getCreateSQL
(),
false
);
}
ObjectArray
<
FunctionAlias
>
functionAliases
=
db
.
getAllFunctionAliases
();
for
(
int
i
=
0
;
i
<
functionAliases
.
size
();
i
++)
{
FunctionAlias
alias
=
functionAliases
.
get
(
i
);
for
(
FunctionAlias
alias
:
db
.
getAllFunctionAliases
())
{
if
(
drop
)
{
add
(
alias
.
getDropSQL
(),
false
);
}
add
(
alias
.
getCreateSQL
(),
false
);
}
ObjectArray
<
UserAggregate
>
aggregates
=
db
.
getAllAggregates
();
for
(
int
i
=
0
;
i
<
aggregates
.
size
();
i
++)
{
UserAggregate
agg
=
aggregates
.
get
(
i
);
for
(
UserAggregate
agg
:
db
.
getAllAggregates
())
{
if
(
drop
)
{
add
(
agg
.
getDropSQL
(),
false
);
}
...
...
@@ -192,8 +177,7 @@ public class ScriptCommand extends ScriptBase {
return
t1
.
getId
()
-
t2
.
getId
();
}
});
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
tables
)
{
table
.
lock
(
session
,
false
,
false
);
String
sql
=
table
.
getCreateSQL
();
if
(
sql
==
null
)
{
...
...
@@ -204,16 +188,14 @@ public class ScriptCommand extends ScriptBase {
add
(
table
.
getDropSQL
(),
false
);
}
}
ObjectArray
<
SchemaObject
>
sequences
=
db
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
);
for
(
int
i
=
0
;
i
<
sequences
.
size
();
i
++)
{
Sequence
sequence
=
(
Sequence
)
sequences
.
get
(
i
);
for
(
SchemaObject
obj
:
db
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
))
{
Sequence
sequence
=
(
Sequence
)
obj
;
if
(
drop
&&
!
sequence
.
getBelongsToTable
())
{
add
(
sequence
.
getDropSQL
(),
false
);
}
add
(
sequence
.
getCreateSQL
(),
false
);
}
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
tables
)
{
table
.
lock
(
session
,
false
,
false
);
String
sql
=
table
.
getCreateSQL
();
if
(
sql
==
null
)
{
...
...
@@ -309,23 +291,18 @@ public class ScriptCommand extends ScriptBase {
return
((
Constraint
)
c1
).
compareTo
((
Constraint
)
c2
);
}
});
for
(
int
i
=
0
;
i
<
constraints
.
size
();
i
++
)
{
Constraint
constraint
=
(
Constraint
)
constraints
.
get
(
i
)
;
for
(
SchemaObject
obj
:
constraints
)
{
Constraint
constraint
=
(
Constraint
)
obj
;
add
(
constraint
.
getCreateSQLWithoutIndexes
(),
false
);
}
ObjectArray
<
SchemaObject
>
triggers
=
db
.
getAllSchemaObjects
(
DbObject
.
TRIGGER
);
for
(
int
i
=
0
;
i
<
triggers
.
size
();
i
++)
{
TriggerObject
trigger
=
(
TriggerObject
)
triggers
.
get
(
i
);
for
(
SchemaObject
obj
:
db
.
getAllSchemaObjects
(
DbObject
.
TRIGGER
))
{
TriggerObject
trigger
=
(
TriggerObject
)
obj
;
add
(
trigger
.
getCreateSQL
(),
false
);
}
ObjectArray
<
Right
>
rights
=
db
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
rights
.
get
(
i
);
for
(
Right
right
:
db
.
getAllRights
())
{
add
(
right
.
getCreateSQL
(),
false
);
}
ObjectArray
<
Comment
>
comments
=
db
.
getAllComments
();
for
(
int
i
=
0
;
i
<
comments
.
size
();
i
++)
{
Comment
comment
=
comments
.
get
(
i
);
for
(
Comment
comment
:
db
.
getAllComments
())
{
add
(
comment
.
getCreateSQL
(),
false
);
}
if
(
out
!=
null
)
{
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
7d2c7659
...
...
@@ -291,8 +291,8 @@ public class Select extends Query {
return
0
;
}
int
count
=
0
;
for
(
int
i
=
0
;
i
<
groupByExpression
.
length
;
i
++
)
{
if
(
groupByExpression
[
i
]
)
{
for
(
boolean
b
:
groupByExpression
)
{
if
(
b
)
{
++
count
;
}
}
...
...
@@ -345,8 +345,8 @@ public class Select extends Query {
groups
.
put
(
defaultGroup
,
new
HashMap
<
Expression
,
Object
>());
}
ObjectArray
<
Value
>
keys
=
groups
.
keys
();
for
(
int
i
=
0
;
i
<
keys
.
size
();
i
++
)
{
ValueArray
key
=
(
ValueArray
)
keys
.
get
(
i
)
;
for
(
Value
v
:
keys
)
{
ValueArray
key
=
(
ValueArray
)
v
;
currentGroup
=
groups
.
get
(
key
);
Value
[]
keyValues
=
key
.
getList
();
Value
[]
row
=
new
Value
[
columnCount
];
...
...
@@ -380,10 +380,8 @@ public class Select extends Query {
if
(
sort
==
null
)
{
return
null
;
}
int
[]
indexes
=
sort
.
getIndexes
();
ObjectArray
<
Column
>
sortColumns
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
indexes
.
length
;
i
++)
{
int
idx
=
indexes
[
i
];
for
(
int
idx
:
sort
.
getIndexes
())
{
if
(
idx
<
0
||
idx
>=
expressions
.
size
())
{
throw
Message
.
getInvalidValueException
(
""
+
(
idx
+
1
),
"ORDER BY"
);
}
...
...
@@ -685,16 +683,14 @@ public class Select extends Query {
}
}
groupByExpression
=
new
boolean
[
expressions
.
size
()];
for
(
int
i
=
0
;
i
<
groupIndex
.
length
;
i
++
)
{
groupByExpression
[
g
roupIndex
[
i
]
]
=
true
;
for
(
int
gi
:
groupIndex
)
{
groupByExpression
[
g
i
]
=
true
;
}
group
=
null
;
}
// map columns in select list and condition
for
(
int
i
=
0
;
i
<
filters
.
size
();
i
++)
{
TableFilter
f
=
filters
.
get
(
i
);
for
(
int
j
=
0
;
j
<
expressions
.
size
();
j
++)
{
Expression
expr
=
expressions
.
get
(
j
);
for
(
TableFilter
f
:
filters
)
{
for
(
Expression
expr
:
expressions
)
{
expr
.
mapColumns
(
f
,
0
);
}
if
(
condition
!=
null
)
{
...
...
@@ -795,19 +791,17 @@ public class Select extends Query {
public
HashSet
<
Table
>
getTables
()
{
HashSet
<
Table
>
set
=
New
.
hashSet
();
for
(
int
i
=
0
;
i
<
filters
.
size
();
i
++)
{
TableFilter
filter
=
filters
.
get
(
i
);
for
(
TableFilter
filter
:
filters
)
{
set
.
add
(
filter
.
getTable
());
}
return
set
;
}
private
double
preparePlan
()
throws
SQLException
{
TableFilter
[]
topArray
=
new
TableFilter
[
topFilters
.
size
()];
topFilters
.
toArray
(
topArray
);
for
(
int
i
=
0
;
i
<
topArray
.
length
;
i
++
)
{
t
opArray
[
i
]
.
setFullCondition
(
condition
);
for
(
TableFilter
t
:
topArray
)
{
t
.
setFullCondition
(
condition
);
}
Optimizer
optimizer
=
new
Optimizer
(
topArray
,
condition
,
session
);
...
...
@@ -845,8 +839,7 @@ public class Select extends Query {
}
// this is only important for subqueries, so they know
// the result columns are evaluatable
for
(
int
i
=
0
;
i
<
expressions
.
size
();
i
++)
{
Expression
e
=
expressions
.
get
(
i
);
for
(
Expression
e
:
expressions
)
{
e
.
setEvaluatable
(
f
,
true
);
}
f
=
f
.
getJoin
();
...
...
@@ -995,8 +988,7 @@ public class Select extends Query {
}
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
expressions
.
size
();
i
++)
{
Expression
e
=
expressions
.
get
(
i
);
for
(
Expression
e
:
expressions
)
{
e
.
mapColumns
(
resolver
,
level
);
}
if
(
condition
!=
null
)
{
...
...
@@ -1005,8 +997,7 @@ public class Select extends Query {
}
public
void
setEvaluatable
(
TableFilter
tableFilter
,
boolean
b
)
{
for
(
int
i
=
0
;
i
<
expressions
.
size
();
i
++)
{
Expression
e
=
expressions
.
get
(
i
);
for
(
Expression
e
:
expressions
)
{
e
.
setEvaluatable
(
tableFilter
,
b
);
}
if
(
condition
!=
null
)
{
...
...
@@ -1061,8 +1052,7 @@ public class Select extends Query {
}
public
void
updateAggregate
(
Session
s
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
expressions
.
size
();
i
++)
{
Expression
e
=
expressions
.
get
(
i
);
for
(
Expression
e
:
expressions
)
{
e
.
updateAggregate
(
s
);
}
if
(
condition
!=
null
)
{
...
...
@@ -1076,8 +1066,7 @@ public class Select extends Query {
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
switch
(
visitor
.
getType
())
{
case
ExpressionVisitor
.
SET_MAX_DATA_MODIFICATION_ID
:
{
for
(
int
i
=
0
;
i
<
filters
.
size
();
i
++)
{
TableFilter
f
=
filters
.
get
(
i
);
for
(
TableFilter
f
:
filters
)
{
long
m
=
f
.
getTable
().
getMaxDataModificationId
();
visitor
.
addDataModificationId
(
m
);
}
...
...
@@ -1090,8 +1079,7 @@ public class Select extends Query {
break
;
}
case
ExpressionVisitor
.
GET_DEPENDENCIES
:
{
for
(
int
i
=
0
;
i
<
filters
.
size
();
i
++)
{
TableFilter
filter
=
filters
.
get
(
i
);
for
(
TableFilter
filter
:
filters
)
{
Table
table
=
filter
.
getTable
();
visitor
.
addDependency
(
table
);
table
.
addDependencies
(
visitor
.
getDependencies
());
...
...
@@ -1102,8 +1090,7 @@ public class Select extends Query {
}
visitor
.
incrementQueryLevel
(
1
);
boolean
result
=
true
;
for
(
int
i
=
0
;
i
<
expressions
.
size
();
i
++)
{
Expression
e
=
expressions
.
get
(
i
);
for
(
Expression
e
:
expressions
)
{
if
(!
e
.
isEverything
(
visitor
))
{
result
=
false
;
break
;
...
...
h2/src/main/org/h2/command/dml/TransactionCommand.java
浏览文件 @
7d2c7659
...
...
@@ -158,9 +158,7 @@ public class TransactionCommand extends Prepared {
// throttle, to allow testing concurrent
// execution of shutdown and query
session
.
throttle
();
Session
[]
sessions
=
db
.
getSessions
(
false
);
for
(
int
i
=
0
;
i
<
sessions
.
length
;
i
++)
{
Session
s
=
sessions
[
i
];
for
(
Session
s
:
db
.
getSessions
(
false
))
{
if
(
db
.
isMultiThreaded
())
{
synchronized
(
s
)
{
s
.
rollback
();
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
7d2c7659
...
...
@@ -299,8 +299,8 @@ public class ConstraintReferential extends Constraint {
return
;
}
boolean
constraintColumnsEqual
=
oldRow
!=
null
;
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++
)
{
int
idx
=
col
umns
[
i
]
.
column
.
getColumnId
();
for
(
IndexColumn
col
:
columns
)
{
int
idx
=
col
.
column
.
getColumnId
();
Value
v
=
newRow
.
getValue
(
idx
);
if
(
v
==
ValueNull
.
INSTANCE
)
{
// return early if one of the columns is NULL
...
...
@@ -606,13 +606,13 @@ public class ConstraintReferential extends Constraint {
}
public
boolean
containsColumn
(
Column
col
)
{
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++
)
{
if
(
c
olumns
[
i
]
.
column
==
col
)
{
for
(
IndexColumn
c
:
columns
)
{
if
(
c
.
column
==
col
)
{
return
true
;
}
}
for
(
int
i
=
0
;
i
<
refColumns
.
length
;
i
++
)
{
if
(
refColumns
[
i
]
.
column
==
col
)
{
for
(
IndexColumn
c
:
refColumns
)
{
if
(
c
.
column
==
col
)
{
return
true
;
}
}
...
...
h2/src/main/org/h2/constraint/ConstraintUnique.java
浏览文件 @
7d2c7659
...
...
@@ -128,8 +128,8 @@ public class ConstraintUnique extends Constraint {
}
public
boolean
containsColumn
(
Column
col
)
{
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++
)
{
if
(
c
olumns
[
i
]
.
column
==
col
)
{
for
(
IndexColumn
c
:
columns
)
{
if
(
c
.
column
==
col
)
{
return
true
;
}
}
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
7d2c7659
...
...
@@ -585,9 +585,7 @@ public class Database implements DataHandler {
}
catch
(
Exception
e
)
{
if
(
recovery
)
{
traceSystem
.
getTrace
(
Trace
.
DATABASE
).
error
(
"opening index"
,
e
);
ArrayList
<
Storage
>
list
=
New
.
arrayList
(
storageMap
.
values
());
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Storage
s
=
list
.
get
(
i
);
for
(
Storage
s
:
New
.
arrayList
(
storageMap
.
values
()))
{
if
(
s
.
getDiskFile
()
==
fileIndex
)
{
removeStorage
(
s
.
getId
(),
fileIndex
);
}
...
...
@@ -695,9 +693,7 @@ public class Database implements DataHandler {
boolean
recompileSuccessful
;
do
{
recompileSuccessful
=
false
;
ObjectArray
<
Table
>
list
=
getAllTablesAndViews
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Table
obj
=
list
.
get
(
i
);
for
(
Table
obj
:
getAllTablesAndViews
())
{
if
(
obj
instanceof
TableView
)
{
TableView
view
=
(
TableView
)
obj
;
if
(
view
.
getInvalid
())
{
...
...
@@ -716,9 +712,7 @@ public class Database implements DataHandler {
// when opening a database, views are initialized before indexes,
// so they may not have the optimal plan yet
// this is not a problem, it is just nice to see the newest plan
ObjectArray
<
Table
>
list
=
getAllTablesAndViews
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Table
obj
=
list
.
get
(
i
);
for
(
Table
obj
:
getAllTablesAndViews
())
{
if
(
obj
instanceof
TableView
)
{
TableView
view
=
(
TableView
)
obj
;
if
(!
view
.
getInvalid
())
{
...
...
@@ -1630,10 +1624,8 @@ public class Database implements DataHandler {
return
null
;
default
:
}
ObjectArray
<
Table
>
list
=
getAllTablesAndViews
();
HashSet
<
DbObject
>
set
=
New
.
hashSet
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Table
t
=
list
.
get
(
i
);
for
(
Table
t
:
getAllTablesAndViews
())
{
if
(
except
==
t
)
{
continue
;
}
...
...
@@ -1649,9 +1641,7 @@ public class Database implements DataHandler {
private
String
getFirstInvalidTable
(
Session
session
)
{
String
conflict
=
null
;
try
{
ObjectArray
<
Table
>
list
=
getAllTablesAndViews
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Table
t
=
list
.
get
(
i
);
for
(
Table
t
:
getAllTablesAndViews
())
{
conflict
=
t
.
getSQL
();
session
.
prepare
(
t
.
getCreateSQL
());
}
...
...
@@ -1971,7 +1961,9 @@ public class Database implements DataHandler {
log
.
setDisabled
(!
logData
);
log
.
checkpoint
();
}
traceSystem
.
getTrace
(
Trace
.
DATABASE
).
error
(
"SET LOG "
+
level
,
null
);
if
(
level
==
0
)
{
traceSystem
.
getTrace
(
Trace
.
DATABASE
).
error
(
"SET LOG "
+
level
,
null
);
}
logLevel
=
level
;
}
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
7d2c7659
...
...
@@ -649,9 +649,7 @@ public class Session extends SessionWithState {
private
void
cleanTempTables
(
boolean
closeSession
)
throws
SQLException
{
if
(
localTempTables
!=
null
&&
localTempTables
.
size
()
>
0
)
{
ObjectArray
<
Table
>
list
=
ObjectArray
.
newInstance
(
localTempTables
.
values
());
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Table
table
=
list
.
get
(
i
);
for
(
Table
table
:
ObjectArray
.
newInstance
(
localTempTables
.
values
()))
{
if
(
closeSession
||
table
.
getOnCommitDrop
())
{
modificationId
++;
table
.
setModified
();
...
...
h2/src/main/org/h2/log/UndoLogRecord.java
浏览文件 @
7d2c7659
...
...
@@ -19,7 +19,6 @@ import org.h2.result.Row;
import
org.h2.store.DataPage
;
import
org.h2.store.FileStore
;
import
org.h2.table.Table
;
import
org.h2.util.ObjectArray
;
import
org.h2.value.Value
;
/**
...
...
@@ -212,9 +211,7 @@ public class UndoLogRecord {
* It commits the change to the indexes.
*/
public
void
commit
()
throws
SQLException
{
ObjectArray
<
Index
>
list
=
table
.
getIndexes
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Index
index
=
list
.
get
(
i
);
for
(
Index
index
:
table
.
getIndexes
())
{
index
.
commit
(
operation
,
row
);
}
}
...
...
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
7d2c7659
...
...
@@ -276,9 +276,7 @@ public class DiskFile implements CacheWriter {
public
void
initFromSummary
(
byte
[]
summary
)
{
synchronized
(
database
)
{
if
(
summary
==
null
||
summary
.
length
==
0
)
{
ObjectArray
<
Storage
>
list
=
database
.
getAllStorages
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Storage
s
=
list
.
get
(
i
);
for
(
Storage
s
:
database
.
getAllStorages
())
{
if
(
s
!=
null
&&
s
.
getDiskFile
()
==
this
)
{
database
.
removeStorage
(
s
.
getId
(),
this
);
}
...
...
@@ -428,8 +426,7 @@ public class DiskFile implements CacheWriter {
database
.
checkPowerOff
();
ObjectArray
<
CacheObject
>
list
=
cache
.
getAllChanged
();
CacheObject
.
sort
(
list
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Record
rec
=
(
Record
)
list
.
get
(
i
);
for
(
CacheObject
rec
:
list
)
{
writeBack
(
rec
);
}
for
(
int
i
=
0
;
i
<
fileBlockCount
;
i
++)
{
...
...
@@ -1072,9 +1069,8 @@ public class DiskFile implements CacheWriter {
int
storageId
=
storage
.
getId
();
// make sure the cache records of this storage are not flushed to disk
// afterwards
ObjectArray
<
CacheObject
>
list
=
cache
.
getAllChanged
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Record
r
=
(
Record
)
list
.
get
(
i
);
for
(
CacheObject
obj
:
cache
.
getAllChanged
())
{
Record
r
=
(
Record
)
obj
;
if
(
r
.
getStorageId
()
==
storageId
)
{
r
.
setChanged
(
false
);
}
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
7d2c7659
...
...
@@ -265,8 +265,7 @@ public class PageStore implements CacheWriter {
database
.
checkPowerOff
();
ObjectArray
<
CacheObject
>
list
=
cache
.
getAllChanged
();
CacheObject
.
sort
(
list
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
CacheObject
rec
=
list
.
get
(
i
);
for
(
CacheObject
rec
:
list
)
{
writeBack
(
rec
);
}
int
todoFlushBeforeReopen
;
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
7d2c7659
...
...
@@ -805,9 +805,7 @@ public class MetaTable extends Table {
break
;
}
case
SETTINGS:
{
ObjectArray
<
Setting
>
list
=
database
.
getAllSettings
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Setting
s
=
list
.
get
(
i
);
for
(
Setting
s
:
database
.
getAllSettings
())
{
String
value
=
s
.
getStringValue
();
if
(
value
==
null
)
{
value
=
""
+
s
.
getIntValue
();
...
...
h2/src/main/org/h2/table/TableData.java
浏览文件 @
7d2c7659
...
...
@@ -278,8 +278,7 @@ public class TableData extends Table implements RecordReader {
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Row
row
=
list
.
get
(
i
);
for
(
Row
row
:
list
)
{
index
.
add
(
session
,
row
);
}
list
.
clear
();
...
...
@@ -640,9 +639,8 @@ public class TableData extends Table implements RecordReader {
}
}
if
(
SysProperties
.
CHECK
)
{
ObjectArray
<
SchemaObject
>
list
=
database
.
getAllSchemaObjects
(
DbObject
.
INDEX
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Index
index
=
(
Index
)
list
.
get
(
i
);
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
DbObject
.
INDEX
))
{
Index
index
=
(
Index
)
obj
;
if
(
index
.
getTable
()
==
this
)
{
Message
.
throwInternalError
(
"index not dropped: "
+
index
.
getName
());
}
...
...
h2/src/main/org/h2/tools/Backup.java
浏览文件 @
7d2c7659
...
...
@@ -106,14 +106,12 @@ public class Backup extends Tool {
fileOut
=
FileUtils
.
openFileOutputStream
(
zipFileName
,
false
);
ZipOutputStream
zipOut
=
new
ZipOutputStream
(
fileOut
);
String
base
=
""
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
String
fileName
=
list
.
get
(
i
);
for
(
String
fileName
:
list
)
{
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_DATA_FILE
))
{
base
=
FileUtils
.
getParent
(
fileName
);
}
}
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
String
fileName
=
list
.
get
(
i
);
for
(
String
fileName
:
list
)
{
String
f
=
FileUtils
.
getAbsolutePath
(
fileName
);
if
(!
f
.
startsWith
(
base
))
{
Message
.
throwInternalError
(
f
+
" does not start with "
+
base
);
...
...
h2/src/main/org/h2/tools/ConvertTraceFile.java
浏览文件 @
7d2c7659
...
...
@@ -180,8 +180,7 @@ public class ConvertTraceFile extends Tool {
if
(
timeTotal
==
0
)
{
timeTotal
=
1
;
}
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Stat
stat
=
list
.
get
(
i
);
for
(
Stat
stat
:
list
)
{
StringBuffer
buff
=
new
StringBuffer
(
100
);
buff
.
append
(
"-- "
);
buff
.
append
(
padNumberLeft
(
100
*
stat
.
time
/
timeTotal
,
3
));
...
...
h2/src/main/org/h2/util/New.java
浏览文件 @
7d2c7659
...
...
@@ -64,6 +64,7 @@ public class New {
* Create a new HashSet.
*
* @param <T> the type
* @param c the collection
* @return the object
*/
public
static
<
T
>
HashSet
<
T
>
hashSet
(
Collection
<
T
>
c
)
{
...
...
h2/src/main/org/h2/util/ObjectArray.java
浏览文件 @
7d2c7659
...
...
@@ -18,7 +18,7 @@ import org.h2.constant.SysProperties;
*
* @param <T> the element type
*/
public
class
ObjectArray
<
T
>
{
public
class
ObjectArray
<
T
>
implements
Iterable
<
T
>
{
private
static
final
int
CAPACITY_INIT
=
4
,
CAPACITY_SHRINK
=
256
;
private
T
[]
data
;
...
...
@@ -41,6 +41,7 @@ public class ObjectArray<T> {
* Create a new object with the given initial capacity.
*
* @param capacity the initial capacity
* @return the object
*/
public
static
<
T
>
ObjectArray
<
T
>
newInstance
(
int
capacity
)
{
return
new
ObjectArray
<
T
>(
CAPACITY_INIT
);
...
...
@@ -48,6 +49,8 @@ public class ObjectArray<T> {
/**
* Create a new object with the default initial capacity.
*
* @return the object
*/
public
static
<
T
>
ObjectArray
<
T
>
newInstance
()
{
return
new
ObjectArray
<
T
>(
CAPACITY_INIT
);
...
...
@@ -57,6 +60,7 @@ public class ObjectArray<T> {
* Create a new object with all elements of the given collection.
*
* @param collection the collection with all elements
* @return the object
*/
public
static
<
T
>
ObjectArray
<
T
>
newInstance
(
Collection
<
T
>
collection
)
{
return
new
ObjectArray
<
T
>(
collection
);
...
...
@@ -316,6 +320,29 @@ public class ObjectArray<T> {
}
}
/**
* The iterator for this list.
*/
private
class
ObjectArrayIterator
implements
Iterator
<
T
>
{
private
int
index
;
public
boolean
hasNext
()
{
return
index
<
size
;
}
public
T
next
()
{
return
get
(
index
++);
}
public
void
remove
()
{
throw
new
UnsupportedOperationException
();
}
}
public
Iterator
<
T
>
iterator
()
{
return
new
ObjectArrayIterator
();
}
// public void sortInsertion(Comparator comp) {
// for (int i = 1, j; i < size(); i++) {
// Object t = get(i);
...
...
h2/src/main/org/h2/util/SmallLRUCache.java
浏览文件 @
7d2c7659
...
...
@@ -37,6 +37,14 @@ extends HashMap
this
.
size
=
size
;
}
/**
* Create a new object with all elements of the given collection.
*
* @param <K> the key type
* @param <V> the value type
* @param size the number of elements
* @return the object
*/
public
static
<
K
,
V
>
SmallLRUCache
<
K
,
V
>
newInstance
(
int
size
)
{
return
new
SmallLRUCache
<
K
,
V
>(
size
);
}
...
...
h2/src/main/org/h2/util/ValueHashMap.java
浏览文件 @
7d2c7659
...
...
@@ -39,6 +39,7 @@ public class ValueHashMap<V> extends HashBase {
* The data handler is used to compare values.
*
* @param handler the data handler
* @return the object
*/
public
static
<
T
>
ValueHashMap
<
T
>
newInstance
(
DataHandler
handler
)
{
return
new
ValueHashMap
<
T
>(
handler
);
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
7d2c7659
...
...
@@ -464,7 +464,7 @@ kill -9 `jps -l | grep "org.h2.test.TestAll" | cut -d " " -f 1`
beforeTest
();
// db
new
TestScriptSimple
().
runTest
(
this
);
//
new TestScriptSimple().runTest(this);
new
TestScript
().
runTest
(
this
);
new
TestAlter
().
runTest
(
this
);
new
TestAutoRecompile
().
runTest
(
this
);
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
7d2c7659
...
...
@@ -589,4 +589,4 @@ 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
\ No newline at end of file
longnvarchar collate localdb nan bootclasspath bcp retrotranslator iterable
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论