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