Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
645494c4
提交
645494c4
authored
10月 13, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Smaller changes (mainly for Android).
上级
6969ad47
隐藏空白字符变更
内嵌
并排
正在显示
22 个修改的文件
包含
176 行增加
和
141 行删除
+176
-141
Parser.java
h2/src/main/org/h2/command/Parser.java
+9
-11
Prepared.java
h2/src/main/org/h2/command/Prepared.java
+5
-3
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+2
-2
Query.java
h2/src/main/org/h2/command/dml/Query.java
+15
-11
Select.java
h2/src/main/org/h2/command/dml/Select.java
+49
-42
Session.java
h2/src/main/org/h2/engine/Session.java
+2
-1
Aggregate.java
h2/src/main/org/h2/expression/Aggregate.java
+6
-4
ConditionIn.java
h2/src/main/org/h2/expression/ConditionIn.java
+3
-2
Function.java
h2/src/main/org/h2/expression/Function.java
+1
-1
IndexCursor.java
h2/src/main/org/h2/index/IndexCursor.java
+1
-1
ViewIndex.java
h2/src/main/org/h2/index/ViewIndex.java
+7
-5
RowList.java
h2/src/main/org/h2/result/RowList.java
+1
-1
SHA256.java
h2/src/main/org/h2/security/SHA256.java
+1
-1
PageLog.java
h2/src/main/org/h2/store/PageLog.java
+3
-2
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+1
-1
Table.java
h2/src/main/org/h2/table/Table.java
+34
-26
Csv.java
h2/src/main/org/h2/tools/Csv.java
+4
-3
CacheLRU.java
h2/src/main/org/h2/util/CacheLRU.java
+3
-2
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+24
-17
DataType.java
h2/src/main/org/h2/value/DataType.java
+1
-1
ValueUuid.java
h2/src/main/org/h2/value/ValueUuid.java
+1
-1
TestRunscript.java
h2/src/test/org/h2/test/db/TestRunscript.java
+3
-3
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
645494c4
...
...
@@ -429,7 +429,7 @@ public class Parser {
throw
getSyntaxError
();
}
if
(
indexedParameterList
!=
null
)
{
for
(
int
i
=
0
;
i
<
indexedParameterList
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
indexedParameterList
.
size
();
i
<
size
;
i
++)
{
if
(
indexedParameterList
.
get
(
i
)
==
null
)
{
indexedParameterList
.
set
(
i
,
new
Parameter
(
i
));
}
...
...
@@ -844,9 +844,11 @@ public class Parser {
private
Prepared
prepare
(
Session
s
,
String
sql
,
ArrayList
<
Value
>
paramValues
)
{
Prepared
prep
=
s
.
prepare
(
sql
);
ArrayList
<
Parameter
>
params
=
prep
.
getParameters
();
for
(
int
i
=
0
;
params
!=
null
&&
i
<
params
.
size
();
i
++)
{
Parameter
p
=
params
.
get
(
i
);
p
.
setValue
(
paramValues
.
get
(
i
));
if
(
params
!=
null
)
{
for
(
int
i
=
0
,
size
=
params
.
size
();
i
<
size
;
i
++)
{
Parameter
p
=
params
.
get
(
i
);
p
.
setValue
(
paramValues
.
get
(
i
));
}
}
return
prep
;
}
...
...
@@ -955,11 +957,7 @@ public class Parser {
if
(
isSelect
())
{
Query
query
=
parseSelectUnion
();
read
(
")"
);
ArrayList
<
Parameter
>
params
=
New
.
arrayList
();
for
(
int
i
=
0
;
i
<
parameters
.
size
();
i
++)
{
params
.
add
(
parameters
.
get
(
i
));
}
query
.
setParameterList
(
params
);
query
.
setParameterList
(
New
.
arrayList
(
parameters
));
query
.
init
();
Session
s
;
if
(
createView
!=
null
)
{
...
...
@@ -1404,7 +1402,7 @@ public class Parser {
int
paramIndex
=
parameters
.
size
();
Query
command
=
parseSelectUnion
();
ArrayList
<
Parameter
>
params
=
New
.
arrayList
();
for
(
int
i
=
paramIndex
;
i
<
parameters
.
size
()
;
i
++)
{
for
(
int
i
=
paramIndex
,
size
=
parameters
.
size
();
i
<
size
;
i
++)
{
params
.
add
(
parameters
.
get
(
i
));
}
command
.
setParameterList
(
params
);
...
...
@@ -5053,7 +5051,7 @@ public class Parser {
if
((!
Character
.
isLetter
(
c
)
&&
c
!=
'_'
)
||
Character
.
isLowerCase
(
c
))
{
return
StringUtils
.
quoteIdentifier
(
s
);
}
for
(
int
i
=
0
;
i
<
s
.
length
()
;
i
++)
{
for
(
int
i
=
1
,
length
=
s
.
length
();
i
<
length
;
i
++)
{
c
=
s
.
charAt
(
i
);
if
((!
Character
.
isLetterOrDigit
(
c
)
&&
c
!=
'_'
)
||
Character
.
isLowerCase
(
c
))
{
return
StringUtils
.
quoteIdentifier
(
s
);
...
...
h2/src/main/org/h2/command/Prepared.java
浏览文件 @
645494c4
...
...
@@ -156,9 +156,11 @@ public abstract class Prepared {
* @throws SQLException if any parameter has not been set
*/
protected
void
checkParameters
()
{
for
(
int
i
=
0
;
parameters
!=
null
&&
i
<
parameters
.
size
();
i
++)
{
Parameter
param
=
parameters
.
get
(
i
);
param
.
checkSet
();
if
(
parameters
!=
null
)
{
for
(
int
i
=
0
,
size
=
parameters
.
size
();
i
<
size
;
i
++)
{
Parameter
param
=
parameters
.
get
(
i
);
param
.
checkSet
();
}
}
}
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
645494c4
...
...
@@ -85,11 +85,11 @@ public class Merge extends Prepared {
session
.
setLastIdentity
(
ValueLong
.
get
(
0
));
if
(
list
.
size
()
>
0
)
{
count
=
0
;
for
(
int
x
=
0
;
x
<
list
.
size
()
;
x
++)
{
for
(
int
x
=
0
,
size
=
list
.
size
();
x
<
size
;
x
++)
{
setCurrentRowNumber
(
x
+
1
);
Expression
[]
expr
=
list
.
get
(
x
);
Row
newRow
=
table
.
getTemplateRow
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
for
(
int
i
=
0
,
len
=
columns
.
length
;
i
<
len
;
i
++)
{
Column
c
=
columns
[
i
];
int
index
=
c
.
getColumnId
();
Expression
e
=
expr
[
i
];
...
...
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
645494c4
...
...
@@ -214,8 +214,9 @@ public abstract class Query extends Prepared {
if
(
list
==
null
)
{
list
=
New
.
arrayList
();
}
Value
[]
params
=
new
Value
[
list
.
size
()];
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
int
size
=
list
.
size
();
Value
[]
params
=
new
Value
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Value
v
=
list
.
get
(
i
).
getParamValue
();
params
[
i
]
=
v
;
}
...
...
@@ -330,12 +331,14 @@ public abstract class Query extends Prepared {
}
}
else
{
String
s
=
e
.
getSQL
();
for
(
int
j
=
0
;
expressionSQL
!=
null
&&
j
<
expressionSQL
.
size
();
j
++)
{
String
s2
=
expressionSQL
.
get
(
j
);
if
(
s2
.
equals
(
s
))
{
idx
=
j
;
isAlias
=
true
;
break
;
if
(
expressionSQL
!=
null
)
{
for
(
int
j
=
0
,
size
=
expressionSQL
.
size
();
j
<
size
;
j
++)
{
String
s2
=
expressionSQL
.
get
(
j
);
if
(
s2
.
equals
(
s
))
{
idx
=
j
;
isAlias
=
true
;
break
;
}
}
}
}
...
...
@@ -360,9 +363,10 @@ public abstract class Query extends Prepared {
* @return the {@link SortOrder} object
*/
public
SortOrder
prepareOrder
(
ArrayList
<
SelectOrderBy
>
orderList
,
int
expressionCount
)
{
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
);
int
idx
;
boolean
reverse
=
false
;
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
645494c4
...
...
@@ -238,13 +238,15 @@ public class Select extends Query {
return
null
;
}
ArrayList
<
Index
>
indexes
=
topTableFilter
.
getTable
().
getIndexes
();
for
(
int
i
=
0
;
indexes
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
getIndexType
().
isScan
())
{
continue
;
}
if
(
isGroupSortedIndex
(
topTableFilter
,
index
))
{
return
index
;
if
(
indexes
!=
null
)
{
for
(
int
i
=
0
,
size
=
indexes
.
size
();
i
<
size
;
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
getIndexType
().
isScan
())
{
continue
;
}
if
(
isGroupSortedIndex
(
topTableFilter
,
index
))
{
return
index
;
}
}
}
return
null
;
...
...
@@ -256,7 +258,7 @@ public class Select extends Query {
// also check that the first columns in the index are grouped
boolean
[]
grouped
=
new
boolean
[
indexColumns
.
length
];
outerLoop:
for
(
int
i
=
0
;
i
<
expressions
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
expressions
.
size
();
i
<
size
;
i
++)
{
if
(!
groupByExpression
[
i
])
{
continue
;
}
...
...
@@ -407,38 +409,40 @@ public class Select extends Query {
return
topTableFilter
.
getTable
().
getScanIndex
(
session
);
}
ArrayList
<
Index
>
list
=
topTableFilter
.
getTable
().
getIndexes
();
for
(
int
i
=
0
;
list
!=
null
&&
i
<
list
.
size
();
i
++)
{
Index
index
=
list
.
get
(
i
);
if
(
index
.
getCreateSQL
()
==
null
)
{
// can't use the scan index
continue
;
}
if
(
index
.
getIndexType
().
isHash
())
{
continue
;
}
IndexColumn
[]
indexCols
=
index
.
getIndexColumns
();
if
(
indexCols
.
length
<
sortCols
.
length
)
{
continue
;
}
boolean
ok
=
true
;
for
(
int
j
=
0
;
j
<
sortCols
.
length
;
j
++)
{
// the index and the sort order must start
// with the exact same columns
IndexColumn
idxCol
=
indexCols
[
j
];
Column
sortCol
=
sortCols
[
j
];
if
(
idxCol
.
column
!=
sortCol
)
{
ok
=
false
;
break
;
if
(
list
!=
null
)
{
for
(
int
i
=
0
,
size
=
list
.
size
();
i
<
size
;
i
++)
{
Index
index
=
list
.
get
(
i
);
if
(
index
.
getCreateSQL
()
==
null
)
{
// can't use the scan index
continue
;
}
if
(
idxCol
.
sortType
!=
sortTypes
[
j
])
{
// NULL FIRST for ascending and NULLS LAST
// for descending would actually match the default
ok
=
false
;
break
;
if
(
index
.
getIndexType
().
isHash
())
{
continue
;
}
IndexColumn
[]
indexCols
=
index
.
getIndexColumns
();
if
(
indexCols
.
length
<
sortCols
.
length
)
{
continue
;
}
boolean
ok
=
true
;
for
(
int
j
=
0
;
j
<
sortCols
.
length
;
j
++)
{
// the index and the sort order must start
// with the exact same columns
IndexColumn
idxCol
=
indexCols
[
j
];
Column
sortCol
=
sortCols
[
j
];
if
(
idxCol
.
column
!=
sortCol
)
{
ok
=
false
;
break
;
}
if
(
idxCol
.
sortType
!=
sortTypes
[
j
])
{
// NULL FIRST for ascending and NULLS LAST
// for descending would actually match the default
ok
=
false
;
break
;
}
}
if
(
ok
)
{
return
index
;
}
}
if
(
ok
)
{
return
index
;
}
}
return
null
;
...
...
@@ -617,6 +621,7 @@ public class Select extends Query {
}
private
void
expandColumnList
()
{
// the expressions may change within the loop
for
(
int
i
=
0
;
i
<
expressions
.
size
();
i
++)
{
Expression
expr
=
expressions
.
get
(
i
);
if
(!
expr
.
isWildcard
())
{
...
...
@@ -696,12 +701,14 @@ public class Select extends Query {
// then 'HAVING' expressions,
// and 'GROUP BY' expressions at the end
if
(
group
!=
null
)
{
groupIndex
=
new
int
[
group
.
size
()];
for
(
int
i
=
0
;
i
<
group
.
size
();
i
++)
{
int
size
=
group
.
size
();
int
expSize
=
expressionSQL
.
size
();
groupIndex
=
new
int
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Expression
expr
=
group
.
get
(
i
);
String
sql
=
expr
.
getSQL
();
int
found
=
-
1
;
for
(
int
j
=
0
;
j
<
exp
ressionSQL
.
size
()
;
j
++)
{
for
(
int
j
=
0
;
j
<
exp
Size
;
j
++)
{
String
s2
=
expressionSQL
.
get
(
j
);
if
(
s2
.
equals
(
sql
))
{
found
=
j
;
...
...
@@ -710,7 +717,7 @@ public class Select extends Query {
}
if
(
found
<
0
)
{
// special case: GROUP BY a column alias
for
(
int
j
=
0
;
j
<
exp
ressionSQL
.
size
()
;
j
++)
{
for
(
int
j
=
0
;
j
<
exp
Size
;
j
++)
{
Expression
e
=
expressions
.
get
(
j
);
if
(
sql
.
equals
(
e
.
getAlias
()))
{
found
=
j
;
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
645494c4
...
...
@@ -631,6 +631,7 @@ public class Session extends SessionWithState {
// MVCC: keep shared locks (insert / update / delete)
return
;
}
// locks is modified in the loop
for
(
int
i
=
0
;
i
<
locks
.
size
();
i
++)
{
Table
t
=
locks
.
get
(
i
);
if
(!
t
.
isLockedExclusively
())
{
...
...
@@ -661,7 +662,7 @@ public class Session extends SessionWithState {
if
(
locks
.
size
()
>
0
)
{
synchronized
(
database
)
{
// don't use the enhance for loop to safe memory
for
(
int
i
=
0
;
i
<
locks
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
locks
.
size
();
i
<
size
;
i
++)
{
Table
t
=
locks
.
get
(
i
);
t
.
unlock
(
this
);
}
...
...
h2/src/main/org/h2/expression/Aggregate.java
浏览文件 @
645494c4
...
...
@@ -548,10 +548,12 @@ public class Aggregate extends Expression {
if
(
separator
!=
null
&&
!
separator
.
isEverything
(
visitor
))
{
return
false
;
}
for
(
int
i
=
0
;
orderList
!=
null
&&
i
<
orderList
.
size
();
i
++)
{
SelectOrderBy
o
=
orderList
.
get
(
i
);
if
(!
o
.
expression
.
isEverything
(
visitor
))
{
return
false
;
if
(
orderList
!=
null
)
{
for
(
int
i
=
0
,
size
=
orderList
.
size
();
i
<
size
;
i
++)
{
SelectOrderBy
o
=
orderList
.
get
(
i
);
if
(!
o
.
expression
.
isEverything
(
visitor
))
{
return
false
;
}
}
}
return
true
;
...
...
h2/src/main/org/h2/expression/ConditionIn.java
浏览文件 @
645494c4
...
...
@@ -81,7 +81,8 @@ public class ConditionIn extends Condition {
return
left
;
}
boolean
allValuesConstant
=
true
;
for
(
int
i
=
0
;
i
<
valueList
.
size
();
i
++)
{
int
size
=
valueList
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Expression
e
=
valueList
.
get
(
i
);
e
=
e
.
optimize
(
session
);
if
(
allValuesConstant
&&
!
e
.
isConstant
())
{
...
...
@@ -92,7 +93,7 @@ public class ConditionIn extends Condition {
if
(
constant
&&
allValuesConstant
)
{
return
ValueExpression
.
get
(
getValue
(
session
));
}
if
(
valueList
.
size
()
==
1
)
{
if
(
size
==
1
)
{
Expression
right
=
valueList
.
get
(
0
);
Expression
expr
=
new
Comparison
(
session
,
Comparison
.
EQUAL
,
left
,
right
);
expr
=
expr
.
optimize
(
session
);
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
645494c4
...
...
@@ -146,7 +146,7 @@ public class Function extends Expression implements FunctionCall {
// SOUNDEX_INDEX
String
index
=
"7AEIOUY8HW1BFPV2CGJKQSXZ3DT4L5MN6R"
;
char
number
=
0
;
for
(
int
i
=
0
;
i
<
index
.
length
()
;
i
++)
{
for
(
int
i
=
0
,
length
=
index
.
length
();
i
<
length
;
i
++)
{
char
c
=
index
.
charAt
(
i
);
if
(
c
<
'9'
)
{
number
=
c
;
...
...
h2/src/main/org/h2/index/IndexCursor.java
浏览文件 @
645494c4
...
...
@@ -73,7 +73,7 @@ public class IndexCursor implements Cursor {
inResult
=
null
;
inResultTested
=
null
;
// don't use enhanced for loop to avoid creating objects
for
(
int
i
=
0
;
i
<
indexConditions
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
indexConditions
.
size
();
i
<
size
;
i
++)
{
IndexCondition
condition
=
indexConditions
.
get
(
i
);
if
(
condition
.
isAlwaysFalse
())
{
alwaysFalse
=
true
;
...
...
h2/src/main/org/h2/index/ViewIndex.java
浏览文件 @
645494c4
...
...
@@ -195,11 +195,13 @@ public class ViewIndex extends BaseIndex {
return
new
ViewCursor
(
table
,
result
);
}
ArrayList
<
Parameter
>
paramList
=
query
.
getParameters
();
for
(
int
i
=
0
;
originalParameters
!=
null
&&
i
<
originalParameters
.
size
();
i
++)
{
Parameter
orig
=
originalParameters
.
get
(
i
);
int
idx
=
orig
.
getIndex
();
Value
value
=
orig
.
getValue
(
session
);
setParameter
(
paramList
,
idx
,
value
);
if
(
originalParameters
!=
null
)
{
for
(
int
i
=
0
,
size
=
originalParameters
.
size
();
i
<
size
;
i
++)
{
Parameter
orig
=
originalParameters
.
get
(
i
);
int
idx
=
orig
.
getIndex
();
Value
value
=
orig
.
getValue
(
session
);
setParameter
(
paramList
,
idx
,
value
);
}
}
int
len
;
if
(
first
!=
null
)
{
...
...
h2/src/main/org/h2/result/RowList.java
浏览文件 @
645494c4
...
...
@@ -92,7 +92,7 @@ public class RowList {
}
Data
buff
=
rowBuff
;
initBuffer
(
buff
);
for
(
int
i
=
0
;
i
<
list
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
list
.
size
();
i
<
size
;
i
++)
{
if
(
i
>
0
&&
buff
.
length
()
>
Constants
.
IO_BUFFER_SIZE
)
{
flushBuffer
(
buff
);
initBuffer
(
buff
);
...
...
h2/src/main/org/h2/security/SHA256.java
浏览文件 @
645494c4
...
...
@@ -64,7 +64,7 @@ public class SHA256 {
String
user
=
userName
+
"@"
;
byte
[]
buff
=
new
byte
[
2
*
(
user
.
length
()
+
password
.
length
)];
int
n
=
0
;
for
(
int
i
=
0
;
i
<
user
.
length
()
;
i
++)
{
for
(
int
i
=
0
,
length
=
user
.
length
();
i
<
length
;
i
++)
{
char
c
=
user
.
charAt
(
i
);
buff
[
n
++]
=
(
byte
)
(
c
>>
8
);
buff
[
n
++]
=
(
byte
)
c
;
...
...
h2/src/main/org/h2/store/PageLog.java
浏览文件 @
645494c4
...
...
@@ -517,8 +517,9 @@ public class PageLog {
}
Data
buffer
=
getBuffer
();
buffer
.
writeByte
((
byte
)
FREE_LOG
);
buffer
.
writeVarInt
(
pages
.
size
());
for
(
int
i
=
0
;
i
<
pages
.
size
();
i
++)
{
int
size
=
pages
.
size
();
buffer
.
writeVarInt
(
size
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
buffer
.
writeVarInt
(
pages
.
get
(
i
));
}
write
(
buffer
);
...
...
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
645494c4
...
...
@@ -111,7 +111,7 @@ public class RegularTable extends TableBase {
row
.
setSessionId
(
session
.
getId
());
}
try
{
for
(
;
i
<
indexes
.
size
()
;
i
++)
{
for
(
int
size
=
indexes
.
size
();
i
<
size
;
i
++)
{
Index
index
=
indexes
.
get
(
i
);
index
.
add
(
session
,
row
);
checkRowCount
(
session
,
index
,
1
);
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
645494c4
...
...
@@ -565,12 +565,14 @@ public abstract class Table extends SchemaObjectBase {
item
.
setIndex
(
getScanIndex
(
session
));
item
.
cost
=
item
.
getIndex
().
getCost
(
session
,
null
);
ArrayList
<
Index
>
indexes
=
getIndexes
();
for
(
int
i
=
1
;
indexes
!=
null
&&
masks
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
double
cost
=
index
.
getCost
(
session
,
masks
);
if
(
cost
<
item
.
cost
)
{
item
.
cost
=
cost
;
item
.
setIndex
(
index
);
if
(
indexes
!=
null
&&
masks
!=
null
)
{
for
(
int
i
=
1
,
size
=
indexes
.
size
();
i
<
size
;
i
++)
{
Index
index
=
indexes
.
get
(
i
);
double
cost
=
index
.
getCost
(
session
,
masks
);
if
(
cost
<
item
.
cost
)
{
item
.
cost
=
cost
;
item
.
setIndex
(
index
);
}
}
}
return
item
;
...
...
@@ -583,10 +585,12 @@ public abstract class Table extends SchemaObjectBase {
*/
public
Index
findPrimaryKey
()
{
ArrayList
<
Index
>
indexes
=
getIndexes
();
for
(
int
i
=
0
;
indexes
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
idx
=
indexes
.
get
(
i
);
if
(
idx
.
getIndexType
().
isPrimaryKey
())
{
return
idx
;
if
(
indexes
!=
null
)
{
for
(
int
i
=
0
,
size
=
indexes
.
size
();
i
<
size
;
i
++)
{
Index
idx
=
indexes
.
get
(
i
);
if
(
idx
.
getIndexType
().
isPrimaryKey
())
{
return
idx
;
}
}
}
return
null
;
...
...
@@ -797,7 +801,7 @@ public abstract class Table extends SchemaObjectBase {
private
void
fireConstraints
(
Session
session
,
Row
oldRow
,
Row
newRow
,
boolean
before
)
{
if
(
constraints
!=
null
)
{
// don't use enhanced for loop to avoid creating objects
for
(
int
i
=
0
;
i
<
constraints
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
constraints
.
size
();
i
<
size
;
i
++)
{
Constraint
constraint
=
constraints
.
get
(
i
);
if
(
constraint
.
isBefore
()
==
before
)
{
constraint
.
checkRow
(
session
,
this
,
oldRow
,
newRow
);
...
...
@@ -856,9 +860,10 @@ public abstract class Table extends SchemaObjectBase {
public
void
setCheckForeignKeyConstraints
(
Session
session
,
boolean
enabled
,
boolean
checkExisting
)
{
if
(
enabled
&&
checkExisting
)
{
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
c
=
constraints
.
get
(
i
);
c
.
checkExistingData
(
session
);
if
(
constraints
!=
null
)
{
for
(
Constraint
c
:
constraints
)
{
c
.
checkExistingData
(
session
);
}
}
}
checkForeignKeyConstraints
=
enabled
;
...
...
@@ -878,12 +883,14 @@ public abstract class Table extends SchemaObjectBase {
*/
public
Index
getIndexForColumn
(
Column
column
,
boolean
first
)
{
ArrayList
<
Index
>
indexes
=
getIndexes
();
for
(
int
i
=
1
;
indexes
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
canGetFirstOrLast
())
{
int
idx
=
index
.
getColumnIndex
(
column
);
if
(
idx
==
0
)
{
return
index
;
if
(
indexes
!=
null
)
{
for
(
int
i
=
1
,
size
=
indexes
.
size
();
i
<
size
;
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
canGetFirstOrLast
())
{
int
idx
=
index
.
getColumnIndex
(
column
);
if
(
idx
==
0
)
{
return
index
;
}
}
}
}
...
...
@@ -915,12 +922,13 @@ public abstract class Table extends SchemaObjectBase {
*/
public
void
removeIndexOrTransferOwnership
(
Session
session
,
Index
index
)
{
boolean
stillNeeded
=
false
;
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
cons
=
constraints
.
get
(
i
);
if
(
cons
.
usesIndex
(
index
))
{
cons
.
setIndexOwner
(
index
);
database
.
update
(
session
,
cons
);
stillNeeded
=
true
;
if
(
constraints
!=
null
)
{
for
(
Constraint
cons
:
constraints
)
{
if
(
cons
.
usesIndex
(
index
))
{
cons
.
setIndexOwner
(
index
);
database
.
update
(
session
,
cons
);
stillNeeded
=
true
;
}
}
}
if
(!
stillNeeded
)
{
...
...
h2/src/main/org/h2/tools/Csv.java
浏览文件 @
645494c4
...
...
@@ -289,8 +289,9 @@ public class Csv implements SimpleRowSource {
return
data
;
}
}
StringBuilder
buff
=
new
StringBuilder
(
data
.
length
());
for
(
int
i
=
0
;
i
<
data
.
length
();
i
++)
{
int
length
=
data
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
length
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
ch
=
data
.
charAt
(
i
);
if
(
ch
==
fieldDelimiter
||
ch
==
escapeCharacter
)
{
buff
.
append
(
escapeCharacter
);
...
...
@@ -357,7 +358,7 @@ public class Csv implements SimpleRowSource {
}
private
boolean
isSimpleColumnName
(
String
columnName
)
{
for
(
int
i
=
0
;
i
<
columnName
.
length
()
;
i
++)
{
for
(
int
i
=
0
,
length
=
columnName
.
length
();
i
<
length
;
i
++)
{
char
ch
=
columnName
.
charAt
(
i
);
if
(
i
==
0
)
{
if
(
ch
!=
'_'
&&
!
Character
.
isLetter
(
ch
))
{
...
...
h2/src/main/org/h2/util/CacheLRU.java
浏览文件 @
645494c4
...
...
@@ -173,18 +173,19 @@ public class CacheLRU implements Cache {
}
Collections
.
sort
(
changed
);
int
max
=
maxMemory
;
int
size
=
changed
.
size
();
try
{
// temporary disable size checking,
// to avoid stack overflow
maxMemory
=
Integer
.
MAX_VALUE
;
for
(
i
=
0
;
i
<
changed
.
size
()
;
i
++)
{
for
(
i
=
0
;
i
<
size
;
i
++)
{
CacheObject
rec
=
changed
.
get
(
i
);
writer
.
writeBack
(
rec
);
}
}
finally
{
maxMemory
=
max
;
}
for
(
i
=
0
;
i
<
changed
.
size
()
;
i
++)
{
for
(
i
=
0
;
i
<
size
;
i
++)
{
CacheObject
rec
=
changed
.
get
(
i
);
remove
(
rec
.
getPos
());
if
(
SysProperties
.
CHECK
)
{
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
645494c4
...
...
@@ -108,9 +108,10 @@ public class StringUtils {
if
(
s
==
null
)
{
return
"NULL"
;
}
StringBuilder
buff
=
new
StringBuilder
(
s
.
length
()
+
2
);
int
length
=
s
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
length
+
2
);
buff
.
append
(
'\''
);
for
(
int
i
=
0
;
i
<
s
.
length
()
;
i
++)
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
if
(
c
==
'\''
)
{
buff
.
append
(
c
);
...
...
@@ -134,8 +135,9 @@ public class StringUtils {
* @return the Java representation
*/
public
static
String
javaEncode
(
String
s
)
{
StringBuilder
buff
=
new
StringBuilder
(
s
.
length
());
for
(
int
i
=
0
;
i
<
s
.
length
();
i
++)
{
int
length
=
s
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
length
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
switch
(
c
)
{
// case '\b':
...
...
@@ -213,8 +215,9 @@ public class StringUtils {
* @return the string
*/
public
static
String
javaDecode
(
String
s
)
{
StringBuilder
buff
=
new
StringBuilder
(
s
.
length
());
for
(
int
i
=
0
;
i
<
s
.
length
();
i
++)
{
int
length
=
s
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
length
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
if
(
c
==
'"'
)
{
break
;
...
...
@@ -449,9 +452,10 @@ public class StringUtils {
* @return the decoded string
*/
public
static
String
urlDecode
(
String
encoded
)
{
byte
[]
buff
=
new
byte
[
encoded
.
length
()];
int
length
=
encoded
.
length
();
byte
[]
buff
=
new
byte
[
length
];
int
j
=
0
;
for
(
int
i
=
0
;
i
<
encoded
.
length
()
;
i
++)
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
ch
=
encoded
.
charAt
(
i
);
if
(
ch
==
'+'
)
{
buff
[
j
++]
=
' '
;
...
...
@@ -485,18 +489,19 @@ public class StringUtils {
if
(
s
==
null
)
{
return
null
;
}
if
(
s
.
length
()
==
0
)
{
int
length
=
s
.
length
();
if
(
length
==
0
)
{
return
new
String
[
0
];
}
ArrayList
<
String
>
list
=
New
.
arrayList
();
StringBuilder
buff
=
new
StringBuilder
(
s
.
length
()
);
for
(
int
i
=
0
;
i
<
s
.
length
()
;
i
++)
{
StringBuilder
buff
=
new
StringBuilder
(
length
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
if
(
c
==
separatorChar
)
{
String
e
=
buff
.
toString
();
list
.
add
(
trim
?
e
.
trim
()
:
e
);
buff
.
setLength
(
0
);
}
else
if
(
c
==
'\\'
&&
i
<
s
.
length
()
-
1
)
{
}
else
if
(
c
==
'\\'
&&
i
<
length
-
1
)
{
buff
.
append
(
s
.
charAt
(++
i
));
}
else
{
buff
.
append
(
c
);
...
...
@@ -525,7 +530,7 @@ public class StringUtils {
if
(
s
==
null
)
{
s
=
""
;
}
for
(
int
j
=
0
;
j
<
s
.
length
()
;
j
++)
{
for
(
int
j
=
0
,
length
=
s
.
length
();
j
<
length
;
j
++)
{
char
c
=
s
.
charAt
(
j
);
if
(
c
==
'\\'
||
c
==
separatorChar
)
{
buff
.
append
(
'\\'
);
...
...
@@ -656,8 +661,9 @@ public class StringUtils {
* @return the escaped text
*/
public
static
String
xmlText
(
String
text
)
{
StringBuilder
buff
=
new
StringBuilder
(
text
.
length
());
for
(
int
i
=
0
;
i
<
text
.
length
();
i
++)
{
int
length
=
text
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
length
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
ch
=
text
.
charAt
(
i
);
switch
(
ch
)
{
case
'<'
:
...
...
@@ -745,9 +751,10 @@ public class StringUtils {
* @return the double quoted text
*/
public
static
String
quoteIdentifier
(
String
s
)
{
StringBuilder
buff
=
new
StringBuilder
(
s
.
length
()
+
2
);
int
length
=
s
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
length
+
2
);
buff
.
append
(
'\"'
);
for
(
int
i
=
0
;
i
<
s
.
length
()
;
i
++)
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
if
(
c
==
'"'
)
{
buff
.
append
(
c
);
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
645494c4
...
...
@@ -351,7 +351,7 @@ public class DataType {
new
String
[]{
"RESULT_SET"
},
400
);
for
(
int
i
=
0
;
i
<
TYPES_BY_VALUE_TYPE
.
size
()
;
i
++)
{
for
(
int
i
=
0
,
size
=
TYPES_BY_VALUE_TYPE
.
size
();
i
<
size
;
i
++)
{
DataType
dt
=
TYPES_BY_VALUE_TYPE
.
get
(
i
);
if
(
dt
==
null
)
{
DbException
.
throwInternalError
(
"unmapped type "
+
i
);
...
...
h2/src/main/org/h2/value/ValueUuid.java
浏览文件 @
645494c4
...
...
@@ -90,7 +90,7 @@ public class ValueUuid extends Value {
*/
public
static
ValueUuid
get
(
String
s
)
{
long
low
=
0
,
high
=
0
;
for
(
int
i
=
0
,
j
=
0
;
i
<
s
.
length
()
;
i
++)
{
for
(
int
i
=
0
,
j
=
0
,
length
=
s
.
length
();
i
<
length
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
if
(
c
>=
'0'
&&
c
<=
'9'
)
{
low
=
(
low
<<
4
)
|
(
c
-
'0'
);
...
...
h2/src/test/org/h2/test/db/TestRunscript.java
浏览文件 @
645494c4
...
...
@@ -43,11 +43,11 @@ public class TestRunscript extends TestBase implements Trigger {
Connection
conn
;
conn
=
getConnection
(
"runscript"
);
final
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key) as select x from system_range(1,
1
0000)"
);
stat
.
execute
(
"create table test(id int primary key) as select x from system_range(1,
2
0000)"
);
stat
.
execute
(
"script simple drop to '"
+
getBaseDir
()+
"/backup.sql'"
);
stat
.
execute
(
"set throttle 1000"
);
// need to wait a bit (throttle is only used every 50 ms)
Thread
.
sleep
(
1
00
);
Thread
.
sleep
(
2
00
);
final
String
dir
=
getBaseDir
();
final
SQLException
[]
ex
=
new
SQLException
[
1
];
Thread
thread
;
...
...
@@ -62,7 +62,7 @@ public class TestRunscript extends TestBase implements Trigger {
}
};
thread
.
start
();
Thread
.
sleep
(
1
00
);
Thread
.
sleep
(
2
00
);
stat
.
cancel
();
thread
.
join
();
e
=
ex
[
0
];
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论