Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
16a375cc
提交
16a375cc
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use generics
上级
9554aade
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
99 个修改的文件
包含
766 行增加
和
741 行删除
+766
-741
Command.java
h2/src/main/org/h2/command/Command.java
+2
-1
CommandContainer.java
h2/src/main/org/h2/command/CommandContainer.java
+6
-5
CommandInterface.java
h2/src/main/org/h2/command/CommandInterface.java
+2
-1
CommandList.java
h2/src/main/org/h2/command/CommandList.java
+2
-1
CommandRemote.java
h2/src/main/org/h2/command/CommandRemote.java
+11
-11
Parser.java
h2/src/main/org/h2/command/Parser.java
+43
-41
Prepared.java
h2/src/main/org/h2/command/Prepared.java
+5
-5
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+6
-6
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+13
-13
AlterTableRenameColumn.java
h2/src/main/org/h2/command/ddl/AlterTableRenameColumn.java
+2
-2
Analyze.java
h2/src/main/org/h2/command/ddl/Analyze.java
+2
-4
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+10
-10
DropDatabase.java
h2/src/main/org/h2/command/ddl/DropDatabase.java
+26
-25
DropIndex.java
h2/src/main/org/h2/command/ddl/DropIndex.java
+2
-2
GrantRevoke.java
h2/src/main/org/h2/command/ddl/GrantRevoke.java
+5
-5
BackupCommand.java
h2/src/main/org/h2/command/dml/BackupCommand.java
+2
-2
Call.java
h2/src/main/org/h2/command/dml/Call.java
+2
-2
ExecuteProcedure.java
h2/src/main/org/h2/command/dml/ExecuteProcedure.java
+4
-4
Insert.java
h2/src/main/org/h2/command/dml/Insert.java
+5
-5
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+8
-8
Query.java
h2/src/main/org/h2/command/dml/Query.java
+10
-10
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+31
-30
Select.java
h2/src/main/org/h2/command/dml/Select.java
+55
-55
SelectListColumnResolver.java
h2/src/main/org/h2/command/dml/SelectListColumnResolver.java
+2
-2
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+12
-12
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+6
-6
Database.java
h2/src/main/org/h2/engine/Database.java
+48
-35
DbObject.java
h2/src/main/org/h2/engine/DbObject.java
+1
-1
DbObjectBase.java
h2/src/main/org/h2/engine/DbObjectBase.java
+1
-1
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+2
-2
MetaRecord.java
h2/src/main/org/h2/engine/MetaRecord.java
+1
-1
Role.java
h2/src/main/org/h2/engine/Role.java
+6
-6
Session.java
h2/src/main/org/h2/engine/Session.java
+8
-8
SessionRemote.java
h2/src/main/org/h2/engine/SessionRemote.java
+6
-6
SessionWithState.java
h2/src/main/org/h2/engine/SessionWithState.java
+2
-2
User.java
h2/src/main/org/h2/engine/User.java
+12
-12
Aggregate.java
h2/src/main/org/h2/expression/Aggregate.java
+15
-15
AggregateData.java
h2/src/main/org/h2/expression/AggregateData.java
+4
-5
ConditionIn.java
h2/src/main/org/h2/expression/ConditionIn.java
+14
-14
Function.java
h2/src/main/org/h2/expression/Function.java
+1
-1
Subquery.java
h2/src/main/org/h2/expression/Subquery.java
+1
-1
TableFunction.java
h2/src/main/org/h2/expression/TableFunction.java
+1
-1
BtreeIndex.java
h2/src/main/org/h2/index/BtreeIndex.java
+4
-3
BtreeLeaf.java
h2/src/main/org/h2/index/BtreeLeaf.java
+13
-13
BtreeNode.java
h2/src/main/org/h2/index/BtreeNode.java
+5
-4
BtreePage.java
h2/src/main/org/h2/index/BtreePage.java
+2
-2
MetaCursor.java
h2/src/main/org/h2/index/MetaCursor.java
+3
-3
MetaIndex.java
h2/src/main/org/h2/index/MetaIndex.java
+1
-1
MultiVersionIndex.java
h2/src/main/org/h2/index/MultiVersionIndex.java
+2
-1
PageBtreeLeaf.java
h2/src/main/org/h2/index/PageBtreeLeaf.java
+5
-5
PageBtreeNode.java
h2/src/main/org/h2/index/PageBtreeNode.java
+2
-2
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+4
-8
PageDataLeafOverflow.java
h2/src/main/org/h2/index/PageDataLeafOverflow.java
+3
-4
PageDataNode.java
h2/src/main/org/h2/index/PageDataNode.java
+2
-2
PageScanCursor.java
h2/src/main/org/h2/index/PageScanCursor.java
+3
-3
PageScanIndex.java
h2/src/main/org/h2/index/PageScanIndex.java
+2
-2
ScanIndex.java
h2/src/main/org/h2/index/ScanIndex.java
+4
-4
ViewIndex.java
h2/src/main/org/h2/index/ViewIndex.java
+7
-7
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+3
-4
JdbcParameterMetaData.java
h2/src/main/org/h2/jdbc/JdbcParameterMetaData.java
+2
-2
JdbcPreparedStatement.java
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
+14
-14
JdbcStatement.java
h2/src/main/org/h2/jdbc/JdbcStatement.java
+2
-2
LogFile.java
h2/src/main/org/h2/log/LogFile.java
+2
-2
LogSystem.java
h2/src/main/org/h2/log/LogSystem.java
+13
-13
UndoLog.java
h2/src/main/org/h2/log/UndoLog.java
+4
-4
UndoLogRecord.java
h2/src/main/org/h2/log/UndoLogRecord.java
+2
-2
TraceObject.java
h2/src/main/org/h2/message/TraceObject.java
+2
-2
LocalResult.java
h2/src/main/org/h2/result/LocalResult.java
+7
-7
ResultDiskBuffer.java
h2/src/main/org/h2/result/ResultDiskBuffer.java
+9
-9
ResultExternal.java
h2/src/main/org/h2/result/ResultExternal.java
+1
-1
ResultRemote.java
h2/src/main/org/h2/result/ResultRemote.java
+4
-4
ResultTempTable.java
h2/src/main/org/h2/result/ResultTempTable.java
+4
-4
RowList.java
h2/src/main/org/h2/result/RowList.java
+5
-5
SortOrder.java
h2/src/main/org/h2/result/SortOrder.java
+12
-12
UpdatableRow.java
h2/src/main/org/h2/result/UpdatableRow.java
+3
-3
Schema.java
h2/src/main/org/h2/schema/Schema.java
+12
-2
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+4
-3
WebThread.java
h2/src/main/org/h2/server/web/WebThread.java
+2
-2
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+13
-13
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+20
-24
FileSystemMemory.java
h2/src/main/org/h2/store/fs/FileSystemMemory.java
+1
-1
FunctionTable.java
h2/src/main/org/h2/table/FunctionTable.java
+1
-1
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+54
-53
Plan.java
h2/src/main/org/h2/table/Plan.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
+37
-37
TableData.java
h2/src/main/org/h2/table/TableData.java
+24
-23
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+7
-7
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+6
-6
TableView.java
h2/src/main/org/h2/table/TableView.java
+10
-9
Recover.java
h2/src/main/org/h2/tools/Recover.java
+2
-2
Cache.java
h2/src/main/org/h2/util/Cache.java
+1
-1
CacheLRU.java
h2/src/main/org/h2/util/CacheLRU.java
+4
-4
CacheObject.java
h2/src/main/org/h2/util/CacheObject.java
+1
-1
CacheSecondLevel.java
h2/src/main/org/h2/util/CacheSecondLevel.java
+1
-1
CacheTQ.java
h2/src/main/org/h2/util/CacheTQ.java
+4
-4
ObjectArray.java
h2/src/main/org/h2/util/ObjectArray.java
+1
-1
ValueHashMap.java
h2/src/main/org/h2/util/ValueHashMap.java
+4
-4
TestValueHashMap.java
h2/src/test/org/h2/test/unit/TestValueHashMap.java
+6
-6
没有找到文件。
h2/src/main/org/h2/command/Command.java
浏览文件 @
16a375cc
...
...
@@ -12,6 +12,7 @@ import org.h2.constant.ErrorCode;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
import
org.h2.message.TraceObject
;
...
...
@@ -73,7 +74,7 @@ public abstract class Command implements CommandInterface {
*
* @return the list of parameters
*/
public
abstract
ObjectArray
getParameters
();
public
abstract
ObjectArray
<
?
extends
ParameterInterface
>
getParameters
();
/**
* Check if this command is read only.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/CommandContainer.java
浏览文件 @
16a375cc
...
...
@@ -9,6 +9,7 @@ package org.h2.command;
import
java.sql.SQLException
;
import
org.h2.expression.Parameter
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.result.LocalResult
;
import
org.h2.util.ObjectArray
;
import
org.h2.value.Value
;
...
...
@@ -27,7 +28,7 @@ public class CommandContainer extends Command {
this
.
prepared
=
prepared
;
}
public
ObjectArray
getParameters
()
{
public
ObjectArray
<
?
extends
ParameterInterface
>
getParameters
()
{
return
prepared
.
getParameters
();
}
...
...
@@ -44,17 +45,17 @@ public class CommandContainer extends Command {
// TODO test with 'always recompile'
prepared
.
setModificationMetaId
(
0
);
String
sql
=
prepared
.
getSQL
();
ObjectArray
oldParams
=
prepared
.
getParameters
();
ObjectArray
<
Parameter
>
oldParams
=
prepared
.
getParameters
();
Parser
parser
=
new
Parser
(
session
);
prepared
=
parser
.
parseOnly
(
sql
);
long
mod
=
prepared
.
getModificationMetaId
();
prepared
.
setModificationMetaId
(
0
);
ObjectArray
newParams
=
prepared
.
getParameters
();
ObjectArray
<
Parameter
>
newParams
=
prepared
.
getParameters
();
for
(
int
i
=
0
;
i
<
newParams
.
size
();
i
++)
{
Parameter
old
=
(
Parameter
)
oldParams
.
get
(
i
);
Parameter
old
=
oldParams
.
get
(
i
);
if
(
old
.
isValueSet
())
{
Value
v
=
old
.
getValue
(
session
);
Parameter
p
=
(
Parameter
)
newParams
.
get
(
i
);
Parameter
p
=
newParams
.
get
(
i
);
p
.
setValue
(
v
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/CommandInterface.java
浏览文件 @
16a375cc
...
...
@@ -8,6 +8,7 @@ package org.h2.command;
import
java.sql.SQLException
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.result.ResultInterface
;
import
org.h2.util.ObjectArray
;
...
...
@@ -28,7 +29,7 @@ public interface CommandInterface {
*
* @return the parameters
*/
ObjectArray
getParameters
();
ObjectArray
<
?
extends
ParameterInterface
>
getParameters
();
/**
* Execute the query.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/CommandList.java
浏览文件 @
16a375cc
...
...
@@ -8,6 +8,7 @@ package org.h2.command;
import
java.sql.SQLException
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.result.LocalResult
;
import
org.h2.util.ObjectArray
;
...
...
@@ -27,7 +28,7 @@ public class CommandList extends Command {
this
.
remaining
=
remaining
;
}
public
ObjectArray
getParameters
()
{
public
ObjectArray
<
?
extends
ParameterInterface
>
getParameters
()
{
return
command
.
getParameters
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/CommandRemote.java
浏览文件 @
16a375cc
...
...
@@ -28,7 +28,7 @@ import org.h2.value.Value;
*/
public
class
CommandRemote
implements
CommandInterface
{
private
final
ObjectArray
transferList
;
private
final
ObjectArray
<
Transfer
>
transferList
;
private
final
ObjectArray
<
ParameterInterface
>
parameters
;
private
final
Trace
trace
;
private
final
String
sql
;
...
...
@@ -40,7 +40,7 @@ public class CommandRemote implements CommandInterface {
private
int
paramCount
;
private
int
created
;
public
CommandRemote
(
SessionRemote
session
,
ObjectArray
transferList
,
String
sql
,
int
fetchSize
)
throws
SQLException
{
public
CommandRemote
(
SessionRemote
session
,
ObjectArray
<
Transfer
>
transferList
,
String
sql
,
int
fetchSize
)
throws
SQLException
{
this
.
transferList
=
transferList
;
trace
=
session
.
getTrace
();
this
.
sql
=
sql
;
...
...
@@ -59,7 +59,7 @@ public class CommandRemote implements CommandInterface {
boolean
readParams
=
s
.
getClientVersion
()
>=
Constants
.
TCP_PROTOCOL_VERSION_6
;
for
(
int
i
=
0
,
count
=
0
;
i
<
transferList
.
size
();
i
++)
{
try
{
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
Transfer
transfer
=
transferList
.
get
(
i
);
if
(
readParams
&&
createParams
)
{
s
.
traceOperation
(
"SESSION_PREPARE_READ_PARAMS"
,
id
);
transfer
.
writeInt
(
SessionRemote
.
SESSION_PREPARE_READ_PARAMS
).
writeInt
(
id
).
writeString
(
sql
);
...
...
@@ -93,7 +93,7 @@ public class CommandRemote implements CommandInterface {
return
isQuery
;
}
public
ObjectArray
getParameters
()
{
public
ObjectArray
<
ParameterInterface
>
getParameters
()
{
return
parameters
;
}
...
...
@@ -118,7 +118,7 @@ public class CommandRemote implements CommandInterface {
ResultRemote
result
=
null
;
for
(
int
i
=
0
,
count
=
0
;
i
<
transferList
.
size
();
i
++)
{
prepareIfRequired
();
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
Transfer
transfer
=
transferList
.
get
(
i
);
try
{
// TODO cluster: support load balance with values for each server / auto detect
session
.
traceOperation
(
"COMMAND_GET_META_DATA"
,
id
);
...
...
@@ -143,7 +143,7 @@ public class CommandRemote implements CommandInterface {
ResultRemote
result
=
null
;
for
(
int
i
=
0
,
count
=
0
;
i
<
transferList
.
size
();
i
++)
{
prepareIfRequired
();
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
Transfer
transfer
=
transferList
.
get
(
i
);
try
{
// TODO cluster: support load balance with values for each
// server / auto detect
...
...
@@ -185,7 +185,7 @@ public class CommandRemote implements CommandInterface {
boolean
autoCommit
=
false
;
for
(
int
i
=
0
,
count
=
0
;
i
<
transferList
.
size
();
i
++)
{
prepareIfRequired
();
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
Transfer
transfer
=
transferList
.
get
(
i
);
try
{
session
.
traceOperation
(
"COMMAND_EXECUTE_UPDATE"
,
id
);
transfer
.
writeInt
(
SessionRemote
.
COMMAND_EXECUTE_UPDATE
).
writeInt
(
id
);
...
...
@@ -207,7 +207,7 @@ public class CommandRemote implements CommandInterface {
private
void
checkParameters
()
throws
SQLException
{
int
len
=
parameters
.
size
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ParameterInterface
p
=
(
ParameterInterface
)
parameters
.
get
(
i
);
ParameterInterface
p
=
parameters
.
get
(
i
);
p
.
checkSet
();
}
}
...
...
@@ -216,7 +216,7 @@ public class CommandRemote implements CommandInterface {
int
len
=
parameters
.
size
();
transfer
.
writeInt
(
len
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ParameterInterface
p
=
(
ParameterInterface
)
parameters
.
get
(
i
);
ParameterInterface
p
=
parameters
.
get
(
i
);
transfer
.
writeValue
(
p
.
getParamValue
());
}
}
...
...
@@ -228,7 +228,7 @@ public class CommandRemote implements CommandInterface {
synchronized
(
session
)
{
for
(
int
i
=
0
;
i
<
transferList
.
size
();
i
++)
{
try
{
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
Transfer
transfer
=
transferList
.
get
(
i
);
session
.
traceOperation
(
"COMMAND_CLOSE"
,
id
);
transfer
.
writeInt
(
SessionRemote
.
COMMAND_CLOSE
).
writeInt
(
id
);
}
catch
(
IOException
e
)
{
...
...
@@ -240,7 +240,7 @@ public class CommandRemote implements CommandInterface {
int
len
=
parameters
.
size
();
try
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ParameterInterface
p
=
(
ParameterInterface
)
parameters
.
get
(
i
);
ParameterInterface
p
=
parameters
.
get
(
i
);
Value
v
=
p
.
getParamValue
();
if
(
v
!=
null
)
{
v
.
close
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/Parser.java
浏览文件 @
16a375cc
差异被折叠。
点击展开。
h2/src/main/org/h2/command/Prepared.java
浏览文件 @
16a375cc
...
...
@@ -44,7 +44,7 @@ public abstract class Prepared {
/**
* The list of parameters.
*/
protected
ObjectArray
parameters
;
protected
ObjectArray
<
Parameter
>
parameters
;
/**
* If the query should be prepared before each execution. This is set for
...
...
@@ -131,7 +131,7 @@ public abstract class Prepared {
*
* @param parameters the parameter list
*/
public
void
setParameterList
(
ObjectArray
parameters
)
{
public
void
setParameterList
(
ObjectArray
<
Parameter
>
parameters
)
{
this
.
parameters
=
parameters
;
}
...
...
@@ -140,7 +140,7 @@ public abstract class Prepared {
*
* @return the parameter list
*/
public
ObjectArray
getParameters
()
{
public
ObjectArray
<
Parameter
>
getParameters
()
{
return
parameters
;
}
...
...
@@ -151,7 +151,7 @@ public abstract class Prepared {
*/
protected
void
checkParameters
()
throws
SQLException
{
for
(
int
i
=
0
;
parameters
!=
null
&&
i
<
parameters
.
size
();
i
++)
{
Parameter
param
=
(
Parameter
)
parameters
.
get
(
i
);
Parameter
param
=
parameters
.
get
(
i
);
param
.
checkSet
();
}
}
...
...
@@ -320,7 +320,7 @@ public abstract class Prepared {
}
buff
.
append
(
i
+
1
);
buff
.
append
(
": "
);
Expression
e
=
(
Expression
)
parameters
.
get
(
i
);
Expression
e
=
parameters
.
get
(
i
);
Value
v
=
e
.
getValue
(
session
);
buff
.
append
(
v
.
getTraceSQL
());
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
16a375cc
...
...
@@ -114,9 +114,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
case
PRIMARY_KEY:
{
IndexColumn
.
mapColumns
(
indexColumns
,
table
);
index
=
table
.
findPrimaryKey
();
ObjectArray
constraints
=
table
.
getConstraints
();
ObjectArray
<
Constraint
>
constraints
=
table
.
getConstraints
();
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
c
=
(
Constraint
)
constraints
.
get
(
i
);
Constraint
c
=
constraints
.
get
(
i
);
if
(
Constraint
.
PRIMARY_KEY
.
equals
(
c
.
getConstraintType
()))
{
throw
Message
.
getSQLException
(
ErrorCode
.
SECOND_PRIMARY_KEY
);
}
...
...
@@ -287,9 +287,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
private
Index
getUniqueIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
ObjectArray
list
=
t
.
getIndexes
();
ObjectArray
<
Index
>
list
=
t
.
getIndexes
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Index
idx
=
(
Index
)
list
.
get
(
i
);
Index
idx
=
list
.
get
(
i
);
if
(
canUseUniqueIndex
(
idx
,
t
,
cols
))
{
return
idx
;
}
...
...
@@ -298,9 +298,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
private
Index
getIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
ObjectArray
list
=
t
.
getIndexes
();
ObjectArray
<
Index
>
list
=
t
.
getIndexes
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Index
existingIndex
=
(
Index
)
list
.
get
(
i
);
Index
existingIndex
=
list
.
get
(
i
);
if
(
canUseIndex
(
existingIndex
,
t
,
cols
))
{
return
existingIndex
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
16a375cc
...
...
@@ -199,9 +199,9 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
private
void
checkNoViews
()
throws
SQLException
{
ObjectArray
children
=
table
.
getChildren
();
ObjectArray
<
DbObject
>
children
=
table
.
getChildren
();
for
(
int
i
=
0
;
i
<
children
.
size
();
i
++)
{
DbObject
child
=
(
DbObject
)
children
.
get
(
i
);
DbObject
child
=
children
.
get
(
i
);
if
(
child
.
getType
()
==
DbObject
.
TABLE_OR_VIEW
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
OPERATION_NOT_SUPPORTED_WITH_VIEWS_2
,
new
String
[]
{
table
.
getName
(),
child
.
getName
()
});
...
...
@@ -213,7 +213,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
Database
db
=
session
.
getDatabase
();
String
tempName
=
db
.
getTempTableName
(
session
.
getId
());
Column
[]
columns
=
table
.
getColumns
();
ObjectArray
newColumns
=
ObjectArray
.
newInstance
();
ObjectArray
<
Column
>
newColumns
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
col
=
columns
[
i
].
getClone
();
newColumns
.
add
(
col
);
...
...
@@ -246,7 +246,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
buff
.
append
(
newTable
.
getCreateSQL
());
StringBuffer
columnList
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
newColumns
.
size
();
i
++)
{
Column
nc
=
(
Column
)
newColumns
.
get
(
i
);
Column
nc
=
newColumns
.
get
(
i
);
if
(
columnList
.
length
()
>
0
)
{
columnList
.
append
(
", "
);
}
...
...
@@ -269,10 +269,10 @@ public class AlterTableAlterColumn extends SchemaCommand {
String
newTableSQL
=
buff
.
toString
();
execute
(
newTableSQL
,
true
);
newTable
=
(
TableData
)
newTable
.
getSchema
().
getTableOrView
(
session
,
newTable
.
getName
());
ObjectArray
children
=
table
.
getChildren
();
ObjectArray
triggers
=
ObjectArray
.
newInstance
();
ObjectArray
<
DbObject
>
children
=
table
.
getChildren
();
ObjectArray
<
String
>
triggers
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
children
.
size
();
i
++)
{
DbObject
child
=
(
DbObject
)
children
.
get
(
i
);
DbObject
child
=
children
.
get
(
i
);
if
(
child
instanceof
Sequence
)
{
continue
;
}
else
if
(
child
instanceof
Index
)
{
...
...
@@ -319,14 +319,14 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
}
for
(
int
i
=
0
;
i
<
triggers
.
size
();
i
++)
{
String
sql
=
(
String
)
triggers
.
get
(
i
);
String
sql
=
triggers
.
get
(
i
);
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
=
(
DbObject
)
children
.
get
(
i
);
DbObject
child
=
children
.
get
(
i
);
if
(
child
instanceof
Sequence
)
{
continue
;
}
...
...
@@ -352,9 +352,9 @@ public class AlterTableAlterColumn extends SchemaCommand {
private
void
dropSingleColumnIndexes
()
throws
SQLException
{
Database
db
=
session
.
getDatabase
();
ObjectArray
indexes
=
table
.
getIndexes
();
ObjectArray
<
Index
>
indexes
=
table
.
getIndexes
();
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
index
=
(
Index
)
indexes
.
get
(
i
);
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
getCreateSQL
()
==
null
)
{
continue
;
}
...
...
@@ -378,9 +378,9 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
private
void
checkNullable
()
throws
SQLException
{
ObjectArray
indexes
=
table
.
getIndexes
();
ObjectArray
<
Index
>
indexes
=
table
.
getIndexes
();
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
index
=
(
Index
)
indexes
.
get
(
i
);
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
getColumnIndex
(
oldColumn
)
<
0
)
{
continue
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterTableRenameColumn.java
浏览文件 @
16a375cc
...
...
@@ -49,9 +49,9 @@ public class AlterTableRenameColumn extends DefineCommand {
table
.
renameColumn
(
column
,
newName
);
table
.
setModified
();
db
.
update
(
session
,
table
);
ObjectArray
children
=
table
.
getChildren
();
ObjectArray
<
DbObject
>
children
=
table
.
getChildren
();
for
(
int
i
=
0
;
i
<
children
.
size
();
i
++)
{
DbObject
child
=
(
DbObject
)
children
.
get
(
i
);
DbObject
child
=
children
.
get
(
i
);
if
(
child
.
getCreateSQL
()
!=
null
)
{
db
.
update
(
session
,
child
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/Analyze.java
浏览文件 @
16a375cc
...
...
@@ -7,11 +7,9 @@
package
org
.
h2
.
command
.
ddl
;
import
java.sql.SQLException
;
import
org.h2.command.Prepared
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.Session
;
import
org.h2.result.LocalResult
;
import
org.h2.table.Column
;
...
...
@@ -35,10 +33,10 @@ public class Analyze extends DefineCommand {
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
session
.
getUser
().
checkAdmin
();
ObjectArray
tables
=
db
.
getAllSchemaObjects
(
DbObject
.
TABLE_OR_VIEW
);
ObjectArray
<
Table
>
tables
=
db
.
getAllTablesAndViews
(
);
// TODO do we need to lock the table?
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
(
Table
)
tables
.
get
(
i
);
Table
table
=
tables
.
get
(
i
);
if
(!(
table
instanceof
TableData
))
{
continue
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
16a375cc
...
...
@@ -31,8 +31,8 @@ import org.h2.value.DataType;
public
class
CreateTable
extends
SchemaCommand
{
private
String
tableName
;
private
ObjectArray
constraintCommands
=
ObjectArray
.
newInstance
();
private
ObjectArray
columns
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
Prepared
>
constraintCommands
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
Column
>
columns
=
ObjectArray
.
newInstance
();
private
IndexColumn
[]
pkColumns
;
private
boolean
ifNotExists
;
private
boolean
persistIndexes
=
true
;
...
...
@@ -123,7 +123,7 @@ public class CreateTable extends SchemaCommand {
if
(
pkColumns
!=
null
)
{
int
len
=
pkColumns
.
length
;
for
(
int
i
=
0
;
i
<
columns
.
size
();
i
++)
{
Column
c
=
(
Column
)
columns
.
get
(
i
);
Column
c
=
columns
.
get
(
i
);
for
(
int
j
=
0
;
j
<
len
;
j
++)
{
if
(
c
.
getName
().
equals
(
pkColumns
[
j
].
columnName
))
{
c
.
setNullable
(
false
);
...
...
@@ -131,9 +131,9 @@ public class CreateTable extends SchemaCommand {
}
}
}
ObjectArray
sequences
=
ObjectArray
.
newInstance
();
ObjectArray
<
Sequence
>
sequences
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
columns
.
size
();
i
++)
{
Column
c
=
(
Column
)
columns
.
get
(
i
);
Column
c
=
columns
.
get
(
i
);
if
(
c
.
getAutoIncrement
())
{
int
objId
=
getObjectId
(
true
,
true
);
c
.
convertAutoIncrementToSequence
(
session
,
getSchema
(),
objId
,
temporary
);
...
...
@@ -161,15 +161,15 @@ public class CreateTable extends SchemaCommand {
}
try
{
for
(
int
i
=
0
;
i
<
columns
.
size
();
i
++)
{
Column
c
=
(
Column
)
columns
.
get
(
i
);
Column
c
=
columns
.
get
(
i
);
c
.
prepareExpression
(
session
);
}
for
(
int
i
=
0
;
i
<
sequences
.
size
();
i
++)
{
Sequence
sequence
=
(
Sequence
)
sequences
.
get
(
i
);
Sequence
sequence
=
sequences
.
get
(
i
);
table
.
addSequence
(
sequence
);
}
for
(
int
i
=
0
;
i
<
constraintCommands
.
size
();
i
++)
{
Prepared
command
=
(
Prepared
)
constraintCommands
.
get
(
i
);
Prepared
command
=
constraintCommands
.
get
(
i
);
command
.
update
();
}
if
(
asQuery
!=
null
)
{
...
...
@@ -196,9 +196,9 @@ public class CreateTable extends SchemaCommand {
private
void
generateColumnsFromQuery
()
{
int
columnCount
=
asQuery
.
getColumnCount
();
ObjectArray
expressions
=
asQuery
.
getExpressions
();
ObjectArray
<
Expression
>
expressions
=
asQuery
.
getExpressions
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Expression
expr
=
(
Expression
)
expressions
.
get
(
i
);
Expression
expr
=
expressions
.
get
(
i
);
int
type
=
expr
.
getType
();
String
name
=
expr
.
getAlias
();
long
precision
=
expr
.
getPrecision
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/DropDatabase.java
浏览文件 @
16a375cc
...
...
@@ -44,67 +44,68 @@ public class DropDatabase extends DefineCommand {
session
.
getUser
().
checkAdmin
();
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
ObjectArray
list
;
// TODO local temp tables are not removed
list
=
db
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Schema
schema
=
(
Schema
)
list
.
get
(
i
);
ObjectArray
<
Schema
>
schemas
=
db
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
schemas
.
size
();
i
++)
{
Schema
schema
=
schemas
.
get
(
i
);
if
(
schema
.
canDrop
())
{
db
.
removeDatabaseObject
(
session
,
schema
);
}
}
list
=
db
.
getAllSchemaObjects
(
DbObject
.
TABLE_OR_VIEW
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Table
t
=
(
Table
)
list
.
get
(
i
);
ObjectArray
<
Table
>
tables
=
db
.
getAllTablesAndViews
(
);
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
tables
.
get
(
i
);
if
(
t
.
getName
()
!=
null
&&
Table
.
VIEW
.
equals
(
t
.
getTableType
()))
{
db
.
removeSchemaObject
(
session
,
t
);
}
}
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Table
t
=
(
Table
)
list
.
get
(
i
);
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
tables
.
get
(
i
);
if
(
t
.
getName
()
!=
null
&&
Table
.
TABLE_LINK
.
equals
(
t
.
getTableType
()))
{
db
.
removeSchemaObject
(
session
,
t
);
}
}
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Table
t
=
(
Table
)
list
.
get
(
i
);
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
tables
.
get
(
i
);
if
(
t
.
getName
()
!=
null
&&
Table
.
TABLE
.
equals
(
t
.
getTableType
()))
{
db
.
removeSchemaObject
(
session
,
t
);
}
}
session
.
findLocalTempTable
(
null
);
list
=
db
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
);
ObjectArray
<
SchemaObject
>
list
=
ObjectArray
.
newInstance
();
list
.
addAll
(
db
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
));
// maybe constraints and triggers on system tables will be allowed in
// the future
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
=
(
SchemaObject
)
list
.
get
(
i
);
SchemaObject
obj
=
list
.
get
(
i
);
db
.
removeSchemaObject
(
session
,
obj
);
}
list
=
db
.
getAllUsers
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
User
user
=
(
User
)
list
.
get
(
i
);
ObjectArray
<
User
>
users
=
db
.
getAllUsers
();
for
(
int
i
=
0
;
i
<
users
.
size
();
i
++)
{
User
user
=
users
.
get
(
i
);
if
(
user
!=
session
.
getUser
())
{
db
.
removeDatabaseObject
(
session
,
user
);
}
}
list
=
db
.
getAllRoles
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Role
role
=
(
Role
)
list
.
get
(
i
);
ObjectArray
<
Role
>
roles
=
db
.
getAllRoles
();
for
(
int
i
=
0
;
i
<
roles
.
size
();
i
++)
{
Role
role
=
roles
.
get
(
i
);
String
sql
=
role
.
getCreateSQL
();
// the role PUBLIC must not be dropped
if
(
sql
!=
null
)
{
db
.
removeDatabaseObject
(
session
,
role
);
}
}
list
=
db
.
getAllRights
();
list
.
addAll
(
db
.
getAllFunctionAliases
());
list
.
addAll
(
db
.
getAllAggregates
());
list
.
addAll
(
db
.
getAllUserDataTypes
());
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
DbObject
obj
=
(
DbObject
)
list
.
get
(
i
);
ObjectArray
<
DbObject
>
dbObjects
=
ObjectArray
.
newInstance
();
dbObjects
.
addAll
(
db
.
getAllRights
());
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
);
String
sql
=
obj
.
getCreateSQL
();
// the role PUBLIC must not be dropped
if
(
sql
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/DropIndex.java
浏览文件 @
16a375cc
...
...
@@ -51,9 +51,9 @@ public class DropIndex extends SchemaCommand {
Table
table
=
index
.
getTable
();
session
.
getUser
().
checkRight
(
index
.
getTable
(),
Right
.
ALL
);
Constraint
pkConstraint
=
null
;
ObjectArray
constraints
=
table
.
getConstraints
();
ObjectArray
<
Constraint
>
constraints
=
table
.
getConstraints
();
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
cons
=
(
Constraint
)
constraints
.
get
(
i
);
Constraint
cons
=
constraints
.
get
(
i
);
if
(
cons
.
usesIndex
(
index
))
{
// can drop primary key index (for compatibility)
if
(
Constraint
.
PRIMARY_KEY
.
equals
(
cons
.
getConstraintType
()))
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/GrantRevoke.java
浏览文件 @
16a375cc
...
...
@@ -37,10 +37,10 @@ public class GrantRevoke extends DefineCommand {
*/
public
static
final
int
REVOKE
=
1
;
private
ObjectArray
roleNames
;
private
ObjectArray
<
String
>
roleNames
;
private
int
operationType
;
private
int
rightMask
;
private
ObjectArray
tables
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
Table
>
tables
=
ObjectArray
.
newInstance
();
private
RightOwner
grantee
;
public
GrantRevoke
(
Session
session
)
{
...
...
@@ -89,7 +89,7 @@ public class GrantRevoke extends DefineCommand {
Database
db
=
session
.
getDatabase
();
if
(
roleNames
!=
null
)
{
for
(
int
i
=
0
;
i
<
roleNames
.
size
();
i
++)
{
String
name
=
(
String
)
roleNames
.
get
(
i
);
String
name
=
roleNames
.
get
(
i
);
Role
grantedRole
=
db
.
findRole
(
name
);
if
(
grantedRole
==
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
ROLE_NOT_FOUND_1
,
name
);
...
...
@@ -117,7 +117,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
=
(
Table
)
tables
.
get
(
i
);
Table
table
=
tables
.
get
(
i
);
Right
right
=
grantee
.
getRightForTable
(
table
);
if
(
right
==
null
)
{
int
id
=
getObjectId
(
true
,
true
);
...
...
@@ -150,7 +150,7 @@ public class GrantRevoke extends DefineCommand {
private
void
revokeRight
()
throws
SQLException
{
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
(
Table
)
tables
.
get
(
i
);
Table
table
=
tables
.
get
(
i
);
Right
right
=
grantee
.
getRightForTable
(
table
);
if
(
right
==
null
)
{
continue
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/BackupCommand.java
浏览文件 @
16a375cc
...
...
@@ -85,10 +85,10 @@ public class BackupCommand extends Prepared {
String
base
=
FileUtils
.
getParent
(
fn
);
synchronized
(
db
.
getLobSyncObject
())
{
if
(!
SysProperties
.
PAGE_STORE
)
{
ObjectArray
list
=
log
.
getActiveLogFiles
();
ObjectArray
<
LogFile
>
list
=
log
.
getActiveLogFiles
();
int
max
=
list
.
size
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
LogFile
lf
=
(
LogFile
)
list
.
get
(
i
);
LogFile
lf
=
list
.
get
(
i
);
fn
=
lf
.
getFileName
();
backupFile
(
out
,
base
,
fn
);
db
.
setProgress
(
DatabaseEventListener
.
STATE_BACKUP_FILE
,
name
,
i
,
max
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Call.java
浏览文件 @
16a375cc
...
...
@@ -27,7 +27,7 @@ import org.h2.value.ValueResultSet;
*/
public
class
Call
extends
Prepared
{
private
Expression
value
;
private
ObjectArray
expressions
;
private
ObjectArray
<
Expression
>
expressions
;
public
Call
(
Session
session
)
{
super
(
session
);
...
...
@@ -64,7 +64,7 @@ public class Call extends Prepared {
return
LocalResult
.
read
(
session
,
rs
,
maxrows
);
}
else
if
(
v
.
getType
()
==
Value
.
ARRAY
)
{
Value
[]
list
=
((
ValueArray
)
v
).
getList
();
ObjectArray
expr
=
ObjectArray
.
newInstance
();
ObjectArray
<
Expression
>
expr
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
Value
e
=
list
[
i
];
Column
col
=
new
Column
(
"C"
+
(
i
+
1
),
e
.
getType
(),
e
.
getPrecision
(),
e
.
getScale
(),
e
.
getDisplaySize
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/ExecuteProcedure.java
浏览文件 @
16a375cc
...
...
@@ -22,7 +22,7 @@ import org.h2.util.ObjectArray;
*/
public
class
ExecuteProcedure
extends
Prepared
{
private
ObjectArray
expressions
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
Expression
>
expressions
=
ObjectArray
.
newInstance
();
private
Procedure
procedure
;
public
ExecuteProcedure
(
Session
session
)
{
...
...
@@ -45,10 +45,10 @@ public class ExecuteProcedure extends Prepared {
private
void
setParameters
()
throws
SQLException
{
Prepared
prepared
=
procedure
.
getPrepared
();
ObjectArray
params
=
prepared
.
getParameters
();
ObjectArray
<
Parameter
>
params
=
prepared
.
getParameters
();
for
(
int
i
=
0
;
params
!=
null
&&
i
<
params
.
size
()
&&
i
<
expressions
.
size
();
i
++)
{
Expression
expr
=
(
Expression
)
expressions
.
get
(
i
);
Parameter
p
=
(
Parameter
)
params
.
get
(
i
);
Expression
expr
=
expressions
.
get
(
i
);
Parameter
p
=
params
.
get
(
i
);
p
.
setValue
(
expr
.
getValue
(
session
));
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Insert.java
浏览文件 @
16a375cc
...
...
@@ -32,7 +32,7 @@ public class Insert extends Prepared {
private
Table
table
;
private
Column
[]
columns
;
private
ObjectArray
list
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
Expression
[]>
list
=
ObjectArray
.
newInstance
();
private
Query
query
;
public
Insert
(
Session
session
)
{
...
...
@@ -74,7 +74,7 @@ public class Insert extends Prepared {
if
(
list
.
size
()
>
0
)
{
count
=
0
;
for
(
int
x
=
0
;
x
<
list
.
size
();
x
++)
{
Expression
[]
expr
=
(
Expression
[])
list
.
get
(
x
);
Expression
[]
expr
=
list
.
get
(
x
);
Row
newRow
=
table
.
getTemplateRow
();
setCurrentRowNumber
(
x
+
1
);
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
...
...
@@ -151,7 +151,7 @@ public class Insert extends Prepared {
if
(
list
.
size
()
>
0
)
{
buff
.
append
(
"VALUES "
);
for
(
int
x
=
0
;
x
<
list
.
size
();
x
++)
{
Expression
[]
expr
=
(
Expression
[])
list
.
get
(
x
);
Expression
[]
expr
=
list
.
get
(
x
);
if
(
x
>
0
)
{
buff
.
append
(
", "
);
}
...
...
@@ -177,7 +177,7 @@ public class Insert extends Prepared {
public
void
prepare
()
throws
SQLException
{
if
(
columns
==
null
)
{
if
(
list
.
size
()
>
0
&&
((
Expression
[])
list
.
get
(
0
)
).
length
==
0
)
{
if
(
list
.
size
()
>
0
&&
list
.
get
(
0
).
length
==
0
)
{
// special case where table is used as a sequence
columns
=
new
Column
[
0
];
}
else
{
...
...
@@ -186,7 +186,7 @@ public class Insert extends Prepared {
}
if
(
list
.
size
()
>
0
)
{
for
(
int
x
=
0
;
x
<
list
.
size
();
x
++)
{
Expression
[]
expr
=
(
Expression
[])
list
.
get
(
x
);
Expression
[]
expr
=
list
.
get
(
x
);
if
(
expr
.
length
!=
columns
.
length
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
COLUMN_COUNT_DOES_NOT_MATCH
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
16a375cc
...
...
@@ -35,7 +35,7 @@ public class Merge extends Prepared {
private
Table
table
;
private
Column
[]
columns
;
private
Column
[]
keys
;
private
ObjectArray
list
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
Expression
[]>
list
=
ObjectArray
.
newInstance
();
private
Query
query
;
private
Prepared
update
;
...
...
@@ -112,7 +112,7 @@ public class Merge extends Prepared {
count
=
0
;
for
(
int
x
=
0
;
x
<
list
.
size
();
x
++)
{
setCurrentRowNumber
(
x
+
1
);
Expression
[]
expr
=
(
Expression
[])
list
.
get
(
x
);
Expression
[]
expr
=
list
.
get
(
x
);
Row
newRow
=
table
.
getTemplateRow
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
c
=
columns
[
i
];
...
...
@@ -161,11 +161,11 @@ public class Merge extends Prepared {
}
private
void
merge
(
Row
row
)
throws
SQLException
{
ObjectArray
k
=
update
.
getParameters
();
ObjectArray
<
Parameter
>
k
=
update
.
getParameters
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
col
=
columns
[
i
];
Value
v
=
row
.
getValue
(
col
.
getColumnId
());
Parameter
p
=
(
Parameter
)
k
.
get
(
i
);
Parameter
p
=
k
.
get
(
i
);
p
.
setValue
(
v
);
}
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
...
...
@@ -174,7 +174,7 @@ public class Merge extends Prepared {
if
(
v
==
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
COLUMN_CONTAINS_NULL_VALUES_1
,
col
.
getSQL
());
}
Parameter
p
=
(
Parameter
)
k
.
get
(
columns
.
length
+
i
);
Parameter
p
=
k
.
get
(
columns
.
length
+
i
);
p
.
setValue
(
v
);
}
int
count
=
update
.
update
();
...
...
@@ -218,7 +218,7 @@ public class Merge extends Prepared {
if
(
list
.
size
()
>
0
)
{
buff
.
append
(
"VALUES "
);
for
(
int
x
=
0
;
x
<
list
.
size
();
x
++)
{
Expression
[]
expr
=
(
Expression
[])
list
.
get
(
x
);
Expression
[]
expr
=
list
.
get
(
x
);
if
(
x
>
0
)
{
buff
.
append
(
", "
);
}
...
...
@@ -244,7 +244,7 @@ public class Merge extends Prepared {
public
void
prepare
()
throws
SQLException
{
if
(
columns
==
null
)
{
if
(
list
.
size
()
>
0
&&
((
Expression
[])
list
.
get
(
0
)
).
length
==
0
)
{
if
(
list
.
size
()
>
0
&&
list
.
get
(
0
).
length
==
0
)
{
// special case where table is used as a sequence
columns
=
new
Column
[
0
];
}
else
{
...
...
@@ -253,7 +253,7 @@ public class Merge extends Prepared {
}
if
(
list
.
size
()
>
0
)
{
for
(
int
x
=
0
;
x
<
list
.
size
();
x
++)
{
Expression
[]
expr
=
(
Expression
[])
list
.
get
(
x
);
Expression
[]
expr
=
list
.
get
(
x
);
if
(
expr
.
length
!=
columns
.
length
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
COLUMN_COUNT_DOES_NOT_MATCH
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
16a375cc
...
...
@@ -79,7 +79,7 @@ public abstract class Query extends Prepared {
*
* @return the list of expressions
*/
public
abstract
ObjectArray
getExpressions
();
public
abstract
ObjectArray
<
Expression
>
getExpressions
();
/**
* Calculate the cost to execute this query.
...
...
@@ -100,7 +100,7 @@ public abstract class Query extends Prepared {
*
* @param order the order by list
*/
public
abstract
void
setOrder
(
ObjectArray
order
);
public
abstract
void
setOrder
(
ObjectArray
<
SelectOrderBy
>
order
);
/**
* Set the 'for update' flag.
...
...
@@ -202,13 +202,13 @@ public abstract class Query extends Prepared {
}
public
final
Value
[]
getParameterValues
()
{
ObjectArray
list
=
getParameters
();
ObjectArray
<
Parameter
>
list
=
getParameters
();
if
(
list
==
null
)
{
list
=
ObjectArray
.
newInstance
();
}
Value
[]
params
=
new
Value
[
list
.
size
()];
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Value
v
=
((
Parameter
)
list
.
get
(
i
)
).
getParamValue
();
Value
v
=
list
.
get
(
i
).
getParamValue
();
params
[
i
]
=
v
;
}
return
params
;
...
...
@@ -252,10 +252,10 @@ public abstract class Query extends Prepared {
* @param visible the number of visible columns in the select list
* @param mustBeInResult all order by expressions must be in the select list
*/
void
initOrder
(
ObjectArray
expressions
,
ObjectArray
expressionSQL
,
ObjectArray
orderList
,
int
visible
,
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
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
SelectOrderBy
o
=
orderList
.
get
(
i
);
Expression
e
=
o
.
expression
;
if
(
e
==
null
)
{
continue
;
...
...
@@ -272,7 +272,7 @@ public abstract class Query extends Prepared {
String
col
=
exprCol
.
getOriginalColumnName
();
for
(
int
j
=
0
;
j
<
visible
;
j
++)
{
boolean
found
=
false
;
Expression
ec
=
(
Expression
)
expressions
.
get
(
j
);
Expression
ec
=
expressions
.
get
(
j
);
if
(
ec
instanceof
ExpressionColumn
)
{
ExpressionColumn
c
=
(
ExpressionColumn
)
ec
;
found
=
col
.
equals
(
c
.
getColumnName
());
...
...
@@ -309,7 +309,7 @@ public abstract class Query extends Prepared {
}
else
{
String
s
=
e
.
getSQL
();
for
(
int
j
=
0
;
expressionSQL
!=
null
&&
j
<
expressionSQL
.
size
();
j
++)
{
String
s2
=
(
String
)
expressionSQL
.
get
(
j
);
String
s2
=
expressionSQL
.
get
(
j
);
if
(
s2
.
equals
(
s
))
{
idx
=
j
;
isAlias
=
true
;
...
...
@@ -337,11 +337,11 @@ public abstract class Query extends Prepared {
* @param expressionCount the number of columns in the query
* @return the {@link SortOrder} object
*/
public
SortOrder
prepareOrder
(
ObjectArray
orderList
,
int
expressionCount
)
throws
SQLException
{
public
SortOrder
prepareOrder
(
ObjectArray
<
SelectOrderBy
>
orderList
,
int
expressionCount
)
throws
SQLException
{
int
[]
index
=
new
int
[
orderList
.
size
()];
int
[]
sortType
=
new
int
[
orderList
.
size
()];
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
SelectOrderBy
o
=
orderList
.
get
(
i
);
int
idx
;
boolean
reverse
=
false
;
Expression
expr
=
o
.
columnIndexExpr
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
16a375cc
...
...
@@ -39,6 +39,7 @@ import org.h2.result.LocalResult;
import
org.h2.result.Row
;
import
org.h2.schema.Constant
;
import
org.h2.schema.Schema
;
import
org.h2.schema.SchemaObject
;
import
org.h2.schema.Sequence
;
import
org.h2.schema.TriggerObject
;
import
org.h2.table.Column
;
...
...
@@ -125,9 +126,9 @@ public class ScriptCommand extends ScriptBase {
}
Database
db
=
session
.
getDatabase
();
if
(
settings
)
{
ObjectArray
settingList
=
db
.
getAllSettings
();
ObjectArray
<
Setting
>
settingList
=
db
.
getAllSettings
();
for
(
int
i
=
0
;
i
<
settingList
.
size
();
i
++)
{
Setting
setting
=
(
Setting
)
settingList
.
get
(
i
);
Setting
setting
=
settingList
.
get
(
i
);
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)
...
...
@@ -139,51 +140,51 @@ public class ScriptCommand extends ScriptBase {
if
(
out
!=
null
)
{
add
(
""
,
true
);
}
ObjectArray
users
=
db
.
getAllUsers
();
ObjectArray
<
User
>
users
=
db
.
getAllUsers
();
for
(
int
i
=
0
;
i
<
users
.
size
();
i
++)
{
User
user
=
(
User
)
users
.
get
(
i
);
User
user
=
users
.
get
(
i
);
add
(
user
.
getCreateSQL
(
passwords
,
true
),
false
);
}
ObjectArray
roles
=
db
.
getAllRoles
();
ObjectArray
<
Role
>
roles
=
db
.
getAllRoles
();
for
(
int
i
=
0
;
i
<
roles
.
size
();
i
++)
{
Role
role
=
(
Role
)
roles
.
get
(
i
);
Role
role
=
roles
.
get
(
i
);
add
(
role
.
getCreateSQL
(
true
),
false
);
}
ObjectArray
schemas
=
db
.
getAllSchemas
();
ObjectArray
<
Schema
>
schemas
=
db
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
schemas
.
size
();
i
++)
{
Schema
schema
=
(
Schema
)
schemas
.
get
(
i
);
Schema
schema
=
schemas
.
get
(
i
);
add
(
schema
.
getCreateSQL
(),
false
);
}
ObjectArray
datatypes
=
db
.
getAllUserDataTypes
();
ObjectArray
<
UserDataType
>
datatypes
=
db
.
getAllUserDataTypes
();
for
(
int
i
=
0
;
i
<
datatypes
.
size
();
i
++)
{
UserDataType
datatype
=
(
UserDataType
)
datatypes
.
get
(
i
);
UserDataType
datatype
=
datatypes
.
get
(
i
);
if
(
drop
)
{
add
(
datatype
.
getDropSQL
(),
false
);
}
add
(
datatype
.
getCreateSQL
(),
false
);
}
ObjectArray
constants
=
db
.
getAllSchemaObjects
(
DbObject
.
CONSTANT
);
ObjectArray
<
SchemaObject
>
constants
=
db
.
getAllSchemaObjects
(
DbObject
.
CONSTANT
);
for
(
int
i
=
0
;
i
<
constants
.
size
();
i
++)
{
Constant
constant
=
(
Constant
)
constants
.
get
(
i
);
add
(
constant
.
getCreateSQL
(),
false
);
}
ObjectArray
functionAliases
=
db
.
getAllFunctionAliases
();
ObjectArray
<
FunctionAlias
>
functionAliases
=
db
.
getAllFunctionAliases
();
for
(
int
i
=
0
;
i
<
functionAliases
.
size
();
i
++)
{
FunctionAlias
alias
=
(
FunctionAlias
)
functionAliases
.
get
(
i
);
FunctionAlias
alias
=
functionAliases
.
get
(
i
);
if
(
drop
)
{
add
(
alias
.
getDropSQL
(),
false
);
}
add
(
alias
.
getCreateSQL
(),
false
);
}
ObjectArray
aggregates
=
db
.
getAllAggregates
();
ObjectArray
<
UserAggregate
>
aggregates
=
db
.
getAllAggregates
();
for
(
int
i
=
0
;
i
<
aggregates
.
size
();
i
++)
{
UserAggregate
agg
=
(
UserAggregate
)
aggregates
.
get
(
i
);
UserAggregate
agg
=
aggregates
.
get
(
i
);
if
(
drop
)
{
add
(
agg
.
getDropSQL
(),
false
);
}
add
(
agg
.
getCreateSQL
(),
false
);
}
ObjectArray
tables
=
db
.
getAllSchemaObjects
(
DbObject
.
TABLE_OR_VIEW
);
ObjectArray
<
Table
>
tables
=
db
.
getAllTablesAndViews
(
);
// sort by id, so that views are after tables and views on views
// after the base views
tables
.
sort
(
new
Comparator
<
Table
>()
{
...
...
@@ -192,7 +193,7 @@ public class ScriptCommand extends ScriptBase {
}
});
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
(
Table
)
tables
.
get
(
i
);
Table
table
=
tables
.
get
(
i
);
table
.
lock
(
session
,
false
,
false
);
String
sql
=
table
.
getCreateSQL
();
if
(
sql
==
null
)
{
...
...
@@ -203,7 +204,7 @@ public class ScriptCommand extends ScriptBase {
add
(
table
.
getDropSQL
(),
false
);
}
}
ObjectArray
sequences
=
db
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
);
ObjectArray
<
SchemaObject
>
sequences
=
db
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
);
for
(
int
i
=
0
;
i
<
sequences
.
size
();
i
++)
{
Sequence
sequence
=
(
Sequence
)
sequences
.
get
(
i
);
if
(
drop
&&
!
sequence
.
getBelongsToTable
())
{
...
...
@@ -212,7 +213,7 @@ public class ScriptCommand extends ScriptBase {
add
(
sequence
.
getCreateSQL
(),
false
);
}
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
(
Table
)
tables
.
get
(
i
);
Table
table
=
tables
.
get
(
i
);
table
.
lock
(
session
,
false
,
false
);
String
sql
=
table
.
getCreateSQL
();
if
(
sql
==
null
)
{
...
...
@@ -287,9 +288,9 @@ public class ScriptCommand extends ScriptBase {
}
}
}
ObjectArray
indexes
=
table
.
getIndexes
();
ObjectArray
<
Index
>
indexes
=
table
.
getIndexes
();
for
(
int
j
=
0
;
indexes
!=
null
&&
j
<
indexes
.
size
();
j
++)
{
Index
index
=
(
Index
)
indexes
.
get
(
j
);
Index
index
=
indexes
.
get
(
j
);
if
(!
index
.
getIndexType
().
getBelongsToConstraint
())
{
add
(
index
.
getCreateSQL
(),
false
);
}
...
...
@@ -302,29 +303,29 @@ public class ScriptCommand extends ScriptBase {
add
(
"DROP ALIAS IF EXISTS SYSTEM_COMBINE_BLOB"
,
true
);
tempLobTableCreated
=
false
;
}
ObjectArray
constraints
=
db
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
);
constraints
.
sort
(
new
Comparator
<
Constrain
t
>()
{
public
int
compare
(
Constraint
c1
,
Constrain
t
c2
)
{
return
c1
.
compareTo
(
c2
);
ObjectArray
<
SchemaObject
>
constraints
=
db
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
);
constraints
.
sort
(
new
Comparator
<
SchemaObjec
t
>()
{
public
int
compare
(
SchemaObject
c1
,
SchemaObjec
t
c2
)
{
return
((
Constraint
)
c1
).
compareTo
((
Constraint
)
c2
);
}
});
for
(
int
i
=
0
;
i
<
constraints
.
size
();
i
++)
{
Constraint
constraint
=
(
Constraint
)
constraints
.
get
(
i
);
add
(
constraint
.
getCreateSQLWithoutIndexes
(),
false
);
}
ObjectArray
triggers
=
db
.
getAllSchemaObjects
(
DbObject
.
TRIGGER
);
ObjectArray
<
SchemaObject
>
triggers
=
db
.
getAllSchemaObjects
(
DbObject
.
TRIGGER
);
for
(
int
i
=
0
;
i
<
triggers
.
size
();
i
++)
{
TriggerObject
trigger
=
(
TriggerObject
)
triggers
.
get
(
i
);
add
(
trigger
.
getCreateSQL
(),
false
);
}
ObjectArray
rights
=
db
.
getAllRights
();
ObjectArray
<
Right
>
rights
=
db
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
(
Right
)
rights
.
get
(
i
);
Right
right
=
rights
.
get
(
i
);
add
(
right
.
getCreateSQL
(),
false
);
}
ObjectArray
comments
=
db
.
getAllComments
();
ObjectArray
<
Comment
>
comments
=
db
.
getAllComments
();
for
(
int
i
=
0
;
i
<
comments
.
size
();
i
++)
{
Comment
comment
=
(
Comment
)
comments
.
get
(
i
);
Comment
comment
=
comments
.
get
(
i
);
add
(
comment
.
getCreateSQL
(),
false
);
}
if
(
out
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
16a375cc
差异被折叠。
点击展开。
h2/src/main/org/h2/command/dml/SelectListColumnResolver.java
浏览文件 @
16a375cc
...
...
@@ -35,9 +35,9 @@ public class SelectListColumnResolver implements ColumnResolver {
int
columnCount
=
select
.
getColumnCount
();
columns
=
new
Column
[
columnCount
];
expressions
=
new
Expression
[
columnCount
];
ObjectArray
columnList
=
select
.
getExpressions
();
ObjectArray
<
Expression
>
columnList
=
select
.
getExpressions
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Expression
expr
=
(
Expression
)
columnList
.
get
(
i
);
Expression
expr
=
columnList
.
get
(
i
);
Column
column
=
new
Column
(
expr
.
getAlias
(),
Value
.
NULL
);
column
.
setTable
(
null
,
i
);
columns
[
i
]
=
column
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
16a375cc
...
...
@@ -56,8 +56,8 @@ public class SelectUnion extends Query {
private
int
unionType
;
private
Query
left
,
right
;
private
ObjectArray
expressions
;
private
ObjectArray
orderList
;
private
ObjectArray
<
Expression
>
expressions
;
private
ObjectArray
<
SelectOrderBy
>
orderList
;
private
SortOrder
sort
;
private
boolean
distinct
;
private
boolean
isPrepared
,
checkInit
;
...
...
@@ -80,20 +80,20 @@ public class SelectUnion extends Query {
this
.
sqlStatement
=
sql
;
}
public
void
setOrder
(
ObjectArray
order
)
{
public
void
setOrder
(
ObjectArray
<
SelectOrderBy
>
order
)
{
orderList
=
order
;
}
private
Value
[]
convert
(
Value
[]
values
,
int
columnCount
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Expression
e
=
(
Expression
)
expressions
.
get
(
i
);
Expression
e
=
expressions
.
get
(
i
);
values
[
i
]
=
values
[
i
].
convertTo
(
e
.
getType
());
}
return
values
;
}
public
LocalResult
queryMeta
()
throws
SQLException
{
ObjectArray
leftExpressions
=
left
.
getExpressions
();
ObjectArray
<
Expression
>
leftExpressions
=
left
.
getExpressions
();
int
columnCount
=
left
.
getColumnCount
();
LocalResult
result
=
new
LocalResult
(
session
,
leftExpressions
,
columnCount
);
result
.
done
();
...
...
@@ -193,12 +193,12 @@ public class SelectUnion extends Query {
if
(
len
!=
right
.
getColumnCount
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
COLUMN_COUNT_DOES_NOT_MATCH
);
}
ObjectArray
le
=
left
.
getExpressions
();
ObjectArray
<
Expression
>
le
=
left
.
getExpressions
();
// set the expressions to get the right column count and names,
// but can't validate at this time
expressions
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Expression
l
=
(
Expression
)
le
.
get
(
i
);
Expression
l
=
le
.
get
(
i
);
expressions
.
add
(
l
);
}
}
...
...
@@ -217,11 +217,11 @@ public class SelectUnion extends Query {
int
len
=
left
.
getColumnCount
();
// set the correct expressions now
expressions
=
ObjectArray
.
newInstance
();
ObjectArray
le
=
left
.
getExpressions
();
ObjectArray
re
=
right
.
getExpressions
();
ObjectArray
<
Expression
>
le
=
left
.
getExpressions
();
ObjectArray
<
Expression
>
re
=
right
.
getExpressions
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Expression
l
=
(
Expression
)
le
.
get
(
i
);
Expression
r
=
(
Expression
)
re
.
get
(
i
);
Expression
l
=
le
.
get
(
i
);
Expression
r
=
re
.
get
(
i
);
int
type
=
Value
.
getHigherOrder
(
l
.
getType
(),
r
.
getType
());
long
prec
=
Math
.
max
(
l
.
getPrecision
(),
r
.
getPrecision
());
int
scale
=
Math
.
max
(
l
.
getScale
(),
r
.
getScale
());
...
...
@@ -251,7 +251,7 @@ public class SelectUnion extends Query {
distinct
=
b
;
}
public
ObjectArray
getExpressions
()
{
public
ObjectArray
<
Expression
>
getExpressions
()
{
return
expressions
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
16a375cc
...
...
@@ -424,9 +424,9 @@ public class ConstraintReferential extends Constraint {
}
else
{
Prepared
updateCommand
=
getUpdate
(
session
);
if
(
updateAction
==
CASCADE
)
{
ObjectArray
params
=
updateCommand
.
getParameters
();
ObjectArray
<
Parameter
>
params
=
updateCommand
.
getParameters
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Parameter
param
=
(
Parameter
)
params
.
get
(
i
);
Parameter
param
=
params
.
get
(
i
);
Column
refCol
=
refColumns
[
i
].
column
;
param
.
setValue
(
newRow
.
getValue
(
refCol
.
getColumnId
()));
}
...
...
@@ -454,8 +454,8 @@ public class ConstraintReferential extends Constraint {
for
(
int
i
=
0
;
i
<
refColumns
.
length
;
i
++)
{
int
idx
=
refColumns
[
i
].
column
.
getColumnId
();
Value
v
=
row
.
getValue
(
idx
);
ObjectArray
params
=
command
.
getParameters
();
Parameter
param
=
(
Parameter
)
params
.
get
(
pos
+
i
);
ObjectArray
<
Parameter
>
params
=
command
.
getParameters
();
Parameter
param
=
params
.
get
(
pos
+
i
);
param
.
setValue
(
v
);
}
}
...
...
@@ -541,10 +541,10 @@ public class ConstraintReferential extends Constraint {
private
Prepared
prepare
(
Session
session
,
String
sql
,
int
action
)
throws
SQLException
{
Prepared
command
=
session
.
prepare
(
sql
);
if
(
action
!=
CASCADE
)
{
ObjectArray
params
=
command
.
getParameters
();
ObjectArray
<
Parameter
>
params
=
command
.
getParameters
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
column
=
columns
[
i
].
column
;
Parameter
param
=
(
Parameter
)
params
.
get
(
i
);
Parameter
param
=
params
.
get
(
i
);
Value
value
;
if
(
action
==
SET_NULL
)
{
value
=
ValueNull
.
INSTANCE
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
16a375cc
差异被折叠。
点击展开。
h2/src/main/org/h2/engine/DbObject.java
浏览文件 @
16a375cc
...
...
@@ -116,7 +116,7 @@ public interface DbObject {
*
* @return the list of children
*/
ObjectArray
getChildren
();
ObjectArray
<
DbObject
>
getChildren
();
/**
* Get the database.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/DbObjectBase.java
浏览文件 @
16a375cc
...
...
@@ -117,7 +117,7 @@ public abstract class DbObjectBase implements DbObject {
return
Parser
.
quoteIdentifier
(
objectName
);
}
public
ObjectArray
getChildren
()
{
public
ObjectArray
<
DbObject
>
getChildren
()
{
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
16a375cc
...
...
@@ -64,7 +64,7 @@ public class FunctionAlias extends DbObjectBase {
}
Class
<
?
>
javaClass
=
ClassUtils
.
loadUserClass
(
className
);
Method
[]
methods
=
javaClass
.
getMethods
();
ObjectArray
list
=
ObjectArray
.
newInstance
();
ObjectArray
<
JavaMethod
>
list
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
Method
m
=
methods
[
i
];
if
(!
Modifier
.
isStatic
(
m
.
getModifiers
()))
{
...
...
@@ -73,7 +73,7 @@ public class FunctionAlias extends DbObjectBase {
if
(
m
.
getName
().
equals
(
methodName
)
||
getMethodSignature
(
m
).
equals
(
methodName
))
{
JavaMethod
javaMethod
=
new
JavaMethod
(
m
,
i
);
for
(
int
j
=
0
;
j
<
list
.
size
();
j
++)
{
JavaMethod
old
=
(
JavaMethod
)
list
.
get
(
j
);
JavaMethod
old
=
list
.
get
(
j
);
if
(
old
.
getParameterCount
()
==
javaMethod
.
getParameterCount
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
METHODS_MUST_HAVE_DIFFERENT_PARAMETER_COUNTS_2
,
new
String
[]
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/MetaRecord.java
浏览文件 @
16a375cc
...
...
@@ -47,7 +47,7 @@ public class MetaRecord {
*
* @param records the list of meta records
*/
public
static
void
sort
(
ObjectArray
records
)
{
public
static
void
sort
(
ObjectArray
<
MetaRecord
>
records
)
{
records
.
sort
(
new
Comparator
<
MetaRecord
>()
{
public
int
compare
(
MetaRecord
m1
,
MetaRecord
m2
)
{
int
c1
=
DbObjectBase
.
getCreateOrder
(
m1
.
getObjectType
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Role.java
浏览文件 @
16a375cc
...
...
@@ -60,25 +60,25 @@ public class Role extends RightOwner {
}
public
void
removeChildrenAndResources
(
Session
session
)
throws
SQLException
{
ObjectArray
users
=
database
.
getAllUsers
();
ObjectArray
<
User
>
users
=
database
.
getAllUsers
();
for
(
int
i
=
0
;
i
<
users
.
size
();
i
++)
{
User
user
=
(
User
)
users
.
get
(
i
);
User
user
=
users
.
get
(
i
);
Right
right
=
user
.
getRightForRole
(
this
);
if
(
right
!=
null
)
{
database
.
removeDatabaseObject
(
session
,
right
);
}
}
ObjectArray
roles
=
database
.
getAllRoles
();
ObjectArray
<
Role
>
roles
=
database
.
getAllRoles
();
for
(
int
i
=
0
;
i
<
roles
.
size
();
i
++)
{
Role
r2
=
(
Role
)
roles
.
get
(
i
);
Role
r2
=
roles
.
get
(
i
);
Right
right
=
r2
.
getRightForRole
(
this
);
if
(
right
!=
null
)
{
database
.
removeDatabaseObject
(
session
,
right
);
}
}
ObjectArray
rights
=
database
.
getAllRights
();
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
(
Right
)
rights
.
get
(
i
);
Right
right
=
rights
.
get
(
i
);
if
(
right
.
getGrantee
()
==
this
)
{
database
.
removeDatabaseObject
(
session
,
right
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
16a375cc
...
...
@@ -60,7 +60,7 @@ public class Session extends SessionWithState {
private
ConnectionInfo
connectionInfo
;
private
User
user
;
private
int
id
;
private
ObjectArray
locks
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
Table
>
locks
=
ObjectArray
.
newInstance
();
private
UndoLog
undoLog
;
private
boolean
autoCommit
=
true
;
private
Random
random
;
...
...
@@ -192,7 +192,7 @@ public class Session extends SessionWithState {
return
localTempTables
.
get
(
name
);
}
public
ObjectArray
getLocalTempTables
()
{
public
ObjectArray
<
Table
>
getLocalTempTables
()
{
if
(
localTempTables
==
null
)
{
return
ObjectArray
.
newInstance
();
}
...
...
@@ -614,7 +614,7 @@ public class Session extends SessionWithState {
return
;
}
for
(
int
i
=
0
;
i
<
locks
.
size
();
i
++)
{
Table
t
=
(
Table
)
locks
.
get
(
i
);
Table
t
=
locks
.
get
(
i
);
if
(!
t
.
isLockedExclusively
())
{
synchronized
(
database
)
{
t
.
unlock
(
this
);
...
...
@@ -634,7 +634,7 @@ public class Session extends SessionWithState {
if
(
locks
.
size
()
>
0
)
{
synchronized
(
database
)
{
for
(
int
i
=
0
;
i
<
locks
.
size
();
i
++)
{
Table
t
=
(
Table
)
locks
.
get
(
i
);
Table
t
=
locks
.
get
(
i
);
t
.
unlock
(
this
);
}
locks
.
clear
();
...
...
@@ -649,9 +649,9 @@ public class Session extends SessionWithState {
private
void
cleanTempTables
(
boolean
closeSession
)
throws
SQLException
{
if
(
localTempTables
!=
null
&&
localTempTables
.
size
()
>
0
)
{
ObjectArray
list
=
ObjectArray
.
newInstance
(
localTempTables
.
values
());
ObjectArray
<
Table
>
list
=
ObjectArray
.
newInstance
(
localTempTables
.
values
());
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Table
table
=
(
Table
)
list
.
get
(
i
);
Table
table
=
list
.
get
(
i
);
if
(
closeSession
||
table
.
getOnCommitDrop
())
{
modificationId
++;
table
.
setModified
();
...
...
@@ -781,11 +781,11 @@ public class Session extends SessionWithState {
rollback
();
}
}
else
{
ObjectArray
list
=
logSystem
.
getInDoubtTransactions
();
ObjectArray
<
InDoubtTransaction
>
list
=
logSystem
.
getInDoubtTransactions
();
int
state
=
commit
?
InDoubtTransaction
.
COMMIT
:
InDoubtTransaction
.
ROLLBACK
;
boolean
found
=
false
;
for
(
int
i
=
0
;
list
!=
null
&&
i
<
list
.
size
();
i
++)
{
InDoubtTransaction
p
=
(
InDoubtTransaction
)
list
.
get
(
i
);
InDoubtTransaction
p
=
list
.
get
(
i
);
if
(
p
.
getTransaction
().
equals
(
transactionName
))
{
p
.
setState
(
state
);
found
=
true
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
16a375cc
...
...
@@ -66,7 +66,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
private
TraceSystem
traceSystem
;
private
Trace
trace
;
private
ObjectArray
transferList
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
Transfer
>
transferList
=
ObjectArray
.
newInstance
();
private
int
nextId
;
private
boolean
autoCommit
=
true
;
private
CommandInterface
switchOffAutoCommit
;
...
...
@@ -142,7 +142,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
return
;
}
for
(
int
i
=
0
;
i
<
transferList
.
size
();
i
++)
{
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
Transfer
transfer
=
transferList
.
get
(
i
);
try
{
Transfer
trans
=
transfer
.
openNewConnection
();
trans
.
init
();
...
...
@@ -187,7 +187,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
// (update set id=1 where id=0, but update set id=2 where id=0 is
// faster)
for
(
int
i
=
0
,
count
=
0
;
i
<
transferList
.
size
();
i
++)
{
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
Transfer
transfer
=
transferList
.
get
(
i
);
try
{
traceOperation
(
"COMMAND_COMMIT"
,
0
);
transfer
.
writeInt
(
SessionRemote
.
COMMAND_COMMIT
);
...
...
@@ -358,7 +358,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
// TODO check if a newer client version can be used
// not required when sending TCP_DRIVER_VERSION_6
CommandInterface
command
=
prepareCommand
(
"SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=?"
,
1
);
ParameterInterface
param
=
(
ParameterInterface
)
command
.
getParameters
().
get
(
0
);
ParameterInterface
param
=
command
.
getParameters
().
get
(
0
);
param
.
setValue
(
ValueString
.
get
(
"info.BUILD_ID"
),
false
);
ResultInterface
result
=
command
.
executeQuery
(
1
,
false
);
if
(
result
.
next
())
{
...
...
@@ -377,7 +377,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
sessionId
=
ByteUtils
.
convertBytesToString
(
RandomUtils
.
getSecureBytes
(
32
));
synchronized
(
this
)
{
for
(
int
i
=
0
;
i
<
transferList
.
size
();
i
++)
{
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
Transfer
transfer
=
transferList
.
get
(
i
);
try
{
traceOperation
(
"SESSION_SET_ID"
,
0
);
transfer
.
writeInt
(
SessionRemote
.
SESSION_SET_ID
);
...
...
@@ -471,7 +471,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
if
(
transferList
!=
null
)
{
synchronized
(
this
)
{
for
(
int
i
=
0
;
i
<
transferList
.
size
();
i
++)
{
Transfer
transfer
=
(
Transfer
)
transferList
.
get
(
i
);
Transfer
transfer
=
transferList
.
get
(
i
);
try
{
traceOperation
(
"SESSION_CLOSE"
,
0
);
transfer
.
writeInt
(
SessionRemote
.
SESSION_CLOSE
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/SessionWithState.java
浏览文件 @
16a375cc
...
...
@@ -17,7 +17,7 @@ import org.h2.value.Value;
*/
public
abstract
class
SessionWithState
implements
SessionInterface
{
protected
ObjectArray
sessionState
;
protected
ObjectArray
<
String
>
sessionState
;
protected
boolean
sessionStateChanged
;
private
boolean
sessionStateUpdating
;
...
...
@@ -29,7 +29,7 @@ public abstract class SessionWithState implements SessionInterface {
sessionStateUpdating
=
true
;
try
{
for
(
int
i
=
0
;
i
<
sessionState
.
size
();
i
++)
{
String
sql
=
(
String
)
sessionState
.
get
(
i
);
String
sql
=
sessionState
.
get
(
i
);
CommandInterface
ci
=
prepareCommand
(
sql
,
Integer
.
MAX_VALUE
);
ci
.
executeUpdate
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/User.java
浏览文件 @
16a375cc
...
...
@@ -187,18 +187,18 @@ public class User extends RightOwner {
return
DbObject
.
USER
;
}
public
ObjectArray
getChildren
()
{
ObjectArray
all
=
database
.
getAllRights
();
ObjectArray
children
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
all
.
size
();
i
++)
{
Right
right
=
(
Right
)
all
.
get
(
i
);
public
ObjectArray
<
DbObject
>
getChildren
()
{
ObjectArray
<
DbObject
>
children
=
ObjectArray
.
newInstance
();
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
rights
.
get
(
i
);
if
(
right
.
getGrantee
()
==
this
)
{
children
.
add
(
right
);
}
}
all
=
database
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
all
.
size
();
i
++)
{
Schema
schema
=
(
Schema
)
all
.
get
(
i
);
ObjectArray
<
Schema
>
schemas
=
database
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
schemas
.
size
();
i
++)
{
Schema
schema
=
schemas
.
get
(
i
);
if
(
schema
.
getOwner
()
==
this
)
{
children
.
add
(
schema
);
}
...
...
@@ -207,9 +207,9 @@ public class User extends RightOwner {
}
public
void
removeChildrenAndResources
(
Session
session
)
throws
SQLException
{
ObjectArray
rights
=
database
.
getAllRights
();
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
(
Right
)
rights
.
get
(
i
);
Right
right
=
rights
.
get
(
i
);
if
(
right
.
getGrantee
()
==
this
)
{
database
.
removeDatabaseObject
(
session
,
right
);
}
...
...
@@ -232,9 +232,9 @@ public class User extends RightOwner {
* @throws SQLException if this user owns a schema
*/
public
void
checkOwnsNoSchemas
()
throws
SQLException
{
ObjectArray
schemas
=
database
.
getAllSchemas
();
ObjectArray
<
Schema
>
schemas
=
database
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
schemas
.
size
();
i
++)
{
Schema
s
=
(
Schema
)
schemas
.
get
(
i
);
Schema
s
=
schemas
.
get
(
i
);
if
(
this
==
s
.
getOwner
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
CANNOT_DROP_2
,
new
String
[]{
getName
(),
s
.
getName
()
});
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Aggregate.java
浏览文件 @
16a375cc
...
...
@@ -121,7 +121,7 @@ public class Aggregate extends Expression {
private
Expression
on
;
private
Expression
separator
;
private
ObjectArray
orderList
;
private
ObjectArray
<
SelectOrderBy
>
orderList
;
private
SortOrder
sort
;
private
int
dataType
,
scale
;
private
long
precision
;
...
...
@@ -189,7 +189,7 @@ public class Aggregate extends Expression {
*
* @param orderBy the order by list
*/
public
void
setOrder
(
ObjectArray
orderBy
)
{
public
void
setOrder
(
ObjectArray
<
SelectOrderBy
>
orderBy
)
{
this
.
orderList
=
orderBy
;
}
...
...
@@ -206,7 +206,7 @@ public class Aggregate extends Expression {
int
[]
index
=
new
int
[
orderList
.
size
()];
int
[]
sortType
=
new
int
[
orderList
.
size
()];
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
SelectOrderBy
o
=
orderList
.
get
(
i
);
index
[
i
]
=
i
+
1
;
int
order
=
o
.
descending
?
SortOrder
.
DESCENDING
:
SortOrder
.
ASCENDING
;
sortType
[
i
]
=
order
;
...
...
@@ -245,7 +245,7 @@ public class Aggregate extends Expression {
Value
[]
array
=
new
Value
[
1
+
orderList
.
size
()];
array
[
0
]
=
v
;
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
SelectOrderBy
o
=
orderList
.
get
(
i
);
array
[
i
+
1
]
=
o
.
expression
.
getValue
(
session
);
}
v
=
ValueArray
.
get
(
array
);
...
...
@@ -292,18 +292,18 @@ public class Aggregate extends Expression {
}
Value
v
=
data
.
getValue
(
session
.
getDatabase
(),
distinct
);
if
(
type
==
GROUP_CONCAT
)
{
ObjectArray
list
=
data
.
getList
();
ObjectArray
<
Value
>
list
=
data
.
getList
();
if
(
list
==
null
||
list
.
size
()
==
0
)
{
return
ValueNull
.
INSTANCE
;
}
if
(
orderList
!=
null
)
{
try
{
final
SortOrder
sortOrder
=
sort
;
list
.
sort
(
new
Comparator
<
Value
Array
>()
{
public
int
compare
(
Value
Array
v1
,
ValueArray
v2
)
{
list
.
sort
(
new
Comparator
<
Value
>()
{
public
int
compare
(
Value
v1
,
Value
v2
)
{
try
{
Value
[]
a1
=
v1
.
getList
();
Value
[]
a2
=
v2
.
getList
();
Value
[]
a1
=
((
ValueArray
)
v1
)
.
getList
();
Value
[]
a2
=
((
ValueArray
)
v2
)
.
getList
();
return
sortOrder
.
compare
(
a1
,
a2
);
}
catch
(
SQLException
e
)
{
throw
Message
.
convertToInternal
(
e
);
...
...
@@ -317,7 +317,7 @@ public class Aggregate extends Expression {
StringBuffer
buff
=
new
StringBuffer
();
String
sep
=
separator
==
null
?
","
:
separator
.
getValue
(
session
).
getString
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Value
val
=
(
Value
)
list
.
get
(
i
);
Value
val
=
list
.
get
(
i
);
String
s
;
if
(
val
.
getType
()
==
Value
.
ARRAY
)
{
s
=
((
ValueArray
)
val
).
getList
()[
0
].
getString
();
...
...
@@ -347,7 +347,7 @@ public class Aggregate extends Expression {
}
if
(
orderList
!=
null
)
{
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
SelectOrderBy
o
=
orderList
.
get
(
i
);
o
.
expression
.
mapColumns
(
resolver
,
level
);
}
}
...
...
@@ -366,7 +366,7 @@ public class Aggregate extends Expression {
}
if
(
orderList
!=
null
)
{
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
SelectOrderBy
o
=
orderList
.
get
(
i
);
o
.
expression
=
o
.
expression
.
optimize
(
session
);
}
sort
=
initOrder
(
session
);
...
...
@@ -436,7 +436,7 @@ public class Aggregate extends Expression {
}
if
(
orderList
!=
null
)
{
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
SelectOrderBy
o
=
orderList
.
get
(
i
);
o
.
expression
.
setEvaluatable
(
tableFilter
,
b
);
}
}
...
...
@@ -464,7 +464,7 @@ public class Aggregate extends Expression {
if
(
orderList
!=
null
)
{
buff
.
append
(
" ORDER BY "
);
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
SelectOrderBy
o
=
orderList
.
get
(
i
);
if
(
i
>
0
)
{
buff
.
append
(
", "
);
}
...
...
@@ -572,7 +572,7 @@ public class Aggregate extends Expression {
return
false
;
}
for
(
int
i
=
0
;
orderList
!=
null
&&
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
SelectOrderBy
o
=
orderList
.
get
(
i
);
if
(!
o
.
expression
.
isEverything
(
visitor
))
{
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/AggregateData.java
浏览文件 @
16a375cc
...
...
@@ -7,7 +7,6 @@
package
org
.
h2
.
expression
;
import
java.sql.SQLException
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.message.Message
;
...
...
@@ -31,7 +30,7 @@ class AggregateData {
private
ValueHashMap
<
AggregateData
>
distinctValues
;
private
Value
value
;
private
double
sum
,
vpn
;
private
ObjectArray
list
;
private
ObjectArray
<
Value
>
list
;
AggregateData
(
int
aggregateType
,
int
dataType
)
{
this
.
aggregateType
=
aggregateType
;
...
...
@@ -146,7 +145,7 @@ class AggregateData {
}
}
ObjectArray
getList
()
{
ObjectArray
<
Value
>
getList
()
{
return
list
;
}
...
...
@@ -247,9 +246,9 @@ class AggregateData {
count
=
distinctValues
.
size
();
}
else
{
count
=
0
;
ObjectArray
l2
=
distinctValues
.
keys
();
ObjectArray
<
Value
>
l2
=
distinctValues
.
keys
();
for
(
int
i
=
0
;
i
<
l2
.
size
();
i
++)
{
add
(
database
,
false
,
(
Value
)
l2
.
get
(
i
));
add
(
database
,
false
,
l2
.
get
(
i
));
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ConditionIn.java
浏览文件 @
16a375cc
...
...
@@ -33,11 +33,11 @@ public class ConditionIn extends Condition {
private
final
Database
database
;
private
Expression
left
;
private
final
ObjectArray
values
;
private
final
ObjectArray
<
Expression
>
values
;
private
Value
min
,
max
;
private
int
queryLevel
;
public
ConditionIn
(
Database
database
,
Expression
left
,
ObjectArray
values
)
{
public
ConditionIn
(
Database
database
,
Expression
left
,
ObjectArray
<
Expression
>
values
)
{
this
.
database
=
database
;
this
.
left
=
left
;
this
.
values
=
values
;
...
...
@@ -54,7 +54,7 @@ public class ConditionIn extends Condition {
boolean
result
=
false
;
boolean
hasNull
=
false
;
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
Value
r
=
e
.
getValue
(
session
);
if
(
r
==
ValueNull
.
INSTANCE
)
{
hasNull
=
true
;
...
...
@@ -74,7 +74,7 @@ public class ConditionIn extends Condition {
public
void
mapColumns
(
ColumnResolver
resolver
,
int
queryLevel
)
throws
SQLException
{
left
.
mapColumns
(
resolver
,
queryLevel
);
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
e
.
mapColumns
(
resolver
,
queryLevel
);
}
this
.
queryLevel
=
Math
.
max
(
queryLevel
,
this
.
queryLevel
);
...
...
@@ -91,7 +91,7 @@ public class ConditionIn extends Condition {
}
boolean
allValuesConstant
=
true
;
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
e
=
e
.
optimize
(
session
);
if
(
allValuesConstant
&&
!
e
.
isConstant
())
{
allValuesConstant
=
false
;
...
...
@@ -103,7 +103,7 @@ public class ConditionIn extends Condition {
}
// TODO optimization: could use index in some cases (sort, use min and max)
if
(
values
.
size
()
==
1
)
{
Expression
right
=
(
Expression
)
values
.
get
(
0
);
Expression
right
=
values
.
get
(
0
);
Expression
expr
=
new
Comparison
(
session
,
Comparison
.
EQUAL
,
left
,
right
);
expr
=
expr
.
optimize
(
session
);
return
expr
;
...
...
@@ -118,7 +118,7 @@ public class ConditionIn extends Condition {
boolean
nullable
=
column
.
getNullable
();
CompareMode
mode
=
session
.
getDatabase
().
getCompareMode
();
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
Value
v
=
e
.
getValue
(
session
);
v
=
v
.
convertTo
(
dataType
);
values
.
set
(
i
,
ValueExpression
.
get
(
v
));
...
...
@@ -158,7 +158,7 @@ public class ConditionIn extends Condition {
public
void
setEvaluatable
(
TableFilter
tableFilter
,
boolean
b
)
{
left
.
setEvaluatable
(
tableFilter
,
b
);
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
e
.
setEvaluatable
(
tableFilter
,
b
);
}
}
...
...
@@ -171,7 +171,7 @@ public class ConditionIn extends Condition {
if
(
i
>
0
)
{
buff
.
append
(
", "
);
}
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
buff
.
append
(
e
.
getSQL
());
}
buff
.
append
(
"))"
);
...
...
@@ -181,7 +181,7 @@ public class ConditionIn extends Condition {
public
void
updateAggregate
(
Session
session
)
throws
SQLException
{
left
.
updateAggregate
(
session
);
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
e
.
updateAggregate
(
session
);
}
}
...
...
@@ -195,7 +195,7 @@ public class ConditionIn extends Condition {
private
boolean
areAllValues
(
ExpressionVisitor
visitor
)
{
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
if
(!
e
.
isEverything
(
visitor
))
{
return
false
;
}
...
...
@@ -206,7 +206,7 @@ public class ConditionIn extends Condition {
public
int
getCost
()
{
int
cost
=
left
.
getCost
();
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
cost
+=
e
.
getCost
();
}
return
cost
;
...
...
@@ -233,13 +233,13 @@ public class ConditionIn extends Condition {
TableFunction
function
=
new
TableFunction
(
database
,
Function
.
getFunctionInfo
(
"TABLE_DISTINCT"
),
rowCount
);
Expression
[]
array
=
new
Expression
[
rowCount
];
for
(
int
i
=
0
;
i
<
rowCount
;
i
++)
{
Expression
e
=
(
Expression
)
values
.
get
(
i
);
Expression
e
=
values
.
get
(
i
);
array
[
i
]
=
e
;
}
ExpressionList
list
=
new
ExpressionList
(
array
);
function
.
setParameter
(
0
,
list
);
function
.
doneWithParameters
();
ObjectArray
columns
=
ObjectArray
.
newInstance
();
ObjectArray
<
Column
>
columns
=
ObjectArray
.
newInstance
();
int
dataType
=
left
.
getType
();
String
columnName
=
session
.
getNextSystemIdentifier
(
select
.
getSQL
());
Column
col
=
new
Column
(
columnName
,
dataType
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Function.java
浏览文件 @
16a375cc
...
...
@@ -112,7 +112,7 @@ public class Function extends Expression implements FunctionCall {
protected
Expression
[]
args
;
private
FunctionInfo
info
;
private
ObjectArray
varArgs
;
private
ObjectArray
<
Expression
>
varArgs
;
private
int
dataType
,
scale
;
private
long
precision
=
PRECISION_UNKNOWN
;
private
int
displaySize
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Subquery.java
浏览文件 @
16a375cc
...
...
@@ -95,7 +95,7 @@ public class Subquery extends Expression {
}
private
Expression
getExpression
()
{
return
(
Expression
)
query
.
getExpressions
().
get
(
0
);
return
query
.
getExpressions
().
get
(
0
);
}
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/TableFunction.java
浏览文件 @
16a375cc
...
...
@@ -74,7 +74,7 @@ public class TableFunction extends Function {
return
getTable
(
session
,
args
,
true
,
false
);
}
public
void
setColumns
(
ObjectArray
columns
)
{
public
void
setColumns
(
ObjectArray
<
Column
>
columns
)
{
this
.
columnList
=
new
Column
[
columns
.
size
()];
columns
.
toArray
(
columnList
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/BtreeIndex.java
浏览文件 @
16a375cc
...
...
@@ -314,9 +314,9 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
* @param s the data page
* @return the array of rows
*/
ObjectArray
readRowArray
(
DataPage
s
)
throws
SQLException
{
ObjectArray
<
SearchRow
>
readRowArray
(
DataPage
s
)
throws
SQLException
{
int
len
=
s
.
readInt
();
ObjectArray
rows
=
ObjectArray
.
newInstance
(
len
);
ObjectArray
<
SearchRow
>
rows
=
ObjectArray
.
newInstance
(
len
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
pos
=
s
.
readInt
();
SearchRow
r
;
...
...
@@ -361,7 +361,8 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
storage
.
truncate
(
session
);
head
=
new
BtreeHead
();
addPage
(
session
,
head
);
BtreePage
root
=
setRoot
(
new
BtreeLeaf
(
this
,
ObjectArray
.
newInstance
()));
ObjectArray
<
SearchRow
>
empty
=
ObjectArray
.
newInstance
();
BtreePage
root
=
setRoot
(
new
BtreeLeaf
(
this
,
empty
));
addPage
(
session
,
root
);
deletePage
(
session
,
head
);
head
.
setRootPosition
(
root
.
getPos
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/BtreeLeaf.java
浏览文件 @
16a375cc
...
...
@@ -50,7 +50,7 @@ public class BtreeLeaf extends BtreePage {
}
}
BtreeLeaf
(
BtreeIndex
index
,
ObjectArray
pageData
)
{
BtreeLeaf
(
BtreeIndex
index
,
ObjectArray
<
SearchRow
>
pageData
)
{
super
(
index
);
this
.
pageData
=
pageData
;
}
...
...
@@ -59,7 +59,7 @@ public class BtreeLeaf extends BtreePage {
int
l
=
0
,
r
=
pageData
.
size
();
while
(
l
<
r
)
{
int
i
=
(
l
+
r
)
>>>
1
;
SearchRow
row
=
(
SearchRow
)
pageData
.
get
(
i
);
SearchRow
row
=
pageData
.
get
(
i
);
int
comp
=
index
.
compareRows
(
row
,
newRow
);
if
(
comp
==
0
)
{
if
(
index
.
indexType
.
getUnique
())
{
...
...
@@ -97,7 +97,7 @@ public class BtreeLeaf extends BtreePage {
}
while
(
l
<
r
)
{
int
i
=
(
l
+
r
)
>>>
1
;
SearchRow
row
=
(
SearchRow
)
pageData
.
get
(
i
);
SearchRow
row
=
pageData
.
get
(
i
);
if
(
SysProperties
.
CHECK
&&
row
==
null
)
{
Message
.
throwInternalError
(
"btree corrupt"
);
}
...
...
@@ -133,7 +133,7 @@ public class BtreeLeaf extends BtreePage {
}
BtreePage
split
(
Session
session
,
int
splitPoint
)
throws
SQLException
{
ObjectArray
data
=
ObjectArray
.
newInstance
();
ObjectArray
<
SearchRow
>
data
=
ObjectArray
.
newInstance
();
int
max
=
pageData
.
size
();
for
(
int
i
=
splitPoint
;
i
<
max
;
i
++)
{
data
.
add
(
getData
(
splitPoint
));
...
...
@@ -153,7 +153,7 @@ public class BtreeLeaf extends BtreePage {
}
while
(
l
<
r
)
{
int
i
=
(
l
+
r
)
>>>
1
;
SearchRow
row
=
(
SearchRow
)
pageData
.
get
(
i
);
SearchRow
row
=
pageData
.
get
(
i
);
int
comp
=
index
.
compareRows
(
row
,
compare
);
if
(
comp
>
0
||
(!
bigger
&&
comp
==
0
))
{
r
=
i
;
...
...
@@ -165,7 +165,7 @@ public class BtreeLeaf extends BtreePage {
return
false
;
}
cursor
.
push
(
this
,
l
);
SearchRow
row
=
(
SearchRow
)
pageData
.
get
(
l
);
SearchRow
row
=
pageData
.
get
(
l
);
cursor
.
setCurrentRow
(
row
);
return
true
;
}
...
...
@@ -173,7 +173,7 @@ public class BtreeLeaf extends BtreePage {
void
next
(
BtreeCursor
cursor
,
int
i
)
throws
SQLException
{
i
++;
if
(
i
<
pageData
.
size
())
{
SearchRow
r
=
(
SearchRow
)
pageData
.
get
(
i
);
SearchRow
r
=
pageData
.
get
(
i
);
cursor
.
setCurrentRow
(
r
);
cursor
.
setStackPosition
(
i
);
return
;
...
...
@@ -185,7 +185,7 @@ public class BtreeLeaf extends BtreePage {
void
previous
(
BtreeCursor
cursor
,
int
i
)
throws
SQLException
{
i
--;
if
(
i
>=
0
)
{
SearchRow
r
=
(
SearchRow
)
pageData
.
get
(
i
);
SearchRow
r
=
pageData
.
get
(
i
);
cursor
.
setCurrentRow
(
r
);
cursor
.
setStackPosition
(
i
);
return
;
...
...
@@ -203,7 +203,7 @@ public class BtreeLeaf extends BtreePage {
return
;
}
cursor
.
push
(
this
,
0
);
SearchRow
row
=
(
SearchRow
)
pageData
.
get
(
0
);
SearchRow
row
=
pageData
.
get
(
0
);
cursor
.
setCurrentRow
(
row
);
}
...
...
@@ -217,7 +217,7 @@ public class BtreeLeaf extends BtreePage {
return
;
}
cursor
.
push
(
this
,
last
);
SearchRow
row
=
(
SearchRow
)
pageData
.
get
(
last
);
SearchRow
row
=
pageData
.
get
(
last
);
cursor
.
setCurrentRow
(
row
);
}
...
...
@@ -260,7 +260,7 @@ public class BtreeLeaf extends BtreePage {
buff
.
writeInt
(
len
);
Column
[]
columns
=
index
.
getColumns
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
SearchRow
row
=
(
SearchRow
)
pageData
.
get
(
i
);
SearchRow
row
=
pageData
.
get
(
i
);
buff
.
writeInt
(
row
.
getPos
());
if
(!
writePos
)
{
for
(
int
j
=
0
;
j
<
columns
.
length
;
j
++)
{
...
...
@@ -288,7 +288,7 @@ public class BtreeLeaf extends BtreePage {
int
len
=
pageData
.
size
();
int
size
=
2
+
DataPage
.
LENGTH_INT
*
(
len
+
1
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
SearchRow
row
=
(
SearchRow
)
pageData
.
get
(
i
);
SearchRow
row
=
pageData
.
get
(
i
);
size
+=
getRowSize
(
dummy
,
row
);
}
size
+=
index
.
getRecordOverhead
();
...
...
@@ -303,7 +303,7 @@ public class BtreeLeaf extends BtreePage {
}
return
null
;
}
return
(
SearchRow
)
pageData
.
get
(
0
);
return
pageData
.
get
(
0
);
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/BtreeNode.java
浏览文件 @
16a375cc
...
...
@@ -54,14 +54,14 @@ public class BtreeNode extends BtreePage {
pageData
.
add
(
pivot
);
}
BtreeNode
(
BtreeIndex
index
,
IntArray
pageChildren
,
ObjectArray
pageData
)
{
BtreeNode
(
BtreeIndex
index
,
IntArray
pageChildren
,
ObjectArray
<
SearchRow
>
pageData
)
{
super
(
index
);
this
.
pageChildren
=
pageChildren
;
this
.
pageData
=
pageData
;
}
SearchRow
getData
(
int
i
)
throws
SQLException
{
SearchRow
r
=
(
SearchRow
)
pageData
.
get
(
i
);
SearchRow
r
=
pageData
.
get
(
i
);
if
(
r
==
null
)
{
int
p
=
pageChildren
.
get
(
i
+
1
);
Session
sysSession
=
index
.
getDatabase
().
getSystemSession
();
...
...
@@ -97,7 +97,8 @@ public class BtreeNode extends BtreePage {
}
int
at
=
l
;
if
(
pageChildren
.
size
()
==
0
)
{
BtreeLeaf
newLeaf
=
new
BtreeLeaf
(
index
,
ObjectArray
.
newInstance
());
ObjectArray
<
SearchRow
>
empty
=
ObjectArray
.
newInstance
();
BtreeLeaf
newLeaf
=
new
BtreeLeaf
(
index
,
empty
);
index
.
addPage
(
session
,
newLeaf
);
pageChildren
.
add
(
newLeaf
.
getPos
());
}
...
...
@@ -187,7 +188,7 @@ public class BtreeNode extends BtreePage {
}
BtreePage
split
(
Session
session
,
int
splitPoint
)
throws
SQLException
{
ObjectArray
data
=
ObjectArray
.
newInstance
();
ObjectArray
<
SearchRow
>
data
=
ObjectArray
.
newInstance
();
IntArray
children
=
new
IntArray
();
splitPoint
++;
int
max
=
pageData
.
size
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/BtreePage.java
浏览文件 @
16a375cc
...
...
@@ -39,7 +39,7 @@ public abstract class BtreePage extends Record {
/**
* The list of data pages.
*/
protected
ObjectArray
pageData
;
protected
ObjectArray
<
SearchRow
>
pageData
;
/**
* If this is the root page of the index.
...
...
@@ -141,7 +141,7 @@ public abstract class BtreePage extends Record {
* @throws SQLException
*/
SearchRow
getData
(
int
i
)
throws
SQLException
{
return
(
SearchRow
)
pageData
.
get
(
i
);
return
pageData
.
get
(
i
);
}
public
int
getByteCount
(
DataPage
dummy
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/MetaCursor.java
浏览文件 @
16a375cc
...
...
@@ -18,10 +18,10 @@ import org.h2.util.ObjectArray;
public
class
MetaCursor
implements
Cursor
{
private
Row
current
;
private
ObjectArray
rows
;
private
ObjectArray
<
Row
>
rows
;
private
int
index
;
MetaCursor
(
ObjectArray
rows
)
{
MetaCursor
(
ObjectArray
<
Row
>
rows
)
{
this
.
rows
=
rows
;
}
...
...
@@ -38,7 +38,7 @@ public class MetaCursor implements Cursor {
}
public
boolean
next
()
{
current
=
(
Row
)
(
index
>=
rows
.
size
()
?
null
:
rows
.
get
(
index
++)
);
current
=
index
>=
rows
.
size
()
?
null
:
rows
.
get
(
index
++
);
return
current
!=
null
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/MetaIndex.java
浏览文件 @
16a375cc
...
...
@@ -43,7 +43,7 @@ public class MetaIndex extends BaseIndex {
}
public
Cursor
find
(
Session
session
,
SearchRow
first
,
SearchRow
last
)
throws
SQLException
{
ObjectArray
rows
=
meta
.
generateRows
(
session
,
first
,
last
);
ObjectArray
<
Row
>
rows
=
meta
.
generateRows
(
session
,
first
,
last
);
return
new
MetaCursor
(
rows
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/MultiVersionIndex.java
浏览文件 @
16a375cc
...
...
@@ -8,6 +8,7 @@ package org.h2.index;
import
java.sql.SQLException
;
import
org.h2.engine.Database
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.Session
;
import
org.h2.message.Message
;
import
org.h2.result.Row
;
...
...
@@ -260,7 +261,7 @@ public class MultiVersionIndex implements Index {
base
.
checkRename
();
}
public
ObjectArray
getChildren
()
{
public
ObjectArray
<
DbObject
>
getChildren
()
{
return
base
.
getChildren
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageBtreeLeaf.java
浏览文件 @
16a375cc
...
...
@@ -108,7 +108,7 @@ class PageBtreeLeaf extends PageBtree {
return
0
;
}
private
void
removeRow
(
int
i
)
throws
SQLException
{
private
void
removeRow
(
int
i
)
{
entryCount
--;
written
=
false
;
if
(
entryCount
<=
0
)
{
...
...
@@ -161,15 +161,15 @@ class PageBtreeLeaf extends PageBtree {
return
false
;
}
int
getRowCount
()
throws
SQLException
{
int
getRowCount
()
{
return
entryCount
;
}
void
setRowCountStored
(
int
rowCount
)
throws
SQLException
{
void
setRowCountStored
(
int
rowCount
)
{
// ignore
}
public
int
getByteCount
(
DataPage
dummy
)
throws
SQLException
{
public
int
getByteCount
(
DataPage
dummy
)
{
return
index
.
getPageStore
().
getPageSize
();
}
...
...
@@ -222,7 +222,7 @@ class PageBtreeLeaf extends PageBtree {
cursor
.
setCurrent
(
this
,
i
);
}
void
remapChildren
()
throws
SQLException
{
void
remapChildren
()
{
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageBtreeNode.java
浏览文件 @
16a375cc
...
...
@@ -247,7 +247,7 @@ class PageBtreeNode extends PageBtree {
}
}
public
int
getByteCount
(
DataPage
dummy
)
throws
SQLException
{
public
int
getByteCount
(
DataPage
dummy
)
{
return
index
.
getPageStore
().
getPageSize
();
}
...
...
@@ -281,7 +281,7 @@ class PageBtreeNode extends PageBtree {
written
=
true
;
}
private
void
removeChild
(
int
i
)
throws
SQLException
{
private
void
removeChild
(
int
i
)
{
entryCount
--;
written
=
false
;
if
(
entryCount
<
0
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
16a375cc
...
...
@@ -205,10 +205,6 @@ class PageDataLeaf extends PageData {
* @return the row
*/
Row
getRowAt
(
int
at
)
throws
SQLException
{
int
test
;
if
(
at
>=
rows
.
length
)
{
System
.
out
.
println
(
"stop"
);
}
Row
r
=
rows
[
at
];
if
(
r
==
null
)
{
if
(
firstOverflowPageId
!=
0
)
{
...
...
@@ -275,7 +271,7 @@ if (at >= rows.length) {
return
this
;
}
protected
void
remapChildren
()
throws
SQLException
{
protected
void
remapChildren
()
{
if
(
firstOverflowPageId
==
0
)
{
return
;
}
...
...
@@ -306,15 +302,15 @@ if (at >= rows.length) {
return
getRowAt
(
index
);
}
int
getRowCount
()
throws
SQLException
{
int
getRowCount
()
{
return
entryCount
;
}
void
setRowCountStored
(
int
rowCount
)
throws
SQLException
{
void
setRowCountStored
(
int
rowCount
)
{
// ignore
}
public
int
getByteCount
(
DataPage
dummy
)
throws
SQLException
{
public
int
getByteCount
(
DataPage
dummy
)
{
return
index
.
getPageStore
().
getPageSize
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataLeafOverflow.java
浏览文件 @
16a375cc
...
...
@@ -104,13 +104,12 @@ public class PageDataLeafOverflow extends Record {
if
(
type
==
(
Page
.
TYPE_DATA_OVERFLOW
|
Page
.
FLAG_LAST
))
{
target
.
write
(
data
.
getBytes
(),
START_LAST
,
size
);
return
0
;
}
else
{
target
.
write
(
data
.
getBytes
(),
START_MORE
,
size
);
return
next
;
}
target
.
write
(
data
.
getBytes
(),
START_MORE
,
size
);
return
next
;
}
public
int
getByteCount
(
DataPage
dummy
)
throws
SQLException
{
public
int
getByteCount
(
DataPage
dummy
)
{
return
leaf
.
getByteCount
(
dummy
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataNode.java
浏览文件 @
16a375cc
...
...
@@ -243,7 +243,7 @@ class PageDataNode extends PageData {
}
}
public
int
getByteCount
(
DataPage
dummy
)
throws
SQLException
{
public
int
getByteCount
(
DataPage
dummy
)
{
return
index
.
getPageStore
().
getPageSize
();
}
...
...
@@ -262,7 +262,7 @@ class PageDataNode extends PageData {
index
.
getPageStore
().
writePage
(
getPos
(),
data
);
}
private
void
removeChild
(
int
i
)
throws
SQLException
{
private
void
removeChild
(
int
i
)
{
entryCount
--;
if
(
entryCount
<
0
)
{
Message
.
throwInternalError
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageScanCursor.java
浏览文件 @
16a375cc
...
...
@@ -25,7 +25,7 @@ class PageScanCursor implements Cursor {
this
.
index
=
index
;
}
public
Row
get
()
throws
SQLException
{
public
Row
get
()
{
return
row
;
}
...
...
@@ -33,7 +33,7 @@ class PageScanCursor implements Cursor {
return
row
.
getPos
();
}
public
SearchRow
getSearchRow
()
throws
SQLException
{
public
SearchRow
getSearchRow
()
{
return
get
();
}
...
...
@@ -50,7 +50,7 @@ class PageScanCursor implements Cursor {
return
true
;
}
public
boolean
previous
()
throws
SQLException
{
public
boolean
previous
()
{
index
--;
int
todo
;
return
true
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageScanIndex.java
浏览文件 @
16a375cc
...
...
@@ -181,7 +181,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
throw
Message
.
getUnsupportedException
(
"PAGE"
);
}
public
double
getCost
(
Session
session
,
int
[]
masks
)
throws
SQLException
{
public
double
getCost
(
Session
session
,
int
[]
masks
)
{
long
cost
=
10
*
(
tableData
.
getRowCountApproximation
()
+
Constants
.
COST_ROW_OFFSET
);
return
cost
;
}
...
...
@@ -292,7 +292,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
return
-
1
;
}
public
void
close
(
Session
session
)
throws
SQLException
{
public
void
close
(
Session
session
)
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"close"
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/ScanIndex.java
浏览文件 @
16a375cc
...
...
@@ -36,7 +36,7 @@ import org.h2.value.ValueLob;
*/
public
class
ScanIndex
extends
BaseIndex
implements
RowIndex
{
private
int
firstFree
=
-
1
;
private
ObjectArray
rows
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
Row
>
rows
=
ObjectArray
.
newInstance
();
private
Storage
storage
;
private
TableData
tableData
;
private
int
rowCountDiff
;
...
...
@@ -99,7 +99,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
if
(
storage
!=
null
)
{
return
(
Row
)
storage
.
getRecord
(
session
,
key
);
}
return
(
Row
)
rows
.
get
(
key
);
return
rows
.
get
(
key
);
}
public
void
add
(
Session
session
,
Row
row
)
throws
SQLException
{
...
...
@@ -125,7 +125,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
rows
.
add
(
row
);
}
else
{
int
key
=
firstFree
;
Row
free
=
(
Row
)
rows
.
get
(
key
);
Row
free
=
rows
.
get
(
key
);
firstFree
=
free
.
getPos
();
row
.
setPos
(
key
);
rows
.
set
(
key
,
row
);
...
...
@@ -246,7 +246,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
if
(
key
>=
rows
.
size
())
{
return
null
;
}
row
=
(
Row
)
rows
.
get
(
key
);
row
=
rows
.
get
(
key
);
if
(!
row
.
isEmpty
())
{
return
row
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/ViewIndex.java
浏览文件 @
16a375cc
...
...
@@ -31,7 +31,7 @@ public class ViewIndex extends BaseIndex {
private
final
TableView
view
;
private
final
String
querySQL
;
private
final
ObjectArray
originalParameters
;
private
final
ObjectArray
<
Parameter
>
originalParameters
;
private
final
SmallLRUCache
<
IntArray
,
CostElement
>
costCache
=
SmallLRUCache
.
newInstance
(
Constants
.
VIEW_INDEX_CACHE_SIZE
);
private
boolean
recursive
;
private
int
[]
masks
;
...
...
@@ -39,7 +39,7 @@ public class ViewIndex extends BaseIndex {
private
Query
query
;
private
Session
session
;
public
ViewIndex
(
TableView
view
,
String
querySQL
,
ObjectArray
originalParameters
,
boolean
recursive
)
{
public
ViewIndex
(
TableView
view
,
String
querySQL
,
ObjectArray
<
Parameter
>
originalParameters
,
boolean
recursive
)
{
initBaseIndex
(
view
,
0
,
null
,
null
,
IndexType
.
createNonUnique
(
false
));
this
.
view
=
view
;
this
.
querySQL
=
querySQL
;
...
...
@@ -155,13 +155,13 @@ public class ViewIndex extends BaseIndex {
}
public
Cursor
find
(
Session
session
,
SearchRow
first
,
SearchRow
last
)
throws
SQLException
{
ObjectArray
paramList
=
query
.
getParameters
();
ObjectArray
<
Parameter
>
paramList
=
query
.
getParameters
();
for
(
int
i
=
0
;
originalParameters
!=
null
&&
i
<
originalParameters
.
size
();
i
++)
{
Parameter
orig
=
(
Parameter
)
originalParameters
.
get
(
i
);
Parameter
orig
=
originalParameters
.
get
(
i
);
int
idx
=
orig
.
getIndex
();
// the parameter may have been optimized away
if
(
idx
<
paramList
.
size
())
{
Parameter
param
=
(
Parameter
)
paramList
.
get
(
idx
);
Parameter
param
=
paramList
.
get
(
idx
);
Value
value
=
orig
.
getValue
(
session
);
param
.
setValue
(
value
);
}
...
...
@@ -180,7 +180,7 @@ public class ViewIndex extends BaseIndex {
if
(
first
!=
null
)
{
Value
v
=
first
.
getValue
(
i
);
if
(
v
!=
null
)
{
Parameter
param
=
(
Parameter
)
paramList
.
get
(
idx
++);
Parameter
param
=
paramList
.
get
(
idx
++);
param
.
setValue
(
v
);
}
}
...
...
@@ -188,7 +188,7 @@ public class ViewIndex extends BaseIndex {
if
(
last
!=
null
&&
masks
[
i
]
!=
IndexCondition
.
EQUALITY
)
{
Value
v
=
last
.
getValue
(
i
);
if
(
v
!=
null
)
{
Parameter
param
=
(
Parameter
)
paramList
.
get
(
idx
++);
Parameter
param
=
paramList
.
get
(
idx
++);
param
.
setValue
(
v
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
16a375cc
...
...
@@ -30,7 +30,6 @@ import org.h2.engine.ConnectionInfo;
import
org.h2.engine.Constants
;
import
org.h2.engine.SessionInterface
;
import
org.h2.engine.SessionRemote
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
import
org.h2.message.TraceObject
;
...
...
@@ -629,7 +628,7 @@ public class JdbcConnection extends TraceObject implements Connection {
}
commit
();
setLockMode
=
prepareCommand
(
"SET LOCK_MODE ?"
,
setLockMode
);
((
ParameterInterface
)
setLockMode
.
getParameters
().
get
(
0
)
).
setValue
(
ValueInt
.
get
(
lockMode
),
false
);
setLockMode
.
getParameters
().
get
(
0
).
setValue
(
ValueInt
.
get
(
lockMode
),
false
);
setLockMode
.
executeUpdate
();
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -644,7 +643,7 @@ public class JdbcConnection extends TraceObject implements Connection {
debugCodeCall
(
"setQueryTimeout"
,
seconds
);
checkClosed
();
setQueryTimeout
=
prepareCommand
(
"SET QUERY_TIMEOUT ?"
,
setQueryTimeout
);
((
ParameterInterface
)
setQueryTimeout
.
getParameters
().
get
(
0
)
).
setValue
(
ValueInt
.
get
(
seconds
*
1000
),
false
);
setQueryTimeout
.
getParameters
().
get
(
0
).
setValue
(
ValueInt
.
get
(
seconds
*
1000
),
false
);
setQueryTimeout
.
executeUpdate
();
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -659,7 +658,7 @@ public class JdbcConnection extends TraceObject implements Connection {
debugCodeCall
(
"getQueryTimeout"
);
checkClosed
();
getQueryTimeout
=
prepareCommand
(
"SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=?"
,
getQueryTimeout
);
((
ParameterInterface
)
getQueryTimeout
.
getParameters
().
get
(
0
)
).
setValue
(
ValueString
.
get
(
"QUERY_TIMEOUT"
),
false
);
getQueryTimeout
.
getParameters
().
get
(
0
).
setValue
(
ValueString
.
get
(
"QUERY_TIMEOUT"
),
false
);
ResultInterface
result
=
getQueryTimeout
.
executeQuery
(
0
,
false
);
result
.
next
();
int
queryTimeout
=
result
.
currentRow
()[
0
].
getInt
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcParameterMetaData.java
浏览文件 @
16a375cc
...
...
@@ -30,7 +30,7 @@ implements ParameterMetaData
private
JdbcPreparedStatement
prep
;
private
int
paramCount
;
private
ObjectArray
parameters
;
private
ObjectArray
<
?
extends
ParameterInterface
>
parameters
;
JdbcParameterMetaData
(
Trace
trace
,
JdbcPreparedStatement
prep
,
CommandInterface
command
,
int
id
)
{
setTrace
(
trace
,
TraceObject
.
PARAMETER_META_DATA
,
id
);
...
...
@@ -208,7 +208,7 @@ implements ParameterMetaData
if
(
param
<
1
||
param
>
paramCount
)
{
throw
Message
.
getInvalidValueException
(
""
+
param
,
"param"
);
}
return
(
ParameterInterface
)
parameters
.
get
(
param
-
1
);
return
parameters
.
get
(
param
-
1
);
}
private
void
checkClosed
()
throws
SQLException
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
浏览文件 @
16a375cc
...
...
@@ -64,7 +64,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
private
final
String
sql
;
private
CommandInterface
command
;
private
ObjectArray
batchParameters
;
private
ObjectArray
<
Value
[]>
batchParameters
;
JdbcPreparedStatement
(
JdbcConnection
conn
,
String
sql
,
int
resultSetType
,
int
id
,
boolean
closeWithResultSet
)
throws
SQLException
{
...
...
@@ -193,9 +193,9 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
try
{
debugCodeCall
(
"clearParameters"
);
checkClosed
();
ObjectArray
parameters
=
command
.
getParameters
();
ObjectArray
<
?
extends
ParameterInterface
>
parameters
=
command
.
getParameters
();
for
(
int
i
=
0
;
i
<
parameters
.
size
();
i
++)
{
ParameterInterface
param
=
(
ParameterInterface
)
parameters
.
get
(
i
);
ParameterInterface
param
=
parameters
.
get
(
i
);
// can only delete old temp files if they are not in the batch
param
.
setValue
(
null
,
batchParameters
==
null
);
}
...
...
@@ -1040,11 +1040,11 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
boolean
error
=
false
;
SQLException
next
=
null
;
for
(
int
i
=
0
;
i
<
batchParameters
.
size
();
i
++)
{
ObjectArray
parameters
=
command
.
getParameters
();
Value
[]
set
=
(
Value
[])
batchParameters
.
get
(
i
);
ObjectArray
<
?
extends
ParameterInterface
>
parameters
=
command
.
getParameters
();
Value
[]
set
=
batchParameters
.
get
(
i
);
for
(
int
j
=
0
;
j
<
set
.
length
;
j
++)
{
Value
value
=
set
[
j
];
ParameterInterface
param
=
(
ParameterInterface
)
parameters
.
get
(
j
);
ParameterInterface
param
=
parameters
.
get
(
j
);
param
.
setValue
(
value
,
false
);
}
try
{
...
...
@@ -1082,10 +1082,10 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
try
{
debugCodeCall
(
"addBatch"
);
checkClosedForWrite
();
ObjectArray
parameters
=
command
.
getParameters
();
ObjectArray
<
?
extends
ParameterInterface
>
parameters
=
command
.
getParameters
();
Value
[]
set
=
new
Value
[
parameters
.
size
()];
for
(
int
i
=
0
;
i
<
parameters
.
size
();
i
++)
{
ParameterInterface
param
=
(
ParameterInterface
)
parameters
.
get
(
i
);
ParameterInterface
param
=
parameters
.
get
(
i
);
Value
value
=
param
.
getParamValue
();
set
[
i
]
=
value
;
}
...
...
@@ -1221,11 +1221,11 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
private
void
setParameter
(
int
parameterIndex
,
Value
value
)
throws
SQLException
{
checkClosed
();
parameterIndex
--;
ObjectArray
parameters
=
command
.
getParameters
();
ObjectArray
<
?
extends
ParameterInterface
>
parameters
=
command
.
getParameters
();
if
(
parameterIndex
<
0
||
parameterIndex
>=
parameters
.
size
())
{
throw
Message
.
getInvalidValueException
(
""
+
(
parameterIndex
+
1
),
"parameterIndex"
);
}
ParameterInterface
param
=
(
ParameterInterface
)
parameters
.
get
(
parameterIndex
);
ParameterInterface
param
=
parameters
.
get
(
parameterIndex
);
// can only delete old temp files if they are not in the batch
param
.
setValue
(
value
,
batchParameters
==
null
);
}
...
...
@@ -1416,14 +1416,14 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
protected
boolean
checkClosed
(
boolean
write
)
throws
SQLException
{
if
(
super
.
checkClosed
(
write
))
{
// if the session was re-connected, re-prepare the statement
ObjectArray
oldParams
=
command
.
getParameters
();
ObjectArray
<
?
extends
ParameterInterface
>
oldParams
=
command
.
getParameters
();
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
ObjectArray
newParams
=
command
.
getParameters
();
ObjectArray
<
?
extends
ParameterInterface
>
newParams
=
command
.
getParameters
();
for
(
int
i
=
0
;
i
<
oldParams
.
size
();
i
++)
{
ParameterInterface
old
=
(
ParameterInterface
)
oldParams
.
get
(
i
);
ParameterInterface
old
=
oldParams
.
get
(
i
);
Value
value
=
old
.
getParamValue
();
if
(
value
!=
null
)
{
ParameterInterface
n
=
(
ParameterInterface
)
newParams
.
get
(
i
);
ParameterInterface
n
=
newParams
.
get
(
i
);
n
.
setValue
(
value
,
false
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcStatement.java
浏览文件 @
16a375cc
...
...
@@ -36,7 +36,7 @@ public class JdbcStatement extends TraceObject implements Statement {
protected
int
resultSetType
;
protected
boolean
closedByResultSet
;
private
CommandInterface
executingCommand
;
private
ObjectArray
batchCommands
;
private
ObjectArray
<
String
>
batchCommands
;
private
boolean
escapeProcessing
=
true
;
JdbcStatement
(
JdbcConnection
conn
,
int
resultSetType
,
int
id
,
boolean
closeWithResultSet
)
{
...
...
@@ -610,7 +610,7 @@ public class JdbcStatement extends TraceObject implements Statement {
int
[]
result
=
new
int
[
batchCommands
.
size
()];
boolean
error
=
false
;
for
(
int
i
=
0
;
i
<
batchCommands
.
size
();
i
++)
{
String
sql
=
(
String
)
batchCommands
.
get
(
i
);
String
sql
=
batchCommands
.
get
(
i
);
try
{
result
[
i
]
=
executeUpdate
(
sql
);
}
catch
(
SQLException
e
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/log/LogFile.java
浏览文件 @
16a375cc
...
...
@@ -67,7 +67,7 @@ public class LogFile {
private
FileStore
file
;
private
int
bufferPos
;
private
byte
[]
buffer
;
private
ObjectArray
unwritten
;
private
ObjectArray
<
Record
>
unwritten
;
private
DataPage
rowBuff
;
private
int
pos
=
LogSystem
.
LOG_WRITTEN
;
private
int
firstUncommittedPos
=
LogSystem
.
LOG_WRITTEN
;
...
...
@@ -426,7 +426,7 @@ public class LogFile {
file
.
write
(
buffer
,
0
,
bufferPos
);
pos
=
getBlock
();
for
(
int
i
=
0
;
i
<
unwritten
.
size
();
i
++)
{
Record
r
=
(
Record
)
unwritten
.
get
(
i
);
Record
r
=
unwritten
.
get
(
i
);
r
.
setLogWritten
(
id
,
pos
);
}
unwritten
.
clear
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/log/LogSystem.java
浏览文件 @
16a375cc
...
...
@@ -39,20 +39,20 @@ public class LogSystem {
public
static
final
int
LOG_WRITTEN
=
-
1
;
private
Database
database
;
private
ObjectArray
activeLogs
;
private
ObjectArray
<
LogFile
>
activeLogs
;
private
LogFile
currentLog
;
private
String
fileNamePrefix
;
private
HashMap
<
Integer
,
Storage
>
storages
=
New
.
hashMap
();
private
HashMap
<
Integer
,
SessionState
>
sessionStates
=
New
.
hashMap
();
private
DataPage
rowBuff
;
private
ObjectArray
undo
;
private
ObjectArray
<
LogRecord
>
undo
;
// TODO log file / deleteOldLogFilesAutomatically:
// make this a setting, so they can be backed up
private
boolean
deleteOldLogFilesAutomatically
=
true
;
private
long
maxLogSize
=
Constants
.
DEFAULT_MAX_LOG_SIZE
;
private
boolean
readOnly
;
private
boolean
flushOnEachCommit
;
private
ObjectArray
inDoubtTransactions
;
private
ObjectArray
<
InDoubtTransaction
>
inDoubtTransactions
;
private
boolean
disabled
;
private
int
keepFiles
;
private
boolean
closed
;
...
...
@@ -140,7 +140,7 @@ public class LogSystem {
}
}
for
(
int
i
=
activeLogs
.
size
()
-
1
;
i
>=
0
;
i
--)
{
LogFile
l
=
(
LogFile
)
activeLogs
.
get
(
i
);
LogFile
l
=
activeLogs
.
get
(
i
);
if
(
l
.
getId
()
<
firstUncommittedLog
)
{
l
.
setFirstUncommittedPos
(
LOG_WRITTEN
);
}
else
if
(
l
.
getId
()
==
firstUncommittedLog
)
{
...
...
@@ -156,7 +156,7 @@ public class LogSystem {
}
}
for
(
int
i
=
0
;
i
<
activeLogs
.
size
();
i
++)
{
LogFile
l
=
(
LogFile
)
activeLogs
.
get
(
i
);
LogFile
l
=
activeLogs
.
get
(
i
);
if
(
l
.
getFirstUncommittedPos
()
==
LOG_WRITTEN
)
{
// must remove the log file first
// if we don't do that, the file is closed but still in the list
...
...
@@ -182,7 +182,7 @@ public class LogSystem {
}
if
(
readOnly
)
{
for
(
int
i
=
0
;
i
<
activeLogs
.
size
();
i
++)
{
LogFile
l
=
(
LogFile
)
activeLogs
.
get
(
i
);
LogFile
l
=
activeLogs
.
get
(
i
);
l
.
close
(
false
);
}
closed
=
true
;
...
...
@@ -202,7 +202,7 @@ public class LogSystem {
closeException
=
Message
.
convert
(
e
);
}
for
(
int
i
=
0
;
i
<
activeLogs
.
size
();
i
++)
{
LogFile
l
=
(
LogFile
)
activeLogs
.
get
(
i
);
LogFile
l
=
activeLogs
.
get
(
i
);
try
{
// if there are any in-doubt transactions
// (even if they are resolved), can't delete the log files
...
...
@@ -254,7 +254,7 @@ public class LogSystem {
}
undo
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
activeLogs
.
size
();
i
++)
{
LogFile
log
=
(
LogFile
)
activeLogs
.
get
(
i
);
LogFile
log
=
activeLogs
.
get
(
i
);
log
.
redoAllGoEnd
();
database
.
getDataFile
().
flushRedoLog
();
database
.
getIndexFile
().
flushRedoLog
();
...
...
@@ -270,7 +270,7 @@ public class LogSystem {
}
for
(
int
i
=
undo
.
size
()
-
1
;
i
>=
0
&&
sessionStates
.
size
()
>
0
;
i
--)
{
database
.
setProgress
(
DatabaseEventListener
.
STATE_RECOVER
,
null
,
undo
.
size
()
-
1
-
i
,
undo
.
size
());
LogRecord
record
=
(
LogRecord
)
undo
.
get
(
i
);
LogRecord
record
=
undo
.
get
(
i
);
if
(
sessionStates
.
get
(
ObjectUtils
.
getInteger
(
record
.
sessionId
))
!=
null
)
{
// undo only if the session is not yet committed
record
.
log
.
undo
(
record
.
logRecordId
);
...
...
@@ -330,7 +330,7 @@ public class LogSystem {
LogFile
l
=
new
LogFile
(
this
,
0
,
fileNamePrefix
);
activeLogs
.
add
(
l
);
}
currentLog
=
(
LogFile
)
activeLogs
.
get
(
activeLogs
.
size
()
-
1
);
currentLog
=
activeLogs
.
get
(
activeLogs
.
size
()
-
1
);
closed
=
false
;
}
...
...
@@ -426,7 +426,7 @@ public class LogSystem {
*
* @return the list
*/
public
ObjectArray
getInDoubtTransactions
()
{
public
ObjectArray
<
InDoubtTransaction
>
getInDoubtTransactions
()
{
return
inDoubtTransactions
;
}
...
...
@@ -584,9 +584,9 @@ public class LogSystem {
*
* @return the list of log files
*/
public
ObjectArray
getActiveLogFiles
()
{
public
ObjectArray
<
LogFile
>
getActiveLogFiles
()
{
synchronized
(
database
)
{
ObjectArray
list
=
ObjectArray
.
newInstance
();
ObjectArray
<
LogFile
>
list
=
ObjectArray
.
newInstance
();
list
.
addAll
(
activeLogs
);
return
list
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/log/UndoLog.java
浏览文件 @
16a375cc
...
...
@@ -24,7 +24,7 @@ public class UndoLog {
private
Database
database
;
// TODO undo log entry: a chain would probably be faster
// and use less memory than an array
private
ObjectArray
records
=
ObjectArray
.
newInstance
();
private
ObjectArray
<
UndoLogRecord
>
records
=
ObjectArray
.
newInstance
();
private
FileStore
file
;
private
DataPage
rowBuff
;
private
int
memoryUndo
;
...
...
@@ -71,12 +71,12 @@ public class UndoLog {
*/
public
UndoLogRecord
getLast
()
throws
SQLException
{
int
i
=
records
.
size
()
-
1
;
UndoLogRecord
entry
=
(
UndoLogRecord
)
records
.
get
(
i
);
UndoLogRecord
entry
=
records
.
get
(
i
);
if
(
entry
.
isStored
())
{
int
start
=
Math
.
max
(
0
,
i
-
database
.
getMaxMemoryUndo
()
/
2
);
UndoLogRecord
first
=
null
;
for
(
int
j
=
start
;
j
<=
i
;
j
++)
{
UndoLogRecord
e
=
(
UndoLogRecord
)
records
.
get
(
j
);
UndoLogRecord
e
=
records
.
get
(
j
);
if
(
e
.
isStored
())
{
e
.
load
(
rowBuff
,
file
);
memoryUndo
++;
...
...
@@ -124,7 +124,7 @@ public class UndoLog {
rowBuff
=
DataPage
.
create
(
database
,
Constants
.
DEFAULT_DATA_PAGE_SIZE
);
DataPage
buff
=
rowBuff
;
for
(
int
i
=
0
;
i
<
records
.
size
();
i
++)
{
UndoLogRecord
r
=
(
UndoLogRecord
)
records
.
get
(
i
);
UndoLogRecord
r
=
records
.
get
(
i
);
saveIfPossible
(
r
,
buff
);
}
}
else
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/log/UndoLogRecord.java
浏览文件 @
16a375cc
...
...
@@ -212,9 +212,9 @@ public class UndoLogRecord {
* It commits the change to the indexes.
*/
public
void
commit
()
throws
SQLException
{
ObjectArray
list
=
table
.
getIndexes
();
ObjectArray
<
Index
>
list
=
table
.
getIndexes
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Index
index
=
(
Index
)
list
.
get
(
i
);
Index
index
=
list
.
get
(
i
);
index
.
commit
(
operation
,
row
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/message/TraceObject.java
浏览文件 @
16a375cc
...
...
@@ -413,7 +413,7 @@ public class TraceObject {
/**
* INTERNAL
*/
public
static
String
toString
(
String
sql
,
ObjectArray
params
)
{
public
static
String
toString
(
String
sql
,
ObjectArray
<
?
extends
ParameterInterface
>
params
)
{
StringBuffer
buff
=
new
StringBuffer
();
buff
.
append
(
sql
);
if
(
params
!=
null
&&
params
.
size
()
>
0
)
{
...
...
@@ -425,7 +425,7 @@ public class TraceObject {
}
buff
.
append
(
i
+
1
);
buff
.
append
(
": "
);
ParameterInterface
p
=
(
ParameterInterface
)
params
.
get
(
i
);
ParameterInterface
p
=
params
.
get
(
i
);
if
(
p
==
null
||
p
.
getParamValue
()
==
null
)
{
buff
.
append
(
"-"
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/LocalResult.java
浏览文件 @
16a375cc
...
...
@@ -36,7 +36,7 @@ public class LocalResult implements ResultInterface {
private
int
visibleColumnCount
;
private
Expression
[]
expressions
;
private
int
rowId
,
rowCount
;
private
ObjectArray
rows
;
private
ObjectArray
<
Value
[]>
rows
;
private
SortOrder
sort
;
private
ValueHashMap
<
Value
[]>
distinctRows
;
private
Value
[]
currentRow
;
...
...
@@ -80,7 +80,7 @@ public class LocalResult implements ResultInterface {
* @param expressionList the expression list
* @param visibleColumnCount the number of visible columns
*/
public
LocalResult
(
Session
session
,
ObjectArray
expressionList
,
int
visibleColumnCount
)
{
public
LocalResult
(
Session
session
,
ObjectArray
<
Expression
>
expressionList
,
int
visibleColumnCount
)
{
this
(
session
,
getList
(
expressionList
),
visibleColumnCount
);
}
...
...
@@ -93,7 +93,7 @@ public class LocalResult implements ResultInterface {
* @return the local result set
*/
public
static
LocalResult
read
(
Session
session
,
ResultSet
rs
,
int
maxrows
)
throws
SQLException
{
ObjectArray
cols
=
getExpressionColumns
(
session
,
rs
);
ObjectArray
<
Expression
>
cols
=
getExpressionColumns
(
session
,
rs
);
int
columnCount
=
cols
.
size
();
LocalResult
result
=
new
LocalResult
(
session
,
cols
,
columnCount
);
for
(
int
i
=
0
;
(
maxrows
==
0
||
i
<
maxrows
)
&&
rs
.
next
();
i
++)
{
...
...
@@ -108,10 +108,10 @@ public class LocalResult implements ResultInterface {
return
result
;
}
private
static
ObjectArray
getExpressionColumns
(
Session
session
,
ResultSet
rs
)
throws
SQLException
{
private
static
ObjectArray
<
Expression
>
getExpressionColumns
(
Session
session
,
ResultSet
rs
)
throws
SQLException
{
ResultSetMetaData
meta
=
rs
.
getMetaData
();
int
columnCount
=
meta
.
getColumnCount
();
ObjectArray
cols
=
ObjectArray
.
newInstance
(
columnCount
);
ObjectArray
<
Expression
>
cols
=
ObjectArray
.
newInstance
(
columnCount
);
Database
db
=
session
==
null
?
null
:
session
.
getDatabase
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
String
name
=
meta
.
getColumnLabel
(
i
+
1
);
...
...
@@ -156,7 +156,7 @@ public class LocalResult implements ResultInterface {
return
copy
;
}
private
static
Expression
[]
getList
(
ObjectArray
expressionList
)
{
private
static
Expression
[]
getList
(
ObjectArray
<
Expression
>
expressionList
)
{
Expression
[]
expressions
=
new
Expression
[
expressionList
.
size
()];
expressionList
.
toArray
(
expressions
);
return
expressions
;
...
...
@@ -237,7 +237,7 @@ public class LocalResult implements ResultInterface {
if
(
disk
!=
null
)
{
currentRow
=
disk
.
next
();
}
else
{
currentRow
=
(
Value
[])
rows
.
get
(
rowId
);
currentRow
=
rows
.
get
(
rowId
);
}
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/ResultDiskBuffer.java
浏览文件 @
16a375cc
...
...
@@ -28,7 +28,7 @@ class ResultDiskBuffer implements ResultExternal {
private
DataPage
rowBuff
;
private
FileStore
file
;
private
ObjectArray
tapes
;
private
ObjectArray
<
ResultDiskTape
>
tapes
;
private
ResultDiskTape
mainTape
;
private
SortOrder
sort
;
private
int
columnCount
;
...
...
@@ -57,7 +57,7 @@ class ResultDiskBuffer implements ResultExternal {
/**
* A list of rows in the buffer.
*/
ObjectArray
buffer
=
ObjectArray
.
newInstance
();
ObjectArray
<
Value
[]>
buffer
=
ObjectArray
.
newInstance
();
}
ResultDiskBuffer
(
Session
session
,
SortOrder
sort
,
int
columnCount
)
throws
SQLException
{
...
...
@@ -77,7 +77,7 @@ class ResultDiskBuffer implements ResultExternal {
}
}
public
void
addRows
(
ObjectArray
rows
)
throws
SQLException
{
public
void
addRows
(
ObjectArray
<
Value
[]>
rows
)
throws
SQLException
{
if
(
sort
!=
null
)
{
sort
.
sort
(
rows
);
}
...
...
@@ -89,7 +89,7 @@ class ResultDiskBuffer implements ResultExternal {
for
(
int
i
=
0
;
i
<
rows
.
size
();
i
++)
{
buff
.
reset
();
buff
.
writeInt
(
0
);
Value
[]
row
=
(
Value
[])
rows
.
get
(
i
);
Value
[]
row
=
rows
.
get
(
i
);
for
(
int
j
=
0
;
j
<
columnCount
;
j
++)
{
buff
.
writeValue
(
row
[
j
]);
}
...
...
@@ -172,7 +172,7 @@ class ResultDiskBuffer implements ResultExternal {
readRow
(
mainTape
);
}
}
Value
[]
row
=
(
Value
[])
mainTape
.
buffer
.
get
(
0
);
Value
[]
row
=
mainTape
.
buffer
.
get
(
0
);
mainTape
.
buffer
.
remove
(
0
);
return
row
;
}
...
...
@@ -196,18 +196,18 @@ class ResultDiskBuffer implements ResultExternal {
}
}
ResultDiskTape
t
=
getTape
(
next
);
Value
[]
row
=
(
Value
[])
t
.
buffer
.
get
(
0
);
Value
[]
row
=
t
.
buffer
.
get
(
0
);
t
.
buffer
.
remove
(
0
);
return
row
;
}
private
ResultDiskTape
getTape
(
int
i
)
{
return
(
ResultDiskTape
)
tapes
.
get
(
i
);
return
tapes
.
get
(
i
);
}
private
int
compareTapes
(
ResultDiskTape
a
,
ResultDiskTape
b
)
throws
SQLException
{
Value
[]
va
=
(
Value
[])
a
.
buffer
.
get
(
0
);
Value
[]
vb
=
(
Value
[])
b
.
buffer
.
get
(
0
);
Value
[]
va
=
a
.
buffer
.
get
(
0
);
Value
[]
vb
=
b
.
buffer
.
get
(
0
);
return
sort
.
compare
(
va
,
vb
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/ResultExternal.java
浏览文件 @
16a375cc
...
...
@@ -34,7 +34,7 @@ public interface ResultExternal {
*
* @param rows the list of rows to add
*/
void
addRows
(
ObjectArray
rows
)
throws
SQLException
;
void
addRows
(
ObjectArray
<
Value
[]>
rows
)
throws
SQLException
;
/**
* This method is called after all rows have been added.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/ResultRemote.java
浏览文件 @
16a375cc
...
...
@@ -31,8 +31,8 @@ public class ResultRemote implements ResultInterface {
private
ResultColumn
[]
columns
;
private
Value
[]
currentRow
;
private
int
rowId
,
rowCount
,
rowOffset
;
private
ObjectArray
result
;
private
ObjectArray
lobValues
;
private
ObjectArray
<
Value
[]>
result
;
private
ObjectArray
<
Value
>
lobValues
;
public
ResultRemote
(
SessionRemote
session
,
Transfer
transfer
,
int
id
,
int
columnCount
,
int
fetchSize
)
throws
IOException
,
SQLException
{
...
...
@@ -119,7 +119,7 @@ public class ResultRemote implements ResultInterface {
if
(
rowId
-
rowOffset
>=
result
.
size
())
{
fetchRows
(
true
);
}
currentRow
=
(
Value
[])
result
.
get
(
rowId
-
rowOffset
);
currentRow
=
result
.
get
(
rowId
-
rowOffset
);
return
true
;
}
currentRow
=
null
;
...
...
@@ -166,7 +166,7 @@ public class ResultRemote implements ResultInterface {
sendClose
();
if
(
lobValues
!=
null
)
{
for
(
int
i
=
0
;
i
<
lobValues
.
size
();
i
++)
{
Value
v
=
(
Value
)
lobValues
.
get
(
i
);
Value
v
=
lobValues
.
get
(
i
);
try
{
v
.
close
();
}
catch
(
SQLException
e
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/ResultTempTable.java
浏览文件 @
16a375cc
...
...
@@ -42,7 +42,7 @@ public class ResultTempTable implements ResultExternal {
Schema
schema
=
session
.
getDatabase
().
getSchema
(
Constants
.
SCHEMA_MAIN
);
Column
column
=
new
Column
(
COLUMN_NAME
,
Value
.
ARRAY
);
column
.
setNullable
(
false
);
ObjectArray
columns
=
ObjectArray
.
newInstance
();
ObjectArray
<
Column
>
columns
=
ObjectArray
.
newInstance
();
columns
.
add
(
column
);
int
tableId
=
session
.
getDatabase
().
allocateObjectId
(
true
,
true
);
String
tableName
=
"TEMP_RESULT_SET_"
+
tableId
;
...
...
@@ -85,12 +85,12 @@ public class ResultTempTable implements ResultExternal {
return
(
int
)
table
.
getRowCount
(
session
);
}
public
void
addRows
(
ObjectArray
rows
)
throws
SQLException
{
public
void
addRows
(
ObjectArray
<
Value
[]>
rows
)
throws
SQLException
{
if
(
sort
!=
null
)
{
sort
.
sort
(
rows
);
}
for
(
int
i
=
0
;
i
<
rows
.
size
();
i
++)
{
Value
[]
values
=
(
Value
[])
rows
.
get
(
i
);
Value
[]
values
=
rows
.
get
(
i
);
addRow
(
values
);
}
}
...
...
@@ -99,7 +99,7 @@ public class ResultTempTable implements ResultExternal {
try
{
if
(
table
!=
null
)
{
index
.
remove
(
session
);
ObjectArray
indexes
=
table
.
getIndexes
();
ObjectArray
<
Index
>
indexes
=
table
.
getIndexes
();
indexes
.
remove
(
indexes
.
indexOf
(
index
));
table
.
removeChildrenAndResources
(
session
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/RowList.java
浏览文件 @
16a375cc
...
...
@@ -27,13 +27,13 @@ import org.h2.value.ValueLob;
public
class
RowList
{
private
final
Session
session
;
private
final
ObjectArray
list
=
ObjectArray
.
newInstance
();
private
final
ObjectArray
<
Row
>
list
=
ObjectArray
.
newInstance
();
private
int
size
;
private
int
index
,
listIndex
;
private
FileStore
file
;
private
DataPage
rowBuff
;
private
Cache
cache
;
private
ObjectArray
lobs
;
private
ObjectArray
<
ValueLob
>
lobs
;
private
int
memory
,
maxMemory
;
private
boolean
written
;
private
boolean
readUncached
;
...
...
@@ -97,7 +97,7 @@ public class RowList {
flushBuffer
(
buff
);
initBuffer
(
buff
);
}
Row
r
=
(
Row
)
list
.
get
(
i
);
Row
r
=
list
.
get
(
i
);
writeRow
(
buff
,
r
);
}
flushBuffer
(
buff
);
...
...
@@ -209,7 +209,7 @@ public class RowList {
public
Row
next
()
throws
SQLException
{
Row
r
;
if
(
file
==
null
)
{
r
=
(
Row
)
list
.
get
(
index
++);
r
=
list
.
get
(
index
++);
}
else
{
if
(
listIndex
>=
list
.
size
())
{
list
.
clear
();
...
...
@@ -233,7 +233,7 @@ public class RowList {
}
}
index
++;
r
=
(
Row
)
list
.
get
(
listIndex
++);
r
=
list
.
get
(
listIndex
++);
}
return
r
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/SortOrder.java
浏览文件 @
16a375cc
...
...
@@ -156,41 +156,41 @@ public class SortOrder {
*
* @param rows the list of rows
*/
public
void
sort
(
ObjectArray
rows
)
throws
SQLException
{
public
void
sort
(
ObjectArray
<
Value
[]>
rows
)
throws
SQLException
{
sort
(
rows
,
0
,
rows
.
size
()
-
1
);
}
private
void
swap
(
ObjectArray
rows
,
int
a
,
int
b
)
{
Object
t
=
rows
.
get
(
a
);
private
void
swap
(
ObjectArray
<
Value
[]>
rows
,
int
a
,
int
b
)
{
Value
[]
t
=
rows
.
get
(
a
);
rows
.
set
(
a
,
rows
.
get
(
b
));
rows
.
set
(
b
,
t
);
}
private
void
sort
(
ObjectArray
rows
,
int
l
,
int
r
)
throws
SQLException
{
private
void
sort
(
ObjectArray
<
Value
[]>
rows
,
int
l
,
int
r
)
throws
SQLException
{
// quicksort
int
i
,
j
;
while
(
r
-
l
>
10
)
{
// randomized pivot to avoid worst case
i
=
RandomUtils
.
nextInt
(
r
-
l
-
4
)
+
l
+
2
;
if
(
compare
(
(
Value
[])
rows
.
get
(
l
),
(
Value
[])
rows
.
get
(
r
))
>
0
)
{
if
(
compare
(
rows
.
get
(
l
),
rows
.
get
(
r
))
>
0
)
{
swap
(
rows
,
l
,
r
);
}
if
(
compare
(
(
Value
[])
rows
.
get
(
i
),
(
Value
[])
rows
.
get
(
l
))
<
0
)
{
if
(
compare
(
rows
.
get
(
i
),
rows
.
get
(
l
))
<
0
)
{
swap
(
rows
,
l
,
i
);
}
else
if
(
compare
(
(
Value
[])
rows
.
get
(
i
),
(
Value
[])
rows
.
get
(
r
))
>
0
)
{
}
else
if
(
compare
(
rows
.
get
(
i
),
rows
.
get
(
r
))
>
0
)
{
swap
(
rows
,
i
,
r
);
}
j
=
r
-
1
;
swap
(
rows
,
i
,
j
);
Value
[]
p
=
(
Value
[])
rows
.
get
(
j
);
Value
[]
p
=
rows
.
get
(
j
);
i
=
l
;
while
(
true
)
{
do
{
++
i
;
}
while
(
compare
(
(
Value
[])
rows
.
get
(
i
),
p
)
<
0
);
}
while
(
compare
(
rows
.
get
(
i
),
p
)
<
0
);
do
{
--
j
;
}
while
(
compare
(
(
Value
[])
rows
.
get
(
j
),
p
)
>
0
);
}
while
(
compare
(
rows
.
get
(
j
),
p
)
>
0
);
if
(
i
>=
j
)
{
break
;
}
...
...
@@ -201,8 +201,8 @@ public class SortOrder {
l
=
i
+
1
;
}
for
(
i
=
l
+
1
;
i
<=
r
;
i
++)
{
Value
[]
t
=
(
Value
[])
rows
.
get
(
i
);
for
(
j
=
i
-
1
;
j
>=
l
&&
(
compare
(
(
Value
[])
rows
.
get
(
j
),
t
)
>
0
);
j
--)
{
Value
[]
t
=
rows
.
get
(
i
);
for
(
j
=
i
-
1
;
j
>=
l
&&
(
compare
(
rows
.
get
(
j
),
t
)
>
0
);
j
--)
{
rows
.
set
(
j
+
1
,
rows
.
get
(
j
));
}
rows
.
set
(
j
+
1
,
t
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/UpdatableRow.java
浏览文件 @
16a375cc
...
...
@@ -33,7 +33,7 @@ public class UpdatableRow {
private
final
int
columnCount
;
private
String
schemaName
;
private
String
tableName
;
private
ObjectArray
key
;
private
ObjectArray
<
String
>
key
;
private
boolean
isUpdatable
;
/**
...
...
@@ -132,14 +132,14 @@ public class UpdatableRow {
if
(
i
>
0
)
{
buff
.
append
(
" AND "
);
}
buff
.
append
(
StringUtils
.
quoteIdentifier
(
(
String
)
key
.
get
(
i
)));
buff
.
append
(
StringUtils
.
quoteIdentifier
(
key
.
get
(
i
)));
buff
.
append
(
"=?"
);
}
}
private
void
setKey
(
PreparedStatement
prep
,
int
start
,
Value
[]
current
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
key
.
size
();
i
++)
{
String
col
=
(
String
)
key
.
get
(
i
);
String
col
=
key
.
get
(
i
);
int
idx
=
getColumnIndex
(
col
);
Value
v
=
current
[
idx
];
if
(
v
==
null
||
v
==
ValueNull
.
INSTANCE
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
16a375cc
...
...
@@ -21,6 +21,7 @@ import org.h2.engine.User;
import
org.h2.index.Index
;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.table.TableData
;
import
org.h2.table.TableLink
;
...
...
@@ -454,11 +455,20 @@ public class Schema extends DbObjectBase {
* @param type the object type
* @return a (possible empty) list of all objects
*/
public
ObjectArray
getAll
(
int
type
)
{
public
ObjectArray
<
SchemaObject
>
getAll
(
int
type
)
{
HashMap
<
String
,
SchemaObject
>
map
=
getMap
(
type
);
return
ObjectArray
.
newInstance
(
map
.
values
());
}
/**
* Get all tables and views.
*
* @return a (possible empty) list of all objects
*/
public
ObjectArray
<
Table
>
getAllTablesAndViews
()
{
return
ObjectArray
.
newInstance
(
tablesAndViews
.
values
());
}
/**
* Remove an object from this schema.
*
...
...
@@ -487,7 +497,7 @@ public class Schema extends DbObjectBase {
* @param session the session
* @return the created {@link TableData} object
*/
public
TableData
createTable
(
String
tableName
,
int
id
,
ObjectArray
columns
,
boolean
persistIndexes
,
boolean
persistData
,
boolean
clustered
,
int
headPos
,
Session
session
)
public
TableData
createTable
(
String
tableName
,
int
id
,
ObjectArray
<
Column
>
columns
,
boolean
persistIndexes
,
boolean
persistData
,
boolean
clustered
,
int
headPos
,
Session
session
)
throws
SQLException
{
return
new
TableData
(
this
,
tableName
,
id
,
columns
,
persistIndexes
,
persistData
,
clustered
,
headPos
,
session
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
16a375cc
...
...
@@ -21,6 +21,7 @@ import org.h2.engine.Engine;
import
org.h2.engine.Session
;
import
org.h2.engine.SessionRemote
;
import
org.h2.expression.Parameter
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.expression.ParameterRemote
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.message.Message
;
...
...
@@ -203,7 +204,7 @@ public class TcpServerThread implements Runnable {
private
void
setParameters
(
Command
command
)
throws
IOException
,
SQLException
{
int
len
=
transfer
.
readInt
();
ObjectArray
params
=
command
.
getParameters
();
ObjectArray
<
?
extends
ParameterInterface
>
params
=
command
.
getParameters
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Parameter
p
=
(
Parameter
)
params
.
get
(
i
);
p
.
setValue
(
transfer
.
readValue
());
...
...
@@ -222,13 +223,13 @@ public class TcpServerThread implements Runnable {
boolean
readonly
=
command
.
isReadOnly
();
cache
.
addObject
(
id
,
command
);
boolean
isQuery
=
command
.
isQuery
();
ObjectArray
params
=
command
.
getParameters
();
ObjectArray
<
?
extends
ParameterInterface
>
params
=
command
.
getParameters
();
int
paramCount
=
params
.
size
();
transfer
.
writeInt
(
getState
(
old
)).
writeBoolean
(
isQuery
).
writeBoolean
(
readonly
)
.
writeInt
(
paramCount
);
if
(
operation
==
SessionRemote
.
SESSION_PREPARE_READ_PARAMS
)
{
for
(
int
i
=
0
;
i
<
paramCount
;
i
++)
{
Parameter
p
=
(
Parameter
)
params
.
get
(
i
);
Parameter
Interface
p
=
params
.
get
(
i
);
ParameterRemote
.
writeMetaData
(
transfer
,
p
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebThread.java
浏览文件 @
16a375cc
...
...
@@ -1272,7 +1272,7 @@ class WebThread extends Thread implements DatabaseEventListener {
result
=
"${text.result.maxrowsSet}"
;
}
else
{
ScriptReader
r
=
new
ScriptReader
(
new
StringReader
(
sql
));
ObjectArray
list
=
ObjectArray
.
newInstance
();
ObjectArray
<
String
>
list
=
ObjectArray
.
newInstance
();
while
(
true
)
{
String
s
=
r
.
readStatement
();
if
(
s
==
null
)
{
...
...
@@ -1282,7 +1282,7 @@ class WebThread extends Thread implements DatabaseEventListener {
}
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
String
s
=
(
String
)
list
.
get
(
i
);
String
s
=
list
.
get
(
i
);
if
(!
s
.
startsWith
(
"@"
))
{
buff
.
append
(
PageParser
.
escapeHtml
(
s
+
";"
));
buff
.
append
(
"<br />"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
16a375cc
...
...
@@ -96,7 +96,7 @@ public class DiskFile implements CacheWriter {
private
boolean
logChanges
;
private
int
recordOverhead
;
private
boolean
init
,
initAlreadyTried
;
private
ObjectArray
redoBuffer
;
private
ObjectArray
<
RedoLogRecord
>
redoBuffer
;
private
int
redoBufferSize
;
private
int
readCount
,
writeCount
;
private
String
mode
;
...
...
@@ -221,7 +221,7 @@ public class DiskFile implements CacheWriter {
out
.
write
(
mask
);
}
out
.
writeInt
(
pageOwners
.
size
());
ObjectArray
storages
=
ObjectArray
.
newInstance
();
ObjectArray
<
Storage
>
storages
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
pageOwners
.
size
();
i
++)
{
int
s
=
pageOwners
.
get
(
i
);
out
.
writeInt
(
s
);
...
...
@@ -234,7 +234,7 @@ public class DiskFile implements CacheWriter {
}
}
for
(
int
i
=
0
;
i
<
storages
.
size
();
i
++)
{
Storage
storage
=
(
Storage
)
storages
.
get
(
i
);
Storage
storage
=
storages
.
get
(
i
);
if
(
storage
!=
null
)
{
out
.
writeInt
(
i
);
out
.
writeInt
(
storage
.
getRecordCount
());
...
...
@@ -276,9 +276,9 @@ public class DiskFile implements CacheWriter {
public
void
initFromSummary
(
byte
[]
summary
)
{
synchronized
(
database
)
{
if
(
summary
==
null
||
summary
.
length
==
0
)
{
ObjectArray
list
=
database
.
getAllStorages
();
ObjectArray
<
Storage
>
list
=
database
.
getAllStorages
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Storage
s
=
(
Storage
)
list
.
get
(
i
);
Storage
s
=
list
.
get
(
i
);
if
(
s
!=
null
&&
s
.
getDiskFile
()
==
this
)
{
database
.
removeStorage
(
s
.
getId
(),
this
);
}
...
...
@@ -318,7 +318,7 @@ public class DiskFile implements CacheWriter {
}
stage
++;
int
len
=
in
.
readInt
();
ObjectArray
storages
=
ObjectArray
.
newInstance
();
ObjectArray
<
Storage
>
storages
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
s
=
in
.
readInt
();
while
(
storages
.
size
()
<=
s
)
{
...
...
@@ -345,7 +345,7 @@ public class DiskFile implements CacheWriter {
break
;
}
int
recordCount
=
in
.
readInt
();
Storage
storage
=
(
Storage
)
storages
.
get
(
s
);
Storage
storage
=
storages
.
get
(
s
);
if
(
init
)
{
if
(
storage
!=
null
)
{
int
current
=
storage
.
getRecordCount
();
...
...
@@ -376,9 +376,9 @@ public class DiskFile implements CacheWriter {
if
(
init
)
{
return
;
}
ObjectArray
storages
=
database
.
getAllStorages
();
ObjectArray
<
Storage
>
storages
=
database
.
getAllStorages
();
for
(
int
i
=
0
;
i
<
storages
.
size
();
i
++)
{
Storage
s
=
(
Storage
)
storages
.
get
(
i
);
Storage
s
=
storages
.
get
(
i
);
if
(
s
!=
null
&&
s
.
getDiskFile
()
==
this
)
{
s
.
setRecordCount
(
0
);
}
...
...
@@ -426,7 +426,7 @@ public class DiskFile implements CacheWriter {
public
void
flush
()
throws
SQLException
{
synchronized
(
database
)
{
database
.
checkPowerOff
();
ObjectArray
list
=
cache
.
getAllChanged
();
ObjectArray
<
CacheObject
>
list
=
cache
.
getAllChanged
();
CacheObject
.
sort
(
list
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Record
rec
=
(
Record
)
list
.
get
(
i
);
...
...
@@ -1072,7 +1072,7 @@ public class DiskFile implements CacheWriter {
int
storageId
=
storage
.
getId
();
// make sure the cache records of this storage are not flushed to disk
// afterwards
ObjectArray
list
=
cache
.
getAllChanged
();
ObjectArray
<
CacheObject
>
list
=
cache
.
getAllChanged
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Record
r
=
(
Record
)
list
.
get
(
i
);
if
(
r
.
getStorageId
()
==
storageId
)
{
...
...
@@ -1206,7 +1206,7 @@ public class DiskFile implements CacheWriter {
// needs to be written in this order and not (A) (C) (B)
RedoLogRecord
last
=
null
;
for
(
int
i
=
0
;
i
<
redoBuffer
.
size
();
i
++)
{
RedoLogRecord
entry
=
(
RedoLogRecord
)
redoBuffer
.
get
(
i
);
RedoLogRecord
entry
=
redoBuffer
.
get
(
i
);
if
(
entry
.
data
!=
null
)
{
continue
;
}
...
...
@@ -1221,7 +1221,7 @@ public class DiskFile implements CacheWriter {
// now write the last entry, skipping deleted entries
last
=
null
;
for
(
int
i
=
0
;
i
<
redoBuffer
.
size
();
i
++)
{
RedoLogRecord
entry
=
(
RedoLogRecord
)
redoBuffer
.
get
(
i
);
RedoLogRecord
entry
=
redoBuffer
.
get
(
i
);
if
(
last
!=
null
&&
entry
.
recordId
!=
last
.
recordId
)
{
if
(
last
.
data
!=
null
)
{
writeRedoLog
(
last
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
16a375cc
...
...
@@ -10,7 +10,6 @@ import java.io.IOException;
import
java.io.OutputStream
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
...
...
@@ -22,7 +21,6 @@ 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
;
...
...
@@ -34,8 +32,8 @@ import org.h2.util.CacheLRU;
import
org.h2.util.CacheObject
;
import
org.h2.util.CacheWriter
;
import
org.h2.util.FileUtils
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.ObjectUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
...
...
@@ -139,7 +137,7 @@ public class PageStore implements CacheWriter {
private
int
activeLog
;
private
int
[]
logRootPageIds
=
new
int
[
LOG_COUNT
];
private
boolean
recoveryRunning
;
private
HashMap
sessionStates
=
new
H
ashMap
();
private
HashMap
<
Integer
,
SessionState
>
sessionStates
=
New
.
h
ashMap
();
/**
* The file size in bytes.
...
...
@@ -159,7 +157,7 @@ public class PageStore implements CacheWriter {
private
Schema
metaSchema
;
private
TableData
metaTable
;
private
PageScanIndex
metaIndex
;
private
HashMap
metaObjects
;
private
HashMap
<
Integer
,
Index
>
metaObjects
;
private
int
systemTableHeadPos
;
/**
...
...
@@ -265,10 +263,10 @@ public class PageStore implements CacheWriter {
}
synchronized
(
database
)
{
database
.
checkPowerOff
();
ObjectArray
list
=
cache
.
getAllChanged
();
ObjectArray
<
CacheObject
>
list
=
cache
.
getAllChanged
();
CacheObject
.
sort
(
list
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Record
rec
=
(
Record
)
list
.
get
(
i
);
CacheObject
rec
=
list
.
get
(
i
);
writeBack
(
rec
);
}
int
todoFlushBeforeReopen
;
...
...
@@ -671,7 +669,7 @@ public class PageStore implements CacheWriter {
if
(!
undo
)
{
switchLogIfPossible
();
int
todoProbablyStillRequiredForTwoPhaseCommit
;
sessionStates
=
new
H
ashMap
();
sessionStates
=
New
.
h
ashMap
();
}
}
catch
(
SQLException
e
)
{
int
test
;
...
...
@@ -685,14 +683,13 @@ public class PageStore implements CacheWriter {
recoveryRunning
=
false
;
}
if
(!
undo
)
{
PageScanIndex
index
=
(
PageScanIndex
)
metaObjects
.
get
(
ObjectUtils
.
getInteger
(
0
)
);
PageScanIndex
index
=
(
PageScanIndex
)
metaObjects
.
get
(
0
);
if
(
index
==
null
)
{
systemTableHeadPos
=
Index
.
EMPTY_HEAD
;
}
else
{
systemTableHeadPos
=
index
.
getHeadPos
();
}
for
(
Iterator
it
=
metaObjects
.
values
().
iterator
();
it
.
hasNext
();)
{
Index
openIndex
=
(
Index
)
it
.
next
();
for
(
Index
openIndex
:
metaObjects
.
values
())
{
openIndex
.
close
(
database
.
getSystemSession
());
}
metaObjects
=
null
;
...
...
@@ -731,8 +728,8 @@ public class PageStore implements CacheWriter {
* @return the session state object
*/
private
SessionState
getOrAddSessionState
(
int
sessionId
)
{
Integer
key
=
ObjectUtils
.
getInteger
(
sessionId
)
;
SessionState
state
=
(
SessionState
)
sessionStates
.
get
(
key
);
Integer
key
=
sessionId
;
SessionState
state
=
sessionStates
.
get
(
key
);
if
(
state
==
null
)
{
state
=
new
SessionState
();
sessionStates
.
put
(
key
,
state
);
...
...
@@ -764,8 +761,7 @@ public class PageStore implements CacheWriter {
* @return true if this session contains an uncommitted transaction
*/
boolean
isSessionCommitted
(
int
sessionId
,
int
logId
,
int
pos
)
{
Integer
key
=
ObjectUtils
.
getInteger
(
sessionId
);
SessionState
state
=
(
SessionState
)
sessionStates
.
get
(
key
);
SessionState
state
=
sessionStates
.
get
(
sessionId
);
if
(
state
==
null
)
{
return
true
;
}
...
...
@@ -777,7 +773,7 @@ public class PageStore implements CacheWriter {
*
* @return the system table head
*/
public
int
getSystemTableHeadPos
()
throws
SQLException
{
public
int
getSystemTableHeadPos
()
{
return
systemTableHeadPos
;
}
...
...
@@ -796,7 +792,7 @@ public class PageStore implements CacheWriter {
removeMeta
(
row
);
}
}
PageScanIndex
index
=
(
PageScanIndex
)
metaObjects
.
get
(
ObjectUtils
.
getInteger
(
tableId
)
);
PageScanIndex
index
=
(
PageScanIndex
)
metaObjects
.
get
(
tableId
);
if
(
index
==
null
)
{
throw
Message
.
throwInternalError
(
"Table not found: "
+
tableId
+
" "
+
row
+
" "
+
add
);
}
...
...
@@ -809,7 +805,7 @@ public class PageStore implements CacheWriter {
}
private
void
openMetaIndex
()
throws
SQLException
{
ObjectArray
cols
=
ObjectArray
.
newInstance
();
ObjectArray
<
Column
>
cols
=
ObjectArray
.
newInstance
();
cols
.
add
(
new
Column
(
"ID"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"TYPE"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"PARENT"
,
Value
.
INT
));
...
...
@@ -822,8 +818,8 @@ public class PageStore implements CacheWriter {
META_TABLE_ID
,
cols
,
true
,
true
,
false
,
headPos
,
database
.
getSystemSession
());
metaIndex
=
(
PageScanIndex
)
metaTable
.
getScanIndex
(
database
.
getSystemSession
());
metaObjects
=
new
H
ashMap
();
metaObjects
.
put
(
ObjectUtils
.
getInteger
(-
1
)
,
metaIndex
);
metaObjects
=
New
.
h
ashMap
();
metaObjects
.
put
(
-
1
,
metaIndex
);
}
private
void
readMetaData
()
throws
SQLException
{
...
...
@@ -836,7 +832,7 @@ public class PageStore implements CacheWriter {
private
void
removeMeta
(
Row
row
)
throws
SQLException
{
int
id
=
row
.
getValue
(
0
).
getInt
();
Index
index
=
(
Index
)
metaObjects
.
remove
(
ObjectUtils
.
getInteger
(
id
)
);
Index
index
=
metaObjects
.
remove
(
id
);
index
.
getTable
().
removeIndex
(
index
);
if
(
index
instanceof
PageBtreeIndex
)
{
index
.
getSchema
().
remove
(
index
);
...
...
@@ -856,7 +852,7 @@ public class PageStore implements CacheWriter {
trace
.
debug
(
"addMeta id="
+
id
+
" type="
+
type
+
" parent="
+
parent
+
" columns="
+
columnList
);
}
if
(
type
==
META_TYPE_SCAN_INDEX
)
{
ObjectArray
columnArray
=
ObjectArray
.
newInstance
();
ObjectArray
<
Column
>
columnArray
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
col
=
new
Column
(
"C"
+
i
,
Value
.
INT
);
columnArray
.
add
(
col
);
...
...
@@ -864,7 +860,7 @@ public class PageStore implements CacheWriter {
TableData
table
=
new
TableData
(
metaSchema
,
"T"
+
id
,
id
,
columnArray
,
true
,
true
,
false
,
headPos
,
session
);
meta
=
table
.
getScanIndex
(
session
);
}
else
{
PageScanIndex
p
=
(
PageScanIndex
)
metaObjects
.
get
(
ObjectUtils
.
getInteger
(
parent
)
);
PageScanIndex
p
=
(
PageScanIndex
)
metaObjects
.
get
(
parent
);
if
(
p
==
null
)
{
throw
Message
.
throwInternalError
(
"parent not found:"
+
parent
);
}
...
...
@@ -877,7 +873,7 @@ public class PageStore implements CacheWriter {
IndexColumn
[]
indexColumns
=
IndexColumn
.
wrap
(
cols
);
meta
=
table
.
addIndex
(
session
,
"I"
+
id
,
id
,
indexColumns
,
indexType
,
headPos
,
null
);
}
metaObjects
.
put
(
ObjectUtils
.
getInteger
(
id
)
,
meta
);
metaObjects
.
put
(
id
,
meta
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileSystemMemory.java
浏览文件 @
16a375cc
...
...
@@ -97,7 +97,7 @@ public class FileSystemMemory extends FileSystem {
}
public
String
[]
listFiles
(
String
path
)
{
ObjectArray
list
=
ObjectArray
.
newInstance
();
ObjectArray
<
String
>
list
=
ObjectArray
.
newInstance
();
synchronized
(
MEMORY_FILES
)
{
for
(
String
name
:
MEMORY_FILES
.
keySet
())
{
if
(
name
.
startsWith
(
path
))
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/FunctionTable.java
浏览文件 @
16a375cc
...
...
@@ -124,7 +124,7 @@ public class FunctionTable extends Table {
return
new
FunctionIndex
(
this
,
IndexColumn
.
wrap
(
columns
));
}
public
ObjectArray
getIndexes
()
{
public
ObjectArray
<
Index
>
getIndexes
()
{
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
16a375cc
差异被折叠。
点击展开。
h2/src/main/org/h2/table/Plan.java
浏览文件 @
16a375cc
...
...
@@ -36,8 +36,8 @@ public class Plan {
public
Plan
(
TableFilter
[]
filters
,
int
count
,
Expression
condition
)
{
this
.
filters
=
new
TableFilter
[
count
];
ObjectUtils
.
arrayCopy
(
filters
,
this
.
filters
,
count
);
ObjectArray
allCond
=
ObjectArray
.
newInstance
();
ObjectArray
all
=
ObjectArray
.
newInstance
();
ObjectArray
<
Expression
>
allCond
=
ObjectArray
.
newInstance
();
ObjectArray
<
TableFilter
>
all
=
ObjectArray
.
newInstance
();
if
(
condition
!=
null
)
{
allCond
.
add
(
condition
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/RangeTable.java
浏览文件 @
16a375cc
...
...
@@ -148,7 +148,7 @@ public class RangeTable extends Table {
}
}
public
ObjectArray
getIndexes
()
{
public
ObjectArray
<
Index
>
getIndexes
()
{
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Table.java
浏览文件 @
16a375cc
差异被折叠。
点击展开。
h2/src/main/org/h2/table/TableData.java
浏览文件 @
16a375cc
...
...
@@ -34,6 +34,7 @@ import org.h2.message.Message;
import
org.h2.message.Trace
;
import
org.h2.result.Row
;
import
org.h2.schema.Schema
;
import
org.h2.schema.SchemaObject
;
import
org.h2.store.DataPage
;
import
org.h2.store.Record
;
import
org.h2.store.RecordReader
;
...
...
@@ -57,11 +58,11 @@ public class TableData extends Table implements RecordReader {
private
HashSet
<
Session
>
lockShared
=
New
.
hashSet
();
private
Trace
traceLock
;
private
boolean
globalTemporary
;
private
final
ObjectArray
indexes
=
ObjectArray
.
newInstance
();
private
final
ObjectArray
<
Index
>
indexes
=
ObjectArray
.
newInstance
();
private
long
lastModificationId
;
private
boolean
containsLargeObject
;
public
TableData
(
Schema
schema
,
String
tableName
,
int
id
,
ObjectArray
columns
,
public
TableData
(
Schema
schema
,
String
tableName
,
int
id
,
ObjectArray
<
Column
>
columns
,
boolean
persistIndexes
,
boolean
persistData
,
boolean
clustered
,
int
headPos
,
Session
session
)
throws
SQLException
{
super
(
schema
,
id
,
tableName
,
persistIndexes
,
persistData
);
Column
[]
cols
=
new
Column
[
columns
.
size
()];
...
...
@@ -91,7 +92,7 @@ public class TableData extends Table implements RecordReader {
public
void
close
(
Session
session
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
index
=
(
Index
)
indexes
.
get
(
i
);
Index
index
=
indexes
.
get
(
i
);
index
.
close
(
session
);
}
}
...
...
@@ -115,7 +116,7 @@ public class TableData extends Table implements RecordReader {
}
try
{
for
(;
i
<
indexes
.
size
();
i
++)
{
Index
index
=
(
Index
)
indexes
.
get
(
i
);
Index
index
=
indexes
.
get
(
i
);
index
.
add
(
session
,
row
);
checkRowCount
(
session
,
index
,
1
);
}
...
...
@@ -123,7 +124,7 @@ public class TableData extends Table implements RecordReader {
}
catch
(
Throwable
e
)
{
try
{
while
(--
i
>=
0
)
{
Index
index
=
(
Index
)
indexes
.
get
(
i
);
Index
index
=
indexes
.
get
(
i
);
index
.
remove
(
session
,
row
);
checkRowCount
(
session
,
index
,
0
);
}
...
...
@@ -148,12 +149,12 @@ public class TableData extends Table implements RecordReader {
}
public
Index
getScanIndex
(
Session
session
)
{
return
(
Index
)
indexes
.
get
(
0
);
return
indexes
.
get
(
0
);
}
public
Index
getUniqueIndex
()
{
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
idx
=
(
Index
)
indexes
.
get
(
i
);
Index
idx
=
indexes
.
get
(
i
);
if
(
idx
.
getIndexType
().
getUnique
())
{
return
idx
;
}
...
...
@@ -161,7 +162,7 @@ public class TableData extends Table implements RecordReader {
return
null
;
}
public
ObjectArray
getIndexes
()
{
public
ObjectArray
<
Index
>
getIndexes
()
{
return
indexes
;
}
...
...
@@ -201,7 +202,7 @@ public class TableData extends Table implements RecordReader {
Cursor
cursor
=
scan
.
find
(
session
,
null
,
null
);
long
i
=
0
;
int
bufferSize
=
Constants
.
DEFAULT_MAX_MEMORY_ROWS
;
ObjectArray
buffer
=
ObjectArray
.
newInstance
(
bufferSize
);
ObjectArray
<
Row
>
buffer
=
ObjectArray
.
newInstance
(
bufferSize
);
while
(
cursor
.
next
())
{
database
.
setProgress
(
DatabaseEventListener
.
STATE_CREATE_INDEX
,
getName
()
+
":"
+
index
.
getName
(),
MathUtils
.
convertLongToInt
(
i
++),
MathUtils
.
convertLongToInt
(
total
));
...
...
@@ -262,7 +263,7 @@ public class TableData extends Table implements RecordReader {
return
true
;
}
private
void
addRowsToIndex
(
Session
session
,
ObjectArray
list
,
Index
index
)
throws
SQLException
{
private
void
addRowsToIndex
(
Session
session
,
ObjectArray
<
Row
>
list
,
Index
index
)
throws
SQLException
{
final
Index
idx
=
index
;
try
{
list
.
sort
(
new
Comparator
<
Row
>()
{
...
...
@@ -278,7 +279,7 @@ public class TableData extends Table implements RecordReader {
throw
Message
.
convert
(
e
);
}
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Row
row
=
(
Row
)
list
.
get
(
i
);
Row
row
=
list
.
get
(
i
);
index
.
add
(
session
,
row
);
}
list
.
clear
();
...
...
@@ -312,7 +313,7 @@ public class TableData extends Table implements RecordReader {
int
i
=
indexes
.
size
()
-
1
;
try
{
for
(;
i
>=
0
;
i
--)
{
Index
index
=
(
Index
)
indexes
.
get
(
i
);
Index
index
=
indexes
.
get
(
i
);
index
.
remove
(
session
,
row
);
checkRowCount
(
session
,
index
,
-
1
);
}
...
...
@@ -320,7 +321,7 @@ public class TableData extends Table implements RecordReader {
}
catch
(
Throwable
e
)
{
try
{
while
(++
i
<
indexes
.
size
())
{
Index
index
=
(
Index
)
indexes
.
get
(
i
);
Index
index
=
indexes
.
get
(
i
);
index
.
add
(
session
,
row
);
checkRowCount
(
session
,
index
,
0
);
}
...
...
@@ -338,7 +339,7 @@ public class TableData extends Table implements RecordReader {
public
void
truncate
(
Session
session
)
throws
SQLException
{
lastModificationId
=
database
.
getNextModificationDataId
();
for
(
int
i
=
indexes
.
size
()
-
1
;
i
>=
0
;
i
--)
{
Index
index
=
(
Index
)
indexes
.
get
(
i
);
Index
index
=
indexes
.
get
(
i
);
index
.
truncate
(
session
);
if
(
SysProperties
.
CHECK
)
{
long
rc
=
index
.
getRowCount
(
session
);
...
...
@@ -421,7 +422,7 @@ public class TableData extends Table implements RecordReader {
}
session
.
setWaitForLock
(
this
);
if
(
checkDeadlock
)
{
ObjectArray
sessions
=
checkDeadlock
(
session
,
null
,
null
);
ObjectArray
<
Session
>
sessions
=
checkDeadlock
(
session
,
null
,
null
);
if
(
sessions
!=
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
DEADLOCK_1
,
getDeadlockDetails
(
sessions
));
}
...
...
@@ -458,11 +459,11 @@ public class TableData extends Table implements RecordReader {
}
}
private
String
getDeadlockDetails
(
ObjectArray
sessions
)
{
private
String
getDeadlockDetails
(
ObjectArray
<
Session
>
sessions
)
{
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
sessions
.
size
();
i
++)
{
buff
.
append
(
'\n'
);
Session
s
=
(
Session
)
sessions
.
get
(
i
);
Session
s
=
sessions
.
get
(
i
);
Table
lock
=
s
.
getWaitForLock
();
buff
.
append
(
"Session "
).
append
(
s
).
append
(
" is waiting to lock "
).
append
(
lock
);
buff
.
append
(
" while locking "
);
...
...
@@ -486,7 +487,7 @@ public class TableData extends Table implements RecordReader {
return
buff
.
toString
();
}
public
ObjectArray
checkDeadlock
(
Session
session
,
Session
clash
,
Set
<
Session
>
visited
)
{
public
ObjectArray
<
Session
>
checkDeadlock
(
Session
session
,
Session
clash
,
Set
<
Session
>
visited
)
{
// only one deadlock check at any given time
synchronized
(
TableData
.
class
)
{
if
(
clash
==
null
)
{
...
...
@@ -503,7 +504,7 @@ public class TableData extends Table implements RecordReader {
return
null
;
}
visited
.
add
(
session
);
ObjectArray
error
=
null
;
ObjectArray
<
Session
>
error
=
null
;
for
(
Session
s
:
lockShared
)
{
if
(
s
==
session
)
{
// it doesn't matter if we have locked the object already
...
...
@@ -633,13 +634,13 @@ public class TableData extends Table implements RecordReader {
super
.
removeChildrenAndResources
(
session
);
// go backwards because database.removeIndex will call table.removeIndex
while
(
indexes
.
size
()
>
1
)
{
Index
index
=
(
Index
)
indexes
.
get
(
1
);
Index
index
=
indexes
.
get
(
1
);
if
(
index
.
getName
()
!=
null
)
{
database
.
removeSchemaObject
(
session
,
index
);
}
}
if
(
SysProperties
.
CHECK
)
{
ObjectArray
list
=
database
.
getAllSchemaObjects
(
DbObject
.
INDEX
);
ObjectArray
<
SchemaObject
>
list
=
database
.
getAllSchemaObjects
(
DbObject
.
INDEX
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Index
index
=
(
Index
)
list
.
get
(
i
);
if
(
index
.
getTable
()
==
this
)
{
...
...
@@ -668,9 +669,9 @@ public class TableData extends Table implements RecordReader {
}
public
boolean
canTruncate
()
{
ObjectArray
constraints
=
getConstraints
();
ObjectArray
<
Constraint
>
constraints
=
getConstraints
();
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
c
=
(
Constraint
)
constraints
.
get
(
i
);
Constraint
c
=
constraints
.
get
(
i
);
if
(!(
c
.
getConstraintType
().
equals
(
Constraint
.
REFERENTIAL
)))
{
continue
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
16a375cc
...
...
@@ -49,7 +49,7 @@ public class TableFilter implements ColumnResolver {
private
boolean
used
;
// conditions that can be used for direct index lookup (start or end)
private
final
ObjectArray
indexConditions
=
ObjectArray
.
newInstance
();
private
final
ObjectArray
<
IndexCondition
>
indexConditions
=
ObjectArray
.
newInstance
();
// conditions that can't be used for index lookup,
// but for row filter for this table (ID=ID, NAME LIKE '%X%')
...
...
@@ -64,7 +64,7 @@ public class TableFilter implements ColumnResolver {
private
TableFilter
join
;
private
boolean
outerJoin
;
private
ObjectArray
naturalJoinColumns
;
private
ObjectArray
<
Column
>
naturalJoinColumns
;
private
boolean
foundOne
;
private
Expression
fullCondition
;
private
final
int
hashCode
;
...
...
@@ -128,7 +128,7 @@ public class TableFilter implements ColumnResolver {
int
len
=
table
.
getColumns
().
length
;
int
[]
masks
=
new
int
[
len
];
for
(
int
i
=
0
;
i
<
indexConditions
.
size
();
i
++)
{
IndexCondition
condition
=
(
IndexCondition
)
indexConditions
.
get
(
i
);
IndexCondition
condition
=
indexConditions
.
get
(
i
);
if
(
condition
.
isEvaluatable
())
{
if
(
condition
.
isAlwaysFalse
())
{
masks
=
null
;
...
...
@@ -182,7 +182,7 @@ public class TableFilter implements ColumnResolver {
public
void
prepare
()
throws
SQLException
{
// forget all unused index conditions
for
(
int
i
=
0
;
i
<
indexConditions
.
size
();
i
++)
{
IndexCondition
condition
=
(
IndexCondition
)
indexConditions
.
get
(
i
);
IndexCondition
condition
=
indexConditions
.
get
(
i
);
if
(!
condition
.
isAlwaysFalse
())
{
Column
col
=
condition
.
getColumn
();
if
(
index
.
getColumnIndex
(
col
)
<
0
)
{
...
...
@@ -254,7 +254,7 @@ public class TableFilter implements ColumnResolver {
}
else
if
(
state
==
BEFORE_FIRST
)
{
SearchRow
start
=
null
,
end
=
null
;
for
(
int
i
=
0
;
i
<
indexConditions
.
size
();
i
++)
{
IndexCondition
condition
=
(
IndexCondition
)
indexConditions
.
get
(
i
);
IndexCondition
condition
=
indexConditions
.
get
(
i
);
if
(
condition
.
isAlwaysFalse
())
{
alwaysFalse
=
true
;
break
;
...
...
@@ -525,7 +525,7 @@ public class TableFilter implements ColumnResolver {
if
(
indexConditions
.
size
()
>
0
)
{
planBuff
.
append
(
": "
);
for
(
int
i
=
0
;
i
<
indexConditions
.
size
();
i
++)
{
IndexCondition
condition
=
(
IndexCondition
)
indexConditions
.
get
(
i
);
IndexCondition
condition
=
indexConditions
.
get
(
i
);
if
(
i
>
0
)
{
planBuff
.
append
(
" AND "
);
}
...
...
@@ -561,7 +561,7 @@ public class TableFilter implements ColumnResolver {
*/
void
removeUnusableIndexConditions
()
{
for
(
int
i
=
0
;
i
<
indexConditions
.
size
();
i
++)
{
IndexCondition
cond
=
(
IndexCondition
)
indexConditions
.
get
(
i
);
IndexCondition
cond
=
indexConditions
.
get
(
i
);
if
(!
cond
.
isEvaluatable
())
{
indexConditions
.
remove
(
i
--);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
16a375cc
...
...
@@ -48,7 +48,7 @@ public class TableLink extends Table {
private
String
driver
,
url
,
user
,
password
,
originalSchema
,
originalTable
,
qualifiedTableName
;
private
TableLinkConnection
conn
;
private
HashMap
<
String
,
PreparedStatement
>
prepared
=
New
.
hashMap
();
private
final
ObjectArray
indexes
=
ObjectArray
.
newInstance
();
private
final
ObjectArray
<
Index
>
indexes
=
ObjectArray
.
newInstance
();
private
final
boolean
emitUpdates
;
private
LinkedIndex
linkedIndex
;
private
SQLException
connectException
;
...
...
@@ -107,7 +107,7 @@ public class TableLink extends Table {
rs
.
close
();
rs
=
meta
.
getColumns
(
null
,
originalSchema
,
originalTable
,
null
);
int
i
=
0
;
ObjectArray
columnList
=
ObjectArray
.
newInstance
();
ObjectArray
<
Column
>
columnList
=
ObjectArray
.
newInstance
();
HashMap
<
String
,
Column
>
columnMap
=
New
.
hashMap
();
String
catalog
=
null
,
schema
=
null
;
while
(
rs
.
next
())
{
...
...
@@ -190,7 +190,7 @@ public class TableLink extends Table {
rs
=
null
;
}
String
pkName
=
""
;
ObjectArray
list
;
ObjectArray
<
Column
>
list
;
if
(
rs
!=
null
&&
rs
.
next
())
{
// the problem is, the rows are not sorted by KEY_SEQ
list
=
ObjectArray
.
newInstance
();
...
...
@@ -284,7 +284,7 @@ public class TableLink extends Table {
return
columnName
;
}
private
void
addIndex
(
ObjectArray
list
,
IndexType
indexType
)
{
private
void
addIndex
(
ObjectArray
<
Column
>
list
,
IndexType
indexType
)
{
Column
[]
cols
=
new
Column
[
list
.
size
()];
list
.
toArray
(
cols
);
Index
index
=
new
LinkedIndex
(
this
,
0
,
IndexColumn
.
wrap
(
cols
),
indexType
);
...
...
@@ -472,7 +472,7 @@ public class TableLink extends Table {
return
url
.
startsWith
(
"jdbc:oracle:"
);
}
public
ObjectArray
getIndexes
()
{
public
ObjectArray
<
Index
>
getIndexes
()
{
return
indexes
;
}
...
...
@@ -483,7 +483,7 @@ public class TableLink extends Table {
public
Index
getUniqueIndex
()
{
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
idx
=
(
Index
)
indexes
.
get
(
i
);
Index
idx
=
indexes
.
get
(
i
);
if
(
idx
.
getIndexType
().
getUnique
())
{
return
idx
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableView.java
浏览文件 @
16a375cc
...
...
@@ -14,6 +14,7 @@ import org.h2.engine.Constants;
import
org.h2.engine.Session
;
import
org.h2.engine.User
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Parameter
;
import
org.h2.index.Index
;
import
org.h2.index.IndexType
;
import
org.h2.index.ViewIndex
;
...
...
@@ -34,7 +35,7 @@ public class TableView extends Table {
private
static
final
long
ROW_COUNT_APPROXIMATION
=
100
;
private
String
querySQL
;
private
ObjectArray
tables
;
private
ObjectArray
<
Table
>
tables
;
private
final
String
[]
columnNames
;
private
Query
viewQuery
;
private
ViewIndex
index
;
...
...
@@ -46,7 +47,7 @@ public class TableView extends Table {
private
User
owner
;
private
Query
topQuery
;
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
<
Parameter
>
params
,
String
[]
columnNames
,
Session
session
,
boolean
recursive
)
throws
SQLException
{
super
(
schema
,
id
,
name
,
false
,
true
);
this
.
querySQL
=
querySQL
;
...
...
@@ -78,10 +79,10 @@ public class TableView extends Table {
try
{
Query
query
=
recompileQuery
(
session
);
tables
=
ObjectArray
.
newInstance
(
query
.
getTables
());
ObjectArray
expressions
=
query
.
getExpressions
();
ObjectArray
list
=
ObjectArray
.
newInstance
();
ObjectArray
<
Expression
>
expressions
=
query
.
getExpressions
();
ObjectArray
<
Column
>
list
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
query
.
getColumnCount
();
i
++)
{
Expression
expr
=
(
Expression
)
expressions
.
get
(
i
);
Expression
expr
=
expressions
.
get
(
i
);
String
name
=
null
;
if
(
columnNames
!=
null
&&
columnNames
.
length
>
i
)
{
name
=
columnNames
[
i
];
...
...
@@ -270,7 +271,7 @@ public class TableView extends Table {
return
item
.
getIndex
();
}
public
ObjectArray
getIndexes
()
{
public
ObjectArray
<
Index
>
getIndexes
()
{
return
null
;
}
...
...
@@ -281,7 +282,7 @@ public class TableView extends Table {
*/
public
void
recompile
(
Session
session
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
(
Table
)
tables
.
get
(
i
);
Table
t
=
tables
.
get
(
i
);
t
.
removeView
(
this
);
}
tables
.
clear
();
...
...
@@ -313,7 +314,7 @@ public class TableView extends Table {
private
void
removeViewFromTables
()
{
if
(
tables
!=
null
)
{
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
(
Table
)
tables
.
get
(
i
);
Table
t
=
tables
.
get
(
i
);
t
.
removeView
(
this
);
}
tables
.
clear
();
...
...
@@ -322,7 +323,7 @@ public class TableView extends Table {
private
void
addViewToTables
()
{
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
(
Table
)
tables
.
get
(
i
);
Table
t
=
tables
.
get
(
i
);
t
.
addView
(
this
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
16a375cc
...
...
@@ -69,7 +69,7 @@ public class Recover extends Tool implements DataHandler {
private
int
valueId
;
private
boolean
trace
;
private
boolean
lobFilesInDirectories
;
private
ObjectArray
schema
;
private
ObjectArray
<
MetaRecord
>
schema
;
private
HashSet
<
Integer
>
objectIdSet
;
private
HashMap
<
Integer
,
String
>
tableMap
;
private
boolean
remove
;
...
...
@@ -1206,7 +1206,7 @@ public class Recover extends Tool implements DataHandler {
private
void
writeSchema
(
PrintWriter
writer
)
{
MetaRecord
.
sort
(
schema
);
for
(
int
i
=
0
;
i
<
schema
.
size
();
i
++)
{
MetaRecord
m
=
(
MetaRecord
)
schema
.
get
(
i
);
MetaRecord
m
=
schema
.
get
(
i
);
writer
.
println
(
m
.
getSQL
()
+
";"
);
}
for
(
Map
.
Entry
<
Integer
,
String
>
entry
:
tableMap
.
entrySet
())
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/Cache.java
浏览文件 @
16a375cc
...
...
@@ -18,7 +18,7 @@ public interface Cache {
*
* @return the list of objects
*/
ObjectArray
getAllChanged
();
ObjectArray
<
CacheObject
>
getAllChanged
();
/**
* Clear the cache.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/CacheLRU.java
浏览文件 @
16a375cc
...
...
@@ -126,7 +126,7 @@ public class CacheLRU implements Cache {
private
void
removeOld
()
throws
SQLException
{
int
i
=
0
;
ObjectArray
changed
=
ObjectArray
.
newInstance
();
ObjectArray
<
CacheObject
>
changed
=
ObjectArray
.
newInstance
();
while
(
sizeMemory
*
4
>
maxSize
*
3
&&
recordCount
>
Constants
.
CACHE_MIN_RECORDS
)
{
i
++;
if
(
i
==
recordCount
)
{
...
...
@@ -159,7 +159,7 @@ public class CacheLRU implements Cache {
if
(
changed
.
size
()
>
0
)
{
CacheObject
.
sort
(
changed
);
for
(
i
=
0
;
i
<
changed
.
size
();
i
++)
{
CacheObject
rec
=
(
CacheObject
)
changed
.
get
(
i
);
CacheObject
rec
=
changed
.
get
(
i
);
writer
.
writeBack
(
rec
);
}
}
...
...
@@ -263,12 +263,12 @@ public class CacheLRU implements Cache {
// }
// }
public
ObjectArray
getAllChanged
()
{
public
ObjectArray
<
CacheObject
>
getAllChanged
()
{
// if(Database.CHECK) {
// testConsistency();
// }
// TODO cache: should probably use the LRU list
ObjectArray
list
=
ObjectArray
.
newInstance
();
ObjectArray
<
CacheObject
>
list
=
ObjectArray
.
newInstance
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
CacheObject
rec
=
values
[
i
];
while
(
rec
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/CacheObject.java
浏览文件 @
16a375cc
...
...
@@ -81,7 +81,7 @@ public abstract class CacheObject {
*
* @param recordList the list of cache objects
*/
public
static
void
sort
(
ObjectArray
recordList
)
{
public
static
void
sort
(
ObjectArray
<
CacheObject
>
recordList
)
{
recordList
.
sort
(
new
CacheComparator
());
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/CacheSecondLevel.java
浏览文件 @
16a375cc
...
...
@@ -46,7 +46,7 @@ class CacheSecondLevel implements Cache {
return
ret
;
}
public
ObjectArray
getAllChanged
()
{
public
ObjectArray
<
CacheObject
>
getAllChanged
()
{
return
baseCache
.
getAllChanged
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/CacheTQ.java
浏览文件 @
16a375cc
...
...
@@ -168,7 +168,7 @@ class CacheTQ implements Cache {
private
void
removeOld
()
throws
SQLException
{
int
i
=
0
;
ObjectArray
changed
=
ObjectArray
.
newInstance
();
ObjectArray
<
CacheObject
>
changed
=
ObjectArray
.
newInstance
();
while
(((
sizeIn
*
4
>
maxIn
*
3
)
||
(
sizeOut
*
4
>
maxOut
*
3
)
||
(
sizeMain
*
4
>
maxMain
*
3
))
&&
recordCount
>
Constants
.
CACHE_MIN_RECORDS
)
{
i
++;
...
...
@@ -226,14 +226,14 @@ class CacheTQ implements Cache {
if
(
changed
.
size
()
>
0
)
{
CacheObject
.
sort
(
changed
);
for
(
i
=
0
;
i
<
changed
.
size
();
i
++)
{
CacheObject
rec
=
(
CacheObject
)
changed
.
get
(
i
);
CacheObject
rec
=
changed
.
get
(
i
);
writer
.
writeBack
(
rec
);
}
}
}
public
ObjectArray
getAllChanged
()
{
ObjectArray
list
=
ObjectArray
.
newInstance
();
public
ObjectArray
<
CacheObject
>
getAllChanged
()
{
ObjectArray
<
CacheObject
>
list
=
ObjectArray
.
newInstance
();
for
(
CacheObject
o
=
headMain
.
next
;
o
!=
headMain
;
o
=
o
.
next
)
{
if
(
o
.
isChanged
())
{
list
.
add
(
o
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/ObjectArray.java
浏览文件 @
16a375cc
...
...
@@ -246,7 +246,7 @@ public class ObjectArray<T> {
*
* @param list the list
*/
public
void
addAll
(
ObjectArray
<
T
>
list
)
{
public
void
addAll
(
ObjectArray
<
?
extends
T
>
list
)
{
for
(
int
i
=
0
;
i
<
list
.
size
;
i
++)
{
add
(
list
.
data
[
i
]);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/ValueHashMap.java
浏览文件 @
16a375cc
...
...
@@ -166,8 +166,8 @@ public class ValueHashMap<V> extends HashBase {
*
* @return all keys
*/
public
ObjectArray
keys
()
{
ObjectArray
list
=
ObjectArray
.
newInstance
(
size
);
public
ObjectArray
<
Value
>
keys
()
{
ObjectArray
<
Value
>
list
=
ObjectArray
.
newInstance
(
size
);
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
Value
k
=
keys
[
i
];
if
(
k
!=
null
&&
k
!=
ValueNull
.
DELETED
)
{
...
...
@@ -182,8 +182,8 @@ public class ValueHashMap<V> extends HashBase {
*
* @return all values
*/
public
ObjectArray
values
()
{
ObjectArray
list
=
ObjectArray
.
newInstance
(
size
);
public
ObjectArray
<
V
>
values
()
{
ObjectArray
<
V
>
list
=
ObjectArray
.
newInstance
(
size
);
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
Value
k
=
keys
[
i
];
if
(
k
!=
null
&&
k
!=
ValueNull
.
DELETED
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestValueHashMap.java
浏览文件 @
16a375cc
...
...
@@ -89,24 +89,24 @@ public class TestValueHashMap extends TestBase implements DataHandler {
assertTrue
((
v1
==
null
&&
v2
==
null
)
||
v1
.
compareEqual
(
v2
));
break
;
case
3
:
{
ObjectArray
a1
=
map
.
keys
();
ObjectArray
a2
=
ObjectArray
.
newInstance
(
hash
.
keySet
());
ObjectArray
<
Value
>
a1
=
map
.
keys
();
ObjectArray
<
Value
>
a2
=
ObjectArray
.
newInstance
(
hash
.
keySet
());
assertEquals
(
a1
.
size
(),
a2
.
size
());
a1
.
sort
(
vc
);
a2
.
sort
(
vc
);
for
(
int
j
=
0
;
j
<
a1
.
size
();
j
++)
{
assertTrue
(
((
Value
)
a1
.
get
(
j
)).
compareEqual
((
Value
)
a2
.
get
(
j
)));
assertTrue
(
a1
.
get
(
j
).
compareEqual
(
a2
.
get
(
j
)));
}
break
;
}
case
4
:
ObjectArray
a1
=
map
.
values
();
ObjectArray
a2
=
ObjectArray
.
newInstance
(
hash
.
values
());
ObjectArray
<
Value
>
a1
=
map
.
values
();
ObjectArray
<
Value
>
a2
=
ObjectArray
.
newInstance
(
hash
.
values
());
assertEquals
(
a1
.
size
(),
a2
.
size
());
a1
.
sort
(
vc
);
a2
.
sort
(
vc
);
for
(
int
j
=
0
;
j
<
a1
.
size
();
j
++)
{
assertTrue
(
((
Value
)
a1
.
get
(
j
)).
compareEqual
((
Value
)
a2
.
get
(
j
)));
assertTrue
(
a1
.
get
(
j
).
compareEqual
(
a2
.
get
(
j
)));
}
break
;
default
:
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论