Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a4f95b2b
提交
a4f95b2b
authored
10月 14, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Smaller changes (mainly for Android).
上级
7692231b
隐藏空白字符变更
内嵌
并排
正在显示
35 个修改的文件
包含
192 行增加
和
98 行删除
+192
-98
CommandContainer.java
h2/src/main/org/h2/command/CommandContainer.java
+1
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+1
-1
Call.java
h2/src/main/org/h2/command/dml/Call.java
+1
-1
Query.java
h2/src/main/org/h2/command/dml/Query.java
+2
-2
Select.java
h2/src/main/org/h2/command/dml/Select.java
+15
-10
Database.java
h2/src/main/org/h2/engine/Database.java
+5
-2
Session.java
h2/src/main/org/h2/engine/Session.java
+5
-2
UndoLogRecord.java
h2/src/main/org/h2/engine/UndoLogRecord.java
+7
-3
Aggregate.java
h2/src/main/org/h2/expression/Aggregate.java
+7
-5
Expression.java
h2/src/main/org/h2/expression/Expression.java
+1
-1
ExpressionVisitor.java
h2/src/main/org/h2/expression/ExpressionVisitor.java
+39
-2
Function.java
h2/src/main/org/h2/expression/Function.java
+3
-2
FullText.java
h2/src/main/org/h2/fulltext/FullText.java
+6
-4
IndexCondition.java
h2/src/main/org/h2/index/IndexCondition.java
+3
-3
PageBtreeIndex.java
h2/src/main/org/h2/index/PageBtreeIndex.java
+1
-1
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+2
-2
ViewCursor.java
h2/src/main/org/h2/index/ViewCursor.java
+1
-1
JdbcPreparedStatement.java
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
+9
-6
JdbcStatement.java
h2/src/main/org/h2/jdbc/JdbcStatement.java
+3
-2
TraceSystem.java
h2/src/main/org/h2/message/TraceSystem.java
+3
-1
ResultDiskBuffer.java
h2/src/main/org/h2/result/ResultDiskBuffer.java
+1
-1
RowList.java
h2/src/main/org/h2/result/RowList.java
+3
-2
UpdatableRow.java
h2/src/main/org/h2/result/UpdatableRow.java
+1
-1
Schema.java
h2/src/main/org/h2/schema/Schema.java
+1
-1
PageFreeList.java
h2/src/main/org/h2/store/PageFreeList.java
+2
-1
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+3
-2
Plan.java
h2/src/main/org/h2/table/Plan.java
+1
-1
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+11
-9
Table.java
h2/src/main/org/h2/table/Table.java
+23
-17
TableView.java
h2/src/main/org/h2/table/TableView.java
+2
-2
Recover.java
h2/src/main/org/h2/tools/Recover.java
+1
-0
Shell.java
h2/src/main/org/h2/tools/Shell.java
+1
-1
SimpleResultSet.java
h2/src/main/org/h2/tools/SimpleResultSet.java
+5
-3
BitField.java
h2/src/main/org/h2/util/BitField.java
+9
-1
IntArray.java
h2/src/main/org/h2/util/IntArray.java
+13
-4
没有找到文件。
h2/src/main/org/h2/command/CommandContainer.java
浏览文件 @
a4f95b2b
...
...
@@ -49,7 +49,7 @@ public class CommandContainer extends Command {
long
mod
=
prepared
.
getModificationMetaId
();
prepared
.
setModificationMetaId
(
0
);
ArrayList
<
Parameter
>
newParams
=
prepared
.
getParameters
();
for
(
int
i
=
0
;
i
<
newParams
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
newParams
.
size
();
i
<
size
;
i
++)
{
Parameter
old
=
oldParams
.
get
(
i
);
if
(
old
.
isValueSet
())
{
Value
v
=
old
.
getValue
(
session
);
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
a4f95b2b
...
...
@@ -651,7 +651,7 @@ public class Parser {
read
(
")"
);
read
(
"="
);
Expression
expression
=
readExpression
();
for
(
int
i
=
0
;
i
<
columns
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
columns
.
size
();
i
<
size
;
i
++)
{
Column
column
=
columns
.
get
(
i
);
Function
f
=
Function
.
getFunction
(
database
,
"ARRAY_GET"
);
f
.
setParameter
(
0
,
expression
);
...
...
h2/src/main/org/h2/command/dml/Call.java
浏览文件 @
a4f95b2b
...
...
@@ -105,7 +105,7 @@ public class Call extends Prepared {
}
public
boolean
isReadOnly
()
{
return
expression
.
isEverything
(
ExpressionVisitor
.
READONLY
);
return
expression
.
isEverything
(
ExpressionVisitor
.
READONLY
_VISITOR
);
}
...
...
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
a4f95b2b
...
...
@@ -200,7 +200,7 @@ public abstract class Query extends Prepared {
return
false
;
}
}
if
(!
isEverything
(
ExpressionVisitor
.
DETERMINISTIC
)
||
!
isEverything
(
ExpressionVisitor
.
INDEPENDENT
))
{
if
(!
isEverything
(
ExpressionVisitor
.
DETERMINISTIC
_VISITOR
)
||
!
isEverything
(
ExpressionVisitor
.
INDEPENDENT_VISITOR
))
{
return
false
;
}
if
(
db
.
getModificationDataId
()
>
lastEval
&&
getMaxDataModificationId
()
>
lastEval
)
{
...
...
@@ -241,7 +241,7 @@ public abstract class Query extends Prepared {
}
Value
[]
params
=
getParameterValues
();
long
now
=
session
.
getDatabase
().
getModificationDataId
();
if
(
isEverything
(
ExpressionVisitor
.
DETERMINISTIC
))
{
if
(
isEverything
(
ExpressionVisitor
.
DETERMINISTIC
_VISITOR
))
{
if
(
lastResult
!=
null
&&
!
lastResult
.
isClosed
()
&&
limit
==
lastLimit
)
{
if
(
sameResultAsLast
(
session
,
params
,
lastParameters
,
lastEvaluated
))
{
lastResult
=
lastResult
.
createShallowCopy
(
session
);
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
a4f95b2b
...
...
@@ -874,7 +874,8 @@ public class Select extends Query {
}
public
void
fireBeforeSelectTriggers
()
{
for
(
TableFilter
filter
:
filters
)
{
for
(
int
i
=
0
,
size
=
filters
.
size
();
i
<
size
;
i
++)
{
TableFilter
filter
=
filters
.
get
(
i
);
filter
.
getTable
().
fire
(
session
,
Trigger
.
SELECT
,
true
);
}
}
...
...
@@ -908,7 +909,7 @@ public class Select extends Query {
}
Expression
on
=
f
.
getJoinCondition
();
if
(
on
!=
null
)
{
if
(!
on
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
))
{
if
(!
on
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
_VISITOR
))
{
if
(
SysProperties
.
NESTED_JOINS
)
{
f
.
removeJoinCondition
();
// need to check that all added are bound to a table
...
...
@@ -932,7 +933,7 @@ public class Select extends Query {
}
on
=
f
.
getFilterCondition
();
if
(
on
!=
null
)
{
if
(!
on
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
))
{
if
(!
on
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
_VISITOR
))
{
f
.
removeFilterCondition
();
addCondition
(
on
);
}
...
...
@@ -1105,7 +1106,7 @@ public class Select extends Query {
Expression
comp
;
Expression
col
=
expressions
.
get
(
columnId
);
col
=
col
.
getNonAliasExpression
();
if
(
col
.
isEverything
(
ExpressionVisitor
.
QUERY_COMPARABLE
))
{
if
(
col
.
isEverything
(
ExpressionVisitor
.
QUERY_COMPARABLE
_VISITOR
))
{
comp
=
new
Comparison
(
session
,
comparisonType
,
col
,
param
);
}
else
{
// add the parameters, so they can be set later
...
...
@@ -1159,7 +1160,8 @@ public class Select extends Query {
if
(
isForUpdate
)
{
return
false
;
}
for
(
TableFilter
f
:
filters
)
{
for
(
int
i
=
0
,
size
=
filters
.
size
();
i
<
size
;
i
++)
{
TableFilter
f
=
filters
.
get
(
i
);
if
(!
f
.
getTable
().
isDeterministic
())
{
return
false
;
}
...
...
@@ -1167,7 +1169,8 @@ public class Select extends Query {
break
;
}
case
ExpressionVisitor
.
SET_MAX_DATA_MODIFICATION_ID
:
{
for
(
TableFilter
f
:
filters
)
{
for
(
int
i
=
0
,
size
=
filters
.
size
();
i
<
size
;
i
++)
{
TableFilter
f
=
filters
.
get
(
i
);
long
m
=
f
.
getTable
().
getMaxDataModificationId
();
visitor
.
addDataModificationId
(
m
);
}
...
...
@@ -1180,8 +1183,9 @@ public class Select extends Query {
break
;
}
case
ExpressionVisitor
.
GET_DEPENDENCIES
:
{
for
(
TableFilter
filter
:
filters
)
{
Table
table
=
filter
.
getTable
();
for
(
int
i
=
0
,
size
=
filters
.
size
();
i
<
size
;
i
++)
{
TableFilter
f
=
filters
.
get
(
i
);
Table
table
=
f
.
getTable
();
visitor
.
addDependency
(
table
);
table
.
addDependencies
(
visitor
.
getDependencies
());
}
...
...
@@ -1191,7 +1195,8 @@ public class Select extends Query {
}
visitor
.
incrementQueryLevel
(
1
);
boolean
result
=
true
;
for
(
Expression
e
:
expressions
)
{
for
(
int
i
=
0
,
size
=
expressions
.
size
();
i
<
size
;
i
++)
{
Expression
e
=
expressions
.
get
(
i
);
if
(!
e
.
isEverything
(
visitor
))
{
result
=
false
;
break
;
...
...
@@ -1208,7 +1213,7 @@ public class Select extends Query {
}
public
boolean
isReadOnly
()
{
return
isEverything
(
ExpressionVisitor
.
READONLY
);
return
isEverything
(
ExpressionVisitor
.
READONLY
_VISITOR
);
}
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
a4f95b2b
...
...
@@ -148,7 +148,7 @@ public class Database implements DataHandler {
private
Mode
mode
=
Mode
.
getInstance
(
Mode
.
REGULAR
);
private
boolean
multiThreaded
;
private
int
maxOperationMemory
=
SysProperties
.
DEFAULT_MAX_OPERATION_MEMORY
;
private
SmallLRUCache
<
String
,
String
[]>
lobFileListCache
=
SmallLRUCache
.
newInstance
(
128
)
;
private
SmallLRUCache
<
String
,
String
[]>
lobFileListCache
;
private
boolean
autoServerMode
;
private
Server
server
;
private
HashMap
<
TableLinkConnection
,
TableLinkConnection
>
linkConnections
;
...
...
@@ -672,7 +672,7 @@ public class Database implements DataHandler {
}
synchronized
(
infoSchema
)
{
if
(!
metaTablesInitialized
)
{
for
(
int
type
=
0
;
type
<
MetaTable
.
getMetaTableTypeCount
()
;
type
++)
{
for
(
int
type
=
0
,
count
=
MetaTable
.
getMetaTableTypeCount
();
type
<
count
;
type
++)
{
MetaTable
m
=
new
MetaTable
(
infoSchema
,
-
1
-
type
,
type
);
infoSchema
.
add
(
m
);
}
...
...
@@ -1962,6 +1962,9 @@ public class Database implements DataHandler {
}
public
SmallLRUCache
<
String
,
String
[]>
getLobFileListCache
()
{
if
(
lobFileListCache
==
null
)
{
lobFileListCache
=
SmallLRUCache
.
newInstance
(
128
);
}
return
lobFileListCache
;
}
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
a4f95b2b
...
...
@@ -469,7 +469,8 @@ public class Session extends SessionWithState {
rows
.
add
(
entry
.
getRow
());
undoLog
.
removeLast
(
false
);
}
for
(
Row
r
:
rows
)
{
for
(
int
i
=
0
,
size
=
rows
.
size
();
i
<
size
;
i
++)
{
Row
r
=
rows
.
get
(
i
);
r
.
commit
();
}
}
...
...
@@ -615,7 +616,9 @@ public class Session extends SessionWithState {
undoLog
.
add
(
log
);
}
else
{
// see also UndoLogRecord.commit
for
(
Index
index
:
table
.
getIndexes
())
{
ArrayList
<
Index
>
indexes
=
table
.
getIndexes
();
for
(
int
i
=
0
,
size
=
indexes
.
size
();
i
<
size
;
i
++)
{
Index
index
=
indexes
.
get
(
i
);
index
.
commit
(
operation
,
row
);
}
row
.
commit
();
...
...
h2/src/main/org/h2/engine/UndoLogRecord.java
浏览文件 @
a4f95b2b
...
...
@@ -6,6 +6,7 @@
*/
package
org
.
h2
.
engine
;
import
java.util.ArrayList
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.index.Index
;
...
...
@@ -149,8 +150,9 @@ public class UndoLogRecord {
}
buff
.
writeLong
(
row
.
getKey
());
buff
.
writeInt
(
row
.
getSessionId
());
buff
.
writeInt
(
row
.
getColumnCount
());
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
();
i
++)
{
int
count
=
row
.
getColumnCount
();
buff
.
writeInt
(
count
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
Value
v
=
row
.
getValue
(
i
);
buff
.
checkCapacity
(
buff
.
getValueLen
(
v
));
buff
.
writeValue
(
v
);
...
...
@@ -260,7 +262,9 @@ public class UndoLogRecord {
* It commits the change to the indexes.
*/
public
void
commit
()
{
for
(
Index
index
:
table
.
getIndexes
())
{
ArrayList
<
Index
>
indexes
=
table
.
getIndexes
();
for
(
int
i
=
0
,
size
=
indexes
.
size
();
i
<
size
;
i
++)
{
Index
index
=
indexes
.
get
(
i
);
index
.
commit
(
operation
,
row
);
}
}
...
...
h2/src/main/org/h2/expression/Aggregate.java
浏览文件 @
a4f95b2b
...
...
@@ -201,9 +201,10 @@ public class Aggregate extends Expression {
}
private
SortOrder
initOrder
(
Session
session
)
{
int
[]
index
=
new
int
[
orderList
.
size
()];
int
[]
sortType
=
new
int
[
orderList
.
size
()];
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
int
size
=
orderList
.
size
();
int
[]
index
=
new
int
[
size
];
int
[]
sortType
=
new
int
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
SelectOrderBy
o
=
orderList
.
get
(
i
);
index
[
i
]
=
i
+
1
;
int
order
=
o
.
descending
?
SortOrder
.
DESCENDING
:
SortOrder
.
ASCENDING
;
...
...
@@ -240,9 +241,10 @@ public class Aggregate extends Expression {
if
(
v
!=
ValueNull
.
INSTANCE
)
{
v
=
v
.
convertTo
(
Value
.
STRING
);
if
(
orderList
!=
null
)
{
Value
[]
array
=
new
Value
[
1
+
orderList
.
size
()];
int
size
=
orderList
.
size
();
Value
[]
array
=
new
Value
[
1
+
size
];
array
[
0
]
=
v
;
for
(
int
i
=
0
;
i
<
orderList
.
size
()
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
SelectOrderBy
o
=
orderList
.
get
(
i
);
array
[
i
+
1
]
=
o
.
expression
.
getValue
(
session
);
}
...
...
h2/src/main/org/h2/expression/Expression.java
浏览文件 @
a4f95b2b
...
...
@@ -284,7 +284,7 @@ public abstract class Expression {
* @param outerJoin if the expression is part of an outer join
*/
public
void
addFilterConditions
(
TableFilter
filter
,
boolean
outerJoin
)
{
if
(!
addedToFilter
&&
!
outerJoin
&&
isEverything
(
ExpressionVisitor
.
EVALUATABLE
))
{
if
(!
addedToFilter
&&
!
outerJoin
&&
isEverything
(
ExpressionVisitor
.
EVALUATABLE
_VISITOR
))
{
filter
.
addFilterCondition
(
this
,
false
);
addedToFilter
=
true
;
}
...
...
h2/src/main/org/h2/expression/ExpressionVisitor.java
浏览文件 @
a4f95b2b
...
...
@@ -8,7 +8,9 @@ package org.h2.expression;
import
java.util.HashSet
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.DbObject
;
import
org.h2.message.DbException
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.Table
;
...
...
@@ -25,6 +27,11 @@ public class ExpressionVisitor {
*/
public
static
final
int
INDEPENDENT
=
0
;
/**
* The visitor singleton for the type INDEPENDENT.
*/
public
static
final
ExpressionVisitor
INDEPENDENT_VISITOR
=
new
ExpressionVisitor
(
INDEPENDENT
);
/**
* Are all aggregates MIN(column), MAX(column), or COUNT(*) for the given
* table (getTable)?
...
...
@@ -36,6 +43,11 @@ public class ExpressionVisitor {
*/
public
static
final
int
DETERMINISTIC
=
2
;
/**
* The visitor singleton for the type DETERMINISTIC.
*/
public
static
final
ExpressionVisitor
DETERMINISTIC_VISITOR
=
new
ExpressionVisitor
(
DETERMINISTIC
);
/**
* Can the expression be evaluated, that means are all columns set to
* 'evaluatable'?
...
...
@@ -43,7 +55,12 @@ public class ExpressionVisitor {
public
static
final
int
EVALUATABLE
=
3
;
/**
* Request to set the latest modification id.
* The visitor singleton for the type EVALUATABLE.
*/
public
static
final
ExpressionVisitor
EVALUATABLE_VISITOR
=
new
ExpressionVisitor
(
EVALUATABLE
);
/**
* Request to set the latest modification id (addDataModificationId).
*/
public
static
final
int
SET_MAX_DATA_MODIFICATION_ID
=
4
;
...
...
@@ -52,6 +69,11 @@ public class ExpressionVisitor {
*/
public
static
final
int
READONLY
=
5
;
/**
* The visitor singleton for the type EVALUATABLE.
*/
public
static
final
ExpressionVisitor
READONLY_VISITOR
=
new
ExpressionVisitor
(
READONLY
);
/**
* Does an expression have no relation to the given table filter
* (getResolver)?
...
...
@@ -59,7 +81,7 @@ public class ExpressionVisitor {
public
static
final
int
NOT_FROM_RESOLVER
=
6
;
/**
* Request to get the set of dependencies.
* Request to get the set of dependencies
(addDependency)
.
*/
public
static
final
int
GET_DEPENDENCIES
=
7
;
...
...
@@ -71,6 +93,11 @@ public class ExpressionVisitor {
*/
public
static
final
int
QUERY_COMPARABLE
=
8
;
/**
* The visitor singleton for the type QUERY_COMPARABLE.
*/
public
static
final
ExpressionVisitor
QUERY_COMPARABLE_VISITOR
=
new
ExpressionVisitor
(
QUERY_COMPARABLE
);
private
int
queryLevel
;
private
Table
table
;
private
int
type
;
...
...
@@ -89,6 +116,16 @@ public class ExpressionVisitor {
* @return the new visitor
*/
public
static
ExpressionVisitor
get
(
int
type
)
{
if
(
SysProperties
.
CHECK
)
{
switch
(
type
)
{
case
INDEPENDENT:
case
DETERMINISTIC:
case
EVALUATABLE:
case
READONLY:
case
QUERY_COMPARABLE:
throw
DbException
.
throwInternalError
(
"Singleton not used"
);
}
}
return
new
ExpressionVisitor
(
type
);
}
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
a4f95b2b
...
...
@@ -1356,8 +1356,9 @@ public class Function extends Expression implements FunctionCall {
}
private
static
String
rawToHex
(
String
s
)
{
StringBuilder
buff
=
new
StringBuilder
(
4
*
s
.
length
());
for
(
int
i
=
0
;
i
<
s
.
length
();
i
++)
{
int
length
=
s
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
4
*
length
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
String
hex
=
Integer
.
toHexString
(
s
.
charAt
(
i
)
&
0xffff
);
for
(
int
j
=
hex
.
length
();
j
<
4
;
j
++)
{
buff
.
append
(
'0'
);
...
...
h2/src/main/org/h2/fulltext/FullText.java
浏览文件 @
a4f95b2b
...
...
@@ -505,10 +505,11 @@ public class FullText {
* @param columns the column list
*/
protected
static
void
setColumns
(
int
[]
index
,
ArrayList
<
String
>
keys
,
ArrayList
<
String
>
columns
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
keys
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
keySize
=
keys
.
size
();
i
<
keySize
;
i
++)
{
String
key
=
keys
.
get
(
i
);
int
found
=
-
1
;
for
(
int
j
=
0
;
found
==
-
1
&&
j
<
columns
.
size
();
j
++)
{
int
columnsSize
=
columns
.
size
();
for
(
int
j
=
0
;
found
==
-
1
&&
j
<
columnsSize
;
j
++)
{
String
column
=
columns
.
get
(
j
);
if
(
column
.
equals
(
key
))
{
found
=
j
;
...
...
@@ -733,9 +734,10 @@ public class FullText {
if
(
data
.
indexOf
(
'\''
)
<
0
)
{
return
"'"
+
data
+
"'"
;
}
StringBuilder
buff
=
new
StringBuilder
(
data
.
length
()
+
2
);
int
len
=
data
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
len
+
2
);
buff
.
append
(
'\''
);
for
(
int
i
=
0
;
i
<
data
.
length
()
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
ch
=
data
.
charAt
(
i
);
if
(
ch
==
'\''
)
{
buff
.
append
(
ch
);
...
...
h2/src/main/org/h2/index/IndexCondition.java
浏览文件 @
a4f95b2b
...
...
@@ -313,17 +313,17 @@ public class IndexCondition {
*/
public
boolean
isEvaluatable
()
{
if
(
expression
!=
null
)
{
return
expression
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
);
return
expression
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
_VISITOR
);
}
if
(
expressionList
!=
null
)
{
for
(
Expression
e
:
expressionList
)
{
if
(!
e
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
))
{
if
(!
e
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
_VISITOR
))
{
return
false
;
}
}
return
true
;
}
return
expressionQuery
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
);
return
expressionQuery
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
_VISITOR
);
}
}
h2/src/main/org/h2/index/PageBtreeIndex.java
浏览文件 @
a4f95b2b
...
...
@@ -217,7 +217,7 @@ public class PageBtreeIndex extends PageIndex {
trace
.
debug
(
getName
()
+
" remove "
+
row
);
}
if
(
tableData
.
getContainsLargeObject
())
{
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
()
;
i
++)
{
for
(
int
i
=
0
,
len
=
row
.
getColumnCount
();
i
<
len
;
i
++)
{
Value
v
=
row
.
getValue
(
i
);
if
(
v
.
isLinked
())
{
session
.
unlinkAtCommit
(
v
);
...
...
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
a4f95b2b
...
...
@@ -104,7 +104,7 @@ public class PageDataIndex extends PageIndex {
}
}
if
(
tableData
.
getContainsLargeObject
())
{
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
()
;
i
++)
{
for
(
int
i
=
0
,
len
=
row
.
getColumnCount
();
i
<
len
;
i
++)
{
Value
v
=
row
.
getValue
(
i
);
Value
v2
=
v
.
link
(
database
,
getId
());
if
(
v2
.
isLinked
())
{
...
...
@@ -304,7 +304,7 @@ public class PageDataIndex extends PageIndex {
public
void
remove
(
Session
session
,
Row
row
)
{
if
(
tableData
.
getContainsLargeObject
())
{
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
()
;
i
++)
{
for
(
int
i
=
0
,
len
=
row
.
getColumnCount
();
i
<
len
;
i
++)
{
Value
v
=
row
.
getValue
(
i
);
if
(
v
.
isLinked
())
{
session
.
unlinkAtCommit
(
v
);
...
...
h2/src/main/org/h2/index/ViewCursor.java
浏览文件 @
a4f95b2b
...
...
@@ -45,7 +45,7 @@ public class ViewCursor implements Cursor {
}
current
=
table
.
getTemplateRow
();
Value
[]
values
=
result
.
currentRow
();
for
(
int
i
=
0
;
i
<
current
.
getColumnCount
()
;
i
++)
{
for
(
int
i
=
0
,
len
=
current
.
getColumnCount
();
i
<
len
;
i
++)
{
Value
v
=
i
<
values
.
length
?
values
[
i
]
:
ValueNull
.
INSTANCE
;
current
.
setValue
(
i
,
v
);
}
...
...
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
浏览文件 @
a4f95b2b
...
...
@@ -203,7 +203,8 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
debugCodeCall
(
"clearParameters"
);
checkClosed
();
ArrayList
<
?
extends
ParameterInterface
>
parameters
=
command
.
getParameters
();
for
(
ParameterInterface
param
:
parameters
)
{
for
(
int
i
=
0
,
size
=
parameters
.
size
();
i
<
size
;
i
++)
{
ParameterInterface
param
=
parameters
.
get
(
i
);
// can only delete old temp files if they are not in the batch
param
.
setValue
(
null
,
batchParameters
==
null
);
}
...
...
@@ -1068,12 +1069,13 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
// TODO batch: check what other database do if no parameters are set
batchParameters
=
New
.
arrayList
();
}
int
[]
result
=
new
int
[
batchParameters
.
size
()];
int
size
=
batchParameters
.
size
();
int
[]
result
=
new
int
[
size
];
boolean
error
=
false
;
SQLException
next
=
null
;
checkClosedForWrite
();
try
{
for
(
int
i
=
0
;
i
<
batchParameters
.
size
()
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Value
[]
set
=
batchParameters
.
get
(
i
);
ArrayList
<
?
extends
ParameterInterface
>
parameters
=
command
.
getParameters
();
for
(
int
j
=
0
;
j
<
set
.
length
;
j
++)
{
...
...
@@ -1122,8 +1124,9 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
checkClosedForWrite
();
try
{
ArrayList
<
?
extends
ParameterInterface
>
parameters
=
command
.
getParameters
();
Value
[]
set
=
new
Value
[
parameters
.
size
()];
for
(
int
i
=
0
;
i
<
parameters
.
size
();
i
++)
{
int
size
=
parameters
.
size
();
Value
[]
set
=
new
Value
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
ParameterInterface
param
=
parameters
.
get
(
i
);
Value
value
=
param
.
getParamValue
();
set
[
i
]
=
value
;
...
...
@@ -1494,7 +1497,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
ArrayList
<
?
extends
ParameterInterface
>
oldParams
=
command
.
getParameters
();
command
=
conn
.
prepareCommand
(
sqlStatement
,
fetchSize
);
ArrayList
<
?
extends
ParameterInterface
>
newParams
=
command
.
getParameters
();
for
(
int
i
=
0
;
i
<
oldParams
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
oldParams
.
size
();
i
<
size
;
i
++)
{
ParameterInterface
old
=
oldParams
.
get
(
i
);
Value
value
=
old
.
getParamValue
();
if
(
value
!=
null
)
{
...
...
h2/src/main/org/h2/jdbc/JdbcStatement.java
浏览文件 @
a4f95b2b
...
...
@@ -622,9 +622,10 @@ public class JdbcStatement extends TraceObject implements Statement {
// TODO batch: check what other database do if no commands are set
batchCommands
=
New
.
arrayList
();
}
int
[]
result
=
new
int
[
batchCommands
.
size
()];
int
size
=
batchCommands
.
size
();
int
[]
result
=
new
int
[
size
];
boolean
error
=
false
;
for
(
int
i
=
0
;
i
<
batchCommands
.
size
()
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
String
sql
=
batchCommands
.
get
(
i
);
try
{
result
[
i
]
=
executeUpdateInternal
(
sql
);
...
...
h2/src/main/org/h2/message/TraceSystem.java
浏览文件 @
a4f95b2b
...
...
@@ -100,7 +100,6 @@ public class TraceSystem implements TraceWriter {
public
TraceSystem
(
String
fileName
)
{
this
.
fileName
=
fileName
;
updateLevel
();
traces
=
SmallLRUCache
.
newInstance
(
100
);
}
private
void
updateLevel
()
{
...
...
@@ -126,6 +125,9 @@ public class TraceSystem implements TraceWriter {
* @return the trace object
*/
public
synchronized
Trace
getTrace
(
String
module
)
{
if
(
traces
==
null
)
{
traces
=
SmallLRUCache
.
newInstance
(
16
);
}
Trace
t
=
traces
.
get
(
module
);
if
(
t
==
null
)
{
t
=
new
Trace
(
writer
,
module
);
...
...
h2/src/main/org/h2/result/ResultDiskBuffer.java
浏览文件 @
a4f95b2b
...
...
@@ -176,7 +176,7 @@ class ResultDiskBuffer implements ResultExternal {
private
Value
[]
nextSorted
()
{
int
next
=
-
1
;
for
(
int
i
=
0
;
i
<
tapes
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
tapes
.
size
();
i
<
size
;
i
++)
{
ResultDiskTape
tape
=
tapes
.
get
(
i
);
if
(
tape
.
buffer
.
size
()
==
0
&&
tape
.
pos
<
tape
.
end
)
{
file
.
seek
(
tape
.
pos
);
...
...
h2/src/main/org/h2/result/RowList.java
浏览文件 @
a4f95b2b
...
...
@@ -49,12 +49,13 @@ public class RowList {
buff
.
checkCapacity
(
1
+
Data
.
LENGTH_INT
*
8
);
buff
.
writeByte
((
byte
)
1
);
buff
.
writeInt
(
r
.
getMemory
());
buff
.
writeInt
(
r
.
getColumnCount
());
int
columnCount
=
r
.
getColumnCount
();
buff
.
writeInt
(
columnCount
);
buff
.
writeLong
(
r
.
getKey
());
buff
.
writeInt
(
r
.
getVersion
());
buff
.
writeInt
(
r
.
isDeleted
()
?
1
:
0
);
buff
.
writeInt
(
r
.
getSessionId
());
for
(
int
i
=
0
;
i
<
r
.
getColumnCount
()
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Value
v
=
r
.
getValue
(
i
);
buff
.
checkCapacity
(
1
);
if
(
v
==
null
)
{
...
...
h2/src/main/org/h2/result/UpdatableRow.java
浏览文件 @
a4f95b2b
...
...
@@ -136,7 +136,7 @@ public class UpdatableRow {
}
private
void
setKey
(
PreparedStatement
prep
,
int
start
,
Value
[]
current
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
key
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
key
.
size
();
i
<
size
;
i
++)
{
String
col
=
key
.
get
(
i
);
int
idx
=
getColumnIndex
(
col
);
Value
v
=
current
[
idx
];
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
a4f95b2b
...
...
@@ -331,7 +331,7 @@ public class Schema extends DbObjectBase {
String
hash
=
Integer
.
toHexString
(
obj
.
getName
().
hashCode
()).
toUpperCase
();
String
name
=
null
;
synchronized
(
temporaryUniqueNames
)
{
for
(
int
i
=
1
;
i
<
hash
.
length
()
;
i
++)
{
for
(
int
i
=
1
,
len
=
hash
.
length
();
i
<
len
;
i
++)
{
name
=
prefix
+
hash
.
substring
(
0
,
i
);
if
(!
map
.
containsKey
(
name
)
&&
!
temporaryUniqueNames
.
contains
(
name
))
{
break
;
...
...
h2/src/main/org/h2/store/PageFreeList.java
浏览文件 @
a4f95b2b
...
...
@@ -22,7 +22,7 @@ public class PageFreeList extends Page {
private
static
final
int
DATA_START
=
3
;
private
final
PageStore
store
;
private
final
BitField
used
=
new
BitField
()
;
private
final
BitField
used
;
private
final
int
pageCount
;
private
boolean
full
;
private
Data
data
;
...
...
@@ -31,6 +31,7 @@ public class PageFreeList extends Page {
setPos
(
pageId
);
this
.
store
=
store
;
pageCount
=
(
store
.
getPageSize
()
-
DATA_START
)
*
8
;
used
=
new
BitField
(
pageCount
);
used
.
set
(
0
);
}
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
a4f95b2b
...
...
@@ -382,8 +382,8 @@ public class PageStore implements CacheWriter {
private
void
writeBack
()
{
ArrayList
<
CacheObject
>
list
=
cache
.
getAllChanged
();
Collections
.
sort
(
list
);
for
(
CacheObject
rec
:
list
)
{
writeBack
(
rec
);
for
(
int
i
=
0
,
size
=
list
.
size
();
i
<
size
;
i
++
)
{
writeBack
(
list
.
get
(
i
)
);
}
}
...
...
@@ -1095,6 +1095,7 @@ public class PageStore implements CacheWriter {
* @param after all allocated pages are higher than this page
*/
void
allocatePages
(
IntArray
list
,
int
pagesToAllocate
,
BitField
exclude
,
int
after
)
{
list
.
ensureCapacity
(
list
.
size
()
+
pagesToAllocate
);
for
(
int
i
=
0
;
i
<
pagesToAllocate
;
i
++)
{
int
page
=
allocatePage
(
exclude
,
after
);
after
=
page
;
...
...
h2/src/main/org/h2/table/Plan.java
浏览文件 @
a4f95b2b
...
...
@@ -112,7 +112,7 @@ public class Plan {
setEvaluatable
(
tableFilter
,
true
);
Expression
on
=
tableFilter
.
getJoinCondition
();
if
(
on
!=
null
)
{
if
(!
on
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
))
{
if
(!
on
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE
_VISITOR
))
{
invalidPlan
=
true
;
break
;
}
...
...
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
a4f95b2b
...
...
@@ -224,7 +224,7 @@ public class RegularTable extends TableBase {
long
total
=
remaining
;
Cursor
cursor
=
scan
.
find
(
session
,
null
,
null
);
long
i
=
0
;
int
bufferSize
=
Constants
.
DEFAULT_MAX_MEMORY_ROWS
;
int
bufferSize
=
(
int
)
Math
.
min
(
rowCount
,
Constants
.
DEFAULT_MAX_MEMORY_ROWS
)
;
ArrayList
<
Row
>
buffer
=
New
.
arrayList
(
bufferSize
);
String
n
=
getName
()
+
":"
+
index
.
getName
();
int
t
=
MathUtils
.
convertLongToInt
(
total
);
...
...
@@ -667,14 +667,16 @@ public class RegularTable extends TableBase {
public
boolean
canTruncate
()
{
if
(
getCheckForeignKeyConstraints
()
&&
database
.
getReferentialIntegrity
())
{
ArrayList
<
Constraint
>
constraints
=
getConstraints
();
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
c
=
constraints
.
get
(
i
);
if
(!(
c
.
getConstraintType
().
equals
(
Constraint
.
REFERENTIAL
)))
{
continue
;
}
ConstraintReferential
ref
=
(
ConstraintReferential
)
c
;
if
(
ref
.
getRefTable
()
==
this
)
{
return
false
;
if
(
constraints
!=
null
)
{
for
(
int
i
=
0
,
size
=
constraints
.
size
();
i
<
size
;
i
++)
{
Constraint
c
=
constraints
.
get
(
i
);
if
(!(
c
.
getConstraintType
().
equals
(
Constraint
.
REFERENTIAL
)))
{
continue
;
}
ConstraintReferential
ref
=
(
ConstraintReferential
)
c
;
if
(
ref
.
getRefTable
()
==
this
)
{
return
false
;
}
}
}
}
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
a4f95b2b
...
...
@@ -121,9 +121,11 @@ public abstract class Table extends SchemaObjectBase {
public
void
rename
(
String
newName
)
{
super
.
rename
(
newName
);
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
constraint
=
constraints
.
get
(
i
);
constraint
.
rebuild
();
if
(
constraints
!=
null
)
{
for
(
int
i
=
0
,
size
=
constraints
.
size
();
i
<
size
;
i
++)
{
Constraint
constraint
=
constraints
.
get
(
i
);
constraint
.
rebuild
();
}
}
}
...
...
@@ -470,23 +472,27 @@ public abstract class Table extends SchemaObjectBase {
* @throws SQLException if the column is referenced
*/
public
void
checkColumnIsNotReferenced
(
Column
col
)
{
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
constraint
=
constraints
.
get
(
i
);
if
(
constraint
.
containsColumn
(
col
))
{
throw
DbException
.
get
(
ErrorCode
.
COLUMN_MAY_BE_REFERENCED_1
,
constraint
.
getSQL
());
if
(
constraints
!=
null
)
{
for
(
int
i
=
0
,
size
=
constraints
.
size
();
i
<
size
;
i
++)
{
Constraint
constraint
=
constraints
.
get
(
i
);
if
(
constraint
.
containsColumn
(
col
))
{
throw
DbException
.
get
(
ErrorCode
.
COLUMN_MAY_BE_REFERENCED_1
,
constraint
.
getSQL
());
}
}
}
ArrayList
<
Index
>
indexes
=
getIndexes
();
for
(
int
i
=
0
;
indexes
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
getColumns
().
length
==
1
)
{
continue
;
}
if
(
index
.
getCreateSQL
()
==
null
)
{
continue
;
}
if
(
index
.
getColumnIndex
(
col
)
>=
0
)
{
throw
DbException
.
get
(
ErrorCode
.
COLUMN_MAY_BE_REFERENCED_1
,
index
.
getSQL
());
if
(
indexes
!=
null
)
{
for
(
int
i
=
0
,
size
=
indexes
.
size
();
i
<
size
;
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
getColumns
().
length
==
1
)
{
continue
;
}
if
(
index
.
getCreateSQL
()
==
null
)
{
continue
;
}
if
(
index
.
getColumnIndex
(
col
)
>=
0
)
{
throw
DbException
.
get
(
ErrorCode
.
COLUMN_MAY_BE_REFERENCED_1
,
index
.
getSQL
());
}
}
}
}
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
a4f95b2b
...
...
@@ -87,7 +87,7 @@ public class TableView extends Table {
tables
=
New
.
arrayList
(
query
.
getTables
());
ArrayList
<
Expression
>
expressions
=
query
.
getExpressions
();
ArrayList
<
Column
>
list
=
New
.
arrayList
();
for
(
int
i
=
0
;
i
<
query
.
getColumnCount
()
;
i
++)
{
for
(
int
i
=
0
,
count
=
query
.
getColumnCount
();
i
<
count
;
i
++)
{
Expression
expr
=
expressions
.
get
(
i
);
String
name
=
null
;
if
(
columnNames
!=
null
&&
columnNames
.
length
>
i
)
{
...
...
@@ -389,7 +389,7 @@ public class TableView extends Table {
if
(
recursive
)
{
return
false
;
}
return
viewQuery
.
isEverything
(
ExpressionVisitor
.
DETERMINISTIC
);
return
viewQuery
.
isEverything
(
ExpressionVisitor
.
DETERMINISTIC
_VISITOR
);
}
public
void
setRecursiveResult
(
ResultInterface
recursiveResult
)
{
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
a4f95b2b
...
...
@@ -1217,6 +1217,7 @@ public class Recover extends Tool implements DataHandler {
sql
=
sql
.
substring
(
"IF NOT EXISTS "
.
length
());
}
boolean
ignore
=
false
;
// sql is modified in the loop
for
(
int
i
=
0
;
i
<
sql
.
length
();
i
++)
{
char
ch
=
sql
.
charAt
(
i
);
if
(
ch
==
'\"'
)
{
...
...
h2/src/main/org/h2/tools/Shell.java
浏览文件 @
a4f95b2b
...
...
@@ -209,7 +209,7 @@ public class Shell extends Tool implements Runnable {
listMode
=
!
listMode
;
println
(
"Result list mode is now "
+
(
listMode
?
"on"
:
"off"
));
}
else
if
(
"HISTORY"
.
equals
(
upper
))
{
for
(
int
i
=
0
;
i
<
history
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
history
.
size
();
i
<
size
;
i
++)
{
String
s
=
history
.
get
(
i
);
s
=
s
.
replace
(
'\n'
,
' '
).
replace
(
'\r'
,
' '
);
println
(
"#"
+
(
1
+
i
)
+
": "
+
s
);
...
...
h2/src/main/org/h2/tools/SimpleResultSet.java
浏览文件 @
a4f95b2b
...
...
@@ -511,9 +511,11 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* closed
*/
public
int
findColumn
(
String
columnLabel
)
throws
SQLException
{
for
(
int
i
=
0
;
columnLabel
!=
null
&&
columns
!=
null
&&
i
<
columns
.
size
();
i
++)
{
if
(
columnLabel
.
equalsIgnoreCase
(
getColumn
(
i
).
name
))
{
return
i
+
1
;
if
(
columnLabel
!=
null
&&
columns
!=
null
)
{
for
(
int
i
=
0
,
size
=
columns
.
size
();
i
<
size
;
i
++)
{
if
(
columnLabel
.
equalsIgnoreCase
(
getColumn
(
i
).
name
))
{
return
i
+
1
;
}
}
}
throw
DbException
.
get
(
ErrorCode
.
COLUMN_NOT_FOUND_1
,
columnLabel
).
getSQLException
();
...
...
h2/src/main/org/h2/util/BitField.java
浏览文件 @
a4f95b2b
...
...
@@ -14,9 +14,17 @@ public final class BitField {
private
static
final
int
ADDRESS_BITS
=
6
;
private
static
final
int
BITS
=
64
;
private
static
final
int
ADDRESS_MASK
=
BITS
-
1
;
private
long
[]
data
=
new
long
[
10
]
;
private
long
[]
data
;
private
int
maxLength
;
public
BitField
()
{
this
(
64
);
}
public
BitField
(
int
capacity
)
{
data
=
new
long
[
capacity
>>>
3
];
}
/**
* Get the index of the next bit that is not set.
*
...
...
h2/src/main/org/h2/util/IntArray.java
浏览文件 @
a4f95b2b
...
...
@@ -49,7 +49,9 @@ public class IntArray {
* @param value the value to append
*/
public
void
add
(
int
value
)
{
checkCapacity
();
if
(
size
>=
data
.
length
)
{
ensureCapacity
(
size
+
size
);
}
data
[
size
++]
=
value
;
}
...
...
@@ -83,9 +85,16 @@ public class IntArray {
size
--;
}
private
void
checkCapacity
()
{
if
(
size
>=
data
.
length
)
{
int
[]
d
=
new
int
[
Math
.
max
(
4
,
data
.
length
*
2
)];
/**
* Ensure the the underlying array is large enough for the given number of
* entries.
*
* @param minCapacity the minimum capacity
*/
public
void
ensureCapacity
(
int
minCapacity
)
{
minCapacity
=
Math
.
max
(
4
,
minCapacity
);
if
(
minCapacity
>=
data
.
length
)
{
int
[]
d
=
new
int
[
minCapacity
];
System
.
arraycopy
(
data
,
0
,
d
,
0
,
data
.
length
);
data
=
d
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论