Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bfcce888
提交
bfcce888
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use generics
上级
7d2c7659
隐藏空白字符变更
内嵌
并排
正在显示
46 个修改的文件
包含
171 行增加
和
309 行删除
+171
-309
RuleList.java
h2/src/main/org/h2/bnf/RuleList.java
+9
-12
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+2
-2
Optimizer.java
h2/src/main/org/h2/command/dml/Optimizer.java
+5
-5
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+4
-5
Database.java
h2/src/main/org/h2/engine/Database.java
+12
-25
Engine.java
h2/src/main/org/h2/engine/Engine.java
+1
-3
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+1
-2
Role.java
h2/src/main/org/h2/engine/Role.java
+3
-10
Session.java
h2/src/main/org/h2/engine/Session.java
+3
-5
SessionRemote.java
h2/src/main/org/h2/engine/SessionRemote.java
+4
-8
SessionWithState.java
h2/src/main/org/h2/engine/SessionWithState.java
+1
-2
User.java
h2/src/main/org/h2/engine/User.java
+4
-12
FullText.java
h2/src/main/org/h2/fulltext/FullText.java
+6
-7
FullTextLucene.java
h2/src/main/org/h2/fulltext/FullTextLucene.java
+2
-3
JdbcPreparedStatement.java
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
+1
-2
JdbcXAConnection.java
h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
+1
-2
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+2
-4
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+1
-2
DbContents.java
h2/src/main/org/h2/server/web/DbContents.java
+6
-6
DbSchema.java
h2/src/main/org/h2/server/web/DbSchema.java
+1
-2
WebServer.java
h2/src/main/org/h2/server/web/WebServer.java
+3
-5
WebThread.java
h2/src/main/org/h2/server/web/WebThread.java
+6
-12
FileObjectSplit.java
h2/src/main/org/h2/store/fs/FileObjectSplit.java
+4
-4
IndexColumn.java
h2/src/main/org/h2/table/IndexColumn.java
+1
-2
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+30
-74
Plan.java
h2/src/main/org/h2/table/Plan.java
+4
-6
Table.java
h2/src/main/org/h2/table/Table.java
+12
-20
TableData.java
h2/src/main/org/h2/table/TableData.java
+5
-8
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+2
-4
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+1
-2
TableView.java
h2/src/main/org/h2/table/TableView.java
+3
-6
ChangeFileEncryption.java
h2/src/main/org/h2/tools/ChangeFileEncryption.java
+2
-4
Csv.java
h2/src/main/org/h2/tools/Csv.java
+2
-2
DeleteDbFiles.java
h2/src/main/org/h2/tools/DeleteDbFiles.java
+1
-2
MultiDimension.java
h2/src/main/org/h2/tools/MultiDimension.java
+2
-2
Recover.java
h2/src/main/org/h2/tools/Recover.java
+1
-2
Shell.java
h2/src/main/org/h2/tools/Shell.java
+1
-2
ClassUtils.java
h2/src/main/org/h2/util/ClassUtils.java
+1
-2
NetUtils.java
h2/src/main/org/h2/util/NetUtils.java
+1
-3
RandomUtils.java
h2/src/main/org/h2/util/RandomUtils.java
+2
-2
StartBrowser.java
h2/src/main/org/h2/util/StartBrowser.java
+2
-2
ValueHashMap.java
h2/src/main/org/h2/util/ValueHashMap.java
+1
-2
CompareMode.java
h2/src/main/org/h2/value/CompareMode.java
+1
-3
Transfer.java
h2/src/main/org/h2/value/Transfer.java
+2
-2
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+6
-6
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+6
-11
没有找到文件。
h2/src/main/org/h2/bnf/RuleList.java
浏览文件 @
bfcce888
...
...
@@ -69,8 +69,8 @@ public class RuleList implements Rule {
return
get
(
idx
).
random
(
config
,
level
+
1
);
}
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++
)
{
buff
.
append
(
get
(
i
)
.
random
(
config
,
level
+
1
));
for
(
Rule
r
:
list
)
{
buff
.
append
(
r
.
random
(
config
,
level
+
1
));
}
return
buff
.
toString
();
}
...
...
@@ -89,8 +89,8 @@ public class RuleList implements Rule {
public
void
setLinks
(
HashMap
<
String
,
RuleHead
>
ruleMap
)
{
if
(!
mapSet
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++
)
{
get
(
i
)
.
setLinks
(
ruleMap
);
for
(
Rule
r
:
list
)
{
r
.
setLinks
(
ruleMap
);
}
mapSet
=
true
;
}
...
...
@@ -102,15 +102,14 @@ public class RuleList implements Rule {
return
false
;
}
if
(
or
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++
)
{
if
(
get
(
i
)
.
matchRemove
(
sentence
))
{
for
(
Rule
r
:
list
)
{
if
(
r
.
matchRemove
(
sentence
))
{
return
true
;
}
}
return
false
;
}
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Rule
r
=
get
(
i
);
for
(
Rule
r
:
list
)
{
if
(!
r
.
matchRemove
(
sentence
))
{
return
false
;
}
...
...
@@ -121,14 +120,12 @@ public class RuleList implements Rule {
public
void
addNextTokenList
(
Sentence
sentence
)
{
String
old
=
sentence
.
getQuery
();
if
(
or
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++
)
{
for
(
Rule
r
:
list
)
{
sentence
.
setQuery
(
old
);
Rule
r
=
get
(
i
);
r
.
addNextTokenList
(
sentence
);
}
}
else
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Rule
r
=
get
(
i
);
for
(
Rule
r
:
list
)
{
r
.
addNextTokenList
(
sentence
);
if
(!
r
.
matchRemove
(
sentence
))
{
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
bfcce888
...
...
@@ -351,8 +351,8 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
boolean
dropIndex
=
false
;
Column
[]
cols
=
index
.
getColumns
();
for
(
int
j
=
0
;
j
<
cols
.
length
;
j
++
)
{
if
(
c
ols
[
j
]
==
oldColumn
)
{
for
(
Column
c
:
cols
)
{
if
(
c
==
oldColumn
)
{
if
(
cols
.
length
==
1
)
{
dropIndex
=
true
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Optimizer.java
浏览文件 @
bfcce888
...
...
@@ -116,8 +116,8 @@ public class Optimizer {
Permutations
p
=
new
Permutations
(
filters
,
list
,
bruteForce
);
for
(
int
x
=
0
;
!
canStop
(
x
)
&&
p
.
next
();
x
++)
{
// find out what filters are not used yet
for
(
int
i
=
0
;
i
<
filters
.
length
;
i
++
)
{
f
ilters
[
i
]
.
setUsed
(
false
);
for
(
TableFilter
f
:
filters
)
{
f
.
setUsed
(
false
);
}
for
(
int
i
=
0
;
i
<
bruteForce
;
i
++)
{
list
[
i
].
setUsed
(
true
);
...
...
@@ -237,9 +237,9 @@ public class Optimizer {
for
(
int
i
=
0
;
i
<
f2
.
length
-
1
;
i
++)
{
f2
[
i
].
addJoin
(
f2
[
i
+
1
],
false
,
null
);
}
for
(
int
i
=
0
;
i
<
f2
.
length
;
i
++
)
{
PlanItem
item
=
bestPlan
.
getItem
(
f
2
[
i
]
);
f
2
[
i
]
.
setPlanItem
(
item
);
for
(
TableFilter
f
:
f2
)
{
PlanItem
item
=
bestPlan
.
getItem
(
f
);
f
.
setPlanItem
(
item
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
bfcce888
...
...
@@ -171,13 +171,13 @@ public class ConnectionInfo implements Cloneable {
private
void
readProperties
(
Properties
info
)
throws
SQLException
{
Object
[]
list
=
new
Object
[
info
.
size
()];
info
.
keySet
().
toArray
(
list
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++
)
{
String
key
=
StringUtils
.
toUpperEnglish
(
list
[
i
]
.
toString
());
for
(
Object
k
:
list
)
{
String
key
=
StringUtils
.
toUpperEnglish
(
k
.
toString
());
if
(
prop
.
containsKey
(
key
))
{
throw
Message
.
getSQLException
(
ErrorCode
.
DUPLICATE_PROPERTY_1
,
key
);
}
if
(
isKnownSetting
(
key
))
{
prop
.
put
(
key
,
info
.
get
(
list
[
i
]
));
prop
.
put
(
key
,
info
.
get
(
k
));
}
}
}
...
...
@@ -188,8 +188,7 @@ public class ConnectionInfo implements Cloneable {
String
settings
=
url
.
substring
(
idx
+
1
);
url
=
url
.
substring
(
0
,
idx
);
String
[]
list
=
StringUtils
.
arraySplit
(
settings
,
';'
,
false
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
String
setting
=
list
[
i
];
for
(
String
setting
:
list
)
{
int
equal
=
setting
.
indexOf
(
'='
);
if
(
equal
<
0
)
{
throw
getFormatException
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
bfcce888
...
...
@@ -643,8 +643,7 @@ public class Database implements DataHandler {
records
.
add
(
rec
);
}
MetaRecord
.
sort
(
records
);
for
(
int
i
=
0
;
i
<
records
.
size
();
i
++)
{
MetaRecord
rec
=
records
.
get
(
i
);
for
(
MetaRecord
rec
:
records
)
{
rec
.
execute
(
this
,
systemSession
,
eventListener
);
}
// try to recompile the views that are invalid
...
...
@@ -729,8 +728,7 @@ public class Database implements DataHandler {
private
void
removeUnusedStorages
(
Session
session
)
throws
SQLException
{
if
(
persistent
)
{
ObjectArray
<
Storage
>
storages
=
getAllStorages
();
for
(
int
i
=
0
;
i
<
storages
.
size
();
i
++)
{
Storage
storage
=
storages
.
get
(
i
);
for
(
Storage
storage
:
storages
)
{
if
(
storage
!=
null
&&
storage
.
getRecordReader
()
==
null
)
{
storage
.
truncate
(
session
);
}
...
...
@@ -1104,8 +1102,7 @@ public class Database implements DataHandler {
traceSystem
.
getTrace
(
Trace
.
DATABASE
).
info
(
"closing "
+
databaseName
+
" from shutdown hook"
);
Session
[]
all
=
new
Session
[
userSessions
.
size
()];
userSessions
.
toArray
(
all
);
for
(
int
i
=
0
;
i
<
all
.
length
;
i
++)
{
Session
s
=
all
[
i
];
for
(
Session
s
:
all
)
{
try
{
// must roll back, otherwise the session is removed and
// the log file that contains its uncommitted operations as well
...
...
@@ -1135,19 +1132,15 @@ public class Database implements DataHandler {
}
try
{
if
(
systemSession
!=
null
)
{
ObjectArray
<
Table
>
tablesAndViews
=
getAllTablesAndViews
();
for
(
int
i
=
0
;
i
<
tablesAndViews
.
size
();
i
++)
{
Table
table
=
tablesAndViews
.
get
(
i
);
for
(
Table
table
:
getAllTablesAndViews
())
{
table
.
close
(
systemSession
);
}
ObjectArray
<
SchemaObject
>
sequences
=
getAllSchemaObjects
(
DbObject
.
SEQUENCE
);
for
(
int
i
=
0
;
i
<
sequences
.
size
();
i
++)
{
Sequence
sequence
=
(
Sequence
)
sequences
.
get
(
i
);
for
(
SchemaObject
obj
:
getAllSchemaObjects
(
DbObject
.
SEQUENCE
))
{
Sequence
sequence
=
(
Sequence
)
obj
;
sequence
.
close
();
}
ObjectArray
<
SchemaObject
>
triggers
=
getAllSchemaObjects
(
DbObject
.
TRIGGER
);
for
(
int
i
=
0
;
i
<
triggers
.
size
();
i
++)
{
TriggerObject
trigger
=
(
TriggerObject
)
triggers
.
get
(
i
);
for
(
SchemaObject
obj
:
getAllSchemaObjects
(
DbObject
.
TRIGGER
))
{
TriggerObject
trigger
=
(
TriggerObject
)
obj
;
trigger
.
close
();
}
meta
.
close
(
systemSession
);
...
...
@@ -1519,8 +1512,7 @@ public class Database implements DataHandler {
String
prefix
=
FileUtils
.
normalize
(
databaseName
)
+
"."
;
String
path
=
FileUtils
.
getParent
(
databaseName
);
String
[]
list
=
FileUtils
.
listFiles
(
path
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
String
name
=
list
[
i
];
for
(
String
name
:
list
)
{
if
(
name
.
endsWith
(
Constants
.
SUFFIX_LOB_FILE
)
&&
FileUtils
.
fileStartsWith
(
name
,
prefix
))
{
name
=
name
.
substring
(
prefix
.
length
());
name
=
name
.
substring
(
0
,
name
.
length
()
-
Constants
.
SUFFIX_LOB_FILE
.
length
());
...
...
@@ -1538,8 +1530,7 @@ public class Database implements DataHandler {
String
path
=
FileUtils
.
getParent
(
databaseName
);
String
prefix
=
FileUtils
.
normalize
(
databaseName
);
String
[]
list
=
FileUtils
.
listFiles
(
path
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
String
name
=
list
[
i
];
for
(
String
name
:
list
)
{
if
(
name
.
endsWith
(
Constants
.
SUFFIX_TEMP_FILE
)
&&
FileUtils
.
fileStartsWith
(
name
,
prefix
))
{
// can't always delete the files, they may still be open
FileUtils
.
tryDelete
(
name
);
...
...
@@ -2218,9 +2209,7 @@ public class Database implements DataHandler {
* @return the table or null if no table is defined
*/
public
Table
getFirstUserTable
()
{
ObjectArray
<
Table
>
array
=
getAllTablesAndViews
();
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
Table
table
=
array
.
get
(
i
);
for
(
Table
table
:
getAllTablesAndViews
())
{
if
(
table
.
getCreateSQL
()
!=
null
)
{
return
table
;
}
...
...
@@ -2307,9 +2296,7 @@ public class Database implements DataHandler {
* afterwards are not flushed; 0 to flush all indexes
*/
public
synchronized
void
flushIndexes
(
long
maxLastChange
)
{
ObjectArray
<
SchemaObject
>
array
=
getAllSchemaObjects
(
DbObject
.
INDEX
);
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
SchemaObject
obj
=
array
.
get
(
i
);
for
(
SchemaObject
obj
:
getAllSchemaObjects
(
DbObject
.
INDEX
))
{
if
(
obj
instanceof
BtreeIndex
)
{
BtreeIndex
idx
=
(
BtreeIndex
)
obj
;
if
(
idx
.
getLastChange
()
==
0
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Engine.java
浏览文件 @
bfcce888
...
...
@@ -149,10 +149,8 @@ public class Engine {
// ignore
}
}
String
[]
keys
=
ci
.
getKeys
();
session
.
setAllowLiterals
(
true
);
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
String
setting
=
keys
[
i
];
for
(
String
setting
:
ci
.
getKeys
())
{
String
value
=
ci
.
getProperty
(
setting
);
try
{
CommandInterface
command
=
session
.
prepareCommand
(
"SET "
+
Parser
.
quoteIdentifier
(
setting
)
+
" "
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
bfcce888
...
...
@@ -165,8 +165,7 @@ public class FunctionAlias extends DbObjectBase {
public
JavaMethod
findJavaMethod
(
Expression
[]
args
)
throws
SQLException
{
load
();
int
parameterCount
=
args
.
length
;
for
(
int
i
=
0
;
i
<
javaMethods
.
length
;
i
++)
{
JavaMethod
m
=
javaMethods
[
i
];
for
(
JavaMethod
m
:
javaMethods
)
{
int
count
=
m
.
getParameterCount
();
if
(
count
==
parameterCount
||
(
m
.
isVarArgs
()
&&
count
<=
parameterCount
+
1
))
{
return
m
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Role.java
浏览文件 @
bfcce888
...
...
@@ -11,7 +11,6 @@ import java.sql.SQLException;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
import
org.h2.table.Table
;
import
org.h2.util.ObjectArray
;
/**
* Represents a role. Roles can be granted to users, and to other roles.
...
...
@@ -60,25 +59,19 @@ public class Role extends RightOwner {
}
public
void
removeChildrenAndResources
(
Session
session
)
throws
SQLException
{
ObjectArray
<
User
>
users
=
database
.
getAllUsers
();
for
(
int
i
=
0
;
i
<
users
.
size
();
i
++)
{
User
user
=
users
.
get
(
i
);
for
(
User
user
:
database
.
getAllUsers
())
{
Right
right
=
user
.
getRightForRole
(
this
);
if
(
right
!=
null
)
{
database
.
removeDatabaseObject
(
session
,
right
);
}
}
ObjectArray
<
Role
>
roles
=
database
.
getAllRoles
();
for
(
int
i
=
0
;
i
<
roles
.
size
();
i
++)
{
Role
r2
=
roles
.
get
(
i
);
for
(
Role
r2
:
database
.
getAllRoles
())
{
Right
right
=
r2
.
getRightForRole
(
this
);
if
(
right
!=
null
)
{
database
.
removeDatabaseObject
(
session
,
right
);
}
}
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
rights
.
get
(
i
);
for
(
Right
right
:
database
.
getAllRights
())
{
if
(
right
.
getGrantee
()
==
this
)
{
database
.
removeDatabaseObject
(
session
,
right
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
bfcce888
...
...
@@ -526,9 +526,8 @@ public class Session extends SessionWithState {
if
(
savepoints
!=
null
)
{
String
[]
names
=
new
String
[
savepoints
.
size
()];
savepoints
.
keySet
().
toArray
(
names
);
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
String
name
=
names
[
i
];
Integer
savepointIndex
=
savepoints
.
get
(
names
[
i
]);
for
(
String
name
:
names
)
{
Integer
savepointIndex
=
savepoints
.
get
(
name
);
if
(
savepointIndex
.
intValue
()
>
index
)
{
savepoints
.
remove
(
name
);
}
...
...
@@ -633,8 +632,7 @@ public class Session extends SessionWithState {
}
if
(
locks
.
size
()
>
0
)
{
synchronized
(
database
)
{
for
(
int
i
=
0
;
i
<
locks
.
size
();
i
++)
{
Table
t
=
locks
.
get
(
i
);
for
(
Table
t
:
locks
)
{
t
.
unlock
(
this
);
}
locks
.
clear
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
bfcce888
...
...
@@ -108,8 +108,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
trans
.
writeBytes
(
ci
.
getFilePasswordHash
());
String
[]
keys
=
ci
.
getKeys
();
trans
.
writeInt
(
keys
.
length
);
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
String
key
=
keys
[
i
];
for
(
String
key
:
keys
)
{
trans
.
writeString
(
key
).
writeString
(
ci
.
getProperty
(
key
));
}
try
{
...
...
@@ -141,8 +140,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
// older servers don't support this feature
return
;
}
for
(
int
i
=
0
;
i
<
transferList
.
size
();
i
++)
{
Transfer
transfer
=
transferList
.
get
(
i
);
for
(
Transfer
transfer
:
transferList
)
{
try
{
Transfer
trans
=
transfer
.
openNewConnection
();
trans
.
init
();
...
...
@@ -376,8 +374,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
if
(
clientVersion
>=
Constants
.
TCP_PROTOCOL_VERSION_6
)
{
sessionId
=
ByteUtils
.
convertBytesToString
(
RandomUtils
.
getSecureBytes
(
32
));
synchronized
(
this
)
{
for
(
int
i
=
0
;
i
<
transferList
.
size
();
i
++)
{
Transfer
transfer
=
transferList
.
get
(
i
);
for
(
Transfer
transfer
:
transferList
)
{
try
{
traceOperation
(
"SESSION_SET_ID"
,
0
);
transfer
.
writeInt
(
SessionRemote
.
SESSION_SET_ID
);
...
...
@@ -470,8 +467,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
public
void
close
()
throws
SQLException
{
if
(
transferList
!=
null
)
{
synchronized
(
this
)
{
for
(
int
i
=
0
;
i
<
transferList
.
size
();
i
++)
{
Transfer
transfer
=
transferList
.
get
(
i
);
for
(
Transfer
transfer
:
transferList
)
{
try
{
traceOperation
(
"SESSION_CLOSE"
,
0
);
transfer
.
writeInt
(
SessionRemote
.
SESSION_CLOSE
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/SessionWithState.java
浏览文件 @
bfcce888
...
...
@@ -28,8 +28,7 @@ public abstract class SessionWithState implements SessionInterface {
if
(
sessionState
!=
null
&&
sessionState
.
size
()
>
0
)
{
sessionStateUpdating
=
true
;
try
{
for
(
int
i
=
0
;
i
<
sessionState
.
size
();
i
++)
{
String
sql
=
sessionState
.
get
(
i
);
for
(
String
sql
:
sessionState
)
{
CommandInterface
ci
=
prepareCommand
(
sql
,
Integer
.
MAX_VALUE
);
ci
.
executeUpdate
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/User.java
浏览文件 @
bfcce888
...
...
@@ -189,16 +189,12 @@ public class User extends RightOwner {
public
ObjectArray
<
DbObject
>
getChildren
()
{
ObjectArray
<
DbObject
>
children
=
ObjectArray
.
newInstance
();
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
rights
.
get
(
i
);
for
(
Right
right
:
database
.
getAllRights
())
{
if
(
right
.
getGrantee
()
==
this
)
{
children
.
add
(
right
);
}
}
ObjectArray
<
Schema
>
schemas
=
database
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
schemas
.
size
();
i
++)
{
Schema
schema
=
schemas
.
get
(
i
);
for
(
Schema
schema
:
database
.
getAllSchemas
())
{
if
(
schema
.
getOwner
()
==
this
)
{
children
.
add
(
schema
);
}
...
...
@@ -207,9 +203,7 @@ public class User extends RightOwner {
}
public
void
removeChildrenAndResources
(
Session
session
)
throws
SQLException
{
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
rights
.
get
(
i
);
for
(
Right
right
:
database
.
getAllRights
())
{
if
(
right
.
getGrantee
()
==
this
)
{
database
.
removeDatabaseObject
(
session
,
right
);
}
...
...
@@ -232,9 +226,7 @@ public class User extends RightOwner {
* @throws SQLException if this user owns a schema
*/
public
void
checkOwnsNoSchemas
()
throws
SQLException
{
ObjectArray
<
Schema
>
schemas
=
database
.
getAllSchemas
();
for
(
int
i
=
0
;
i
<
schemas
.
size
();
i
++)
{
Schema
s
=
schemas
.
get
(
i
);
for
(
Schema
s
:
database
.
getAllSchemas
())
{
if
(
this
==
s
.
getOwner
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
CANNOT_DROP_2
,
new
String
[]{
getName
(),
s
.
getName
()
});
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/fulltext/FullText.java
浏览文件 @
bfcce888
...
...
@@ -739,9 +739,8 @@ public class FullText {
index
.
id
=
rs
.
getInt
(
1
);
String
columns
=
rs
.
getString
(
2
);
if
(
columns
!=
null
)
{
String
[]
list
=
StringUtils
.
arraySplit
(
columns
,
','
,
true
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
indexList
.
add
(
list
[
i
]);
for
(
String
s
:
StringUtils
.
arraySplit
(
columns
,
','
,
true
))
{
indexList
.
add
(
s
);
}
}
}
...
...
@@ -813,8 +812,8 @@ public class FullText {
int
rowId
=
rs
.
getInt
(
1
);
prepInsertMap
.
setInt
(
1
,
rowId
);
int
[]
wordIds
=
getWordIds
(
setting
,
row
);
for
(
int
i
=
0
;
i
<
wordIds
.
length
;
i
++
)
{
prepInsertMap
.
setInt
(
2
,
wordIds
[
i
]
);
for
(
int
i
d
:
wordIds
)
{
prepInsertMap
.
setInt
(
2
,
id
);
prepInsertMap
.
execute
();
}
}
...
...
@@ -830,8 +829,8 @@ public class FullText {
int
rowId
=
rs
.
getInt
(
1
);
prepDeleteMap
.
setInt
(
1
,
rowId
);
int
[]
wordIds
=
getWordIds
(
setting
,
row
);
for
(
int
i
=
0
;
i
<
wordIds
.
length
;
i
++
)
{
prepDeleteMap
.
setInt
(
2
,
wordIds
[
i
]
);
for
(
int
i
d
:
wordIds
)
{
prepDeleteMap
.
setInt
(
2
,
id
);
prepDeleteMap
.
executeUpdate
();
}
prepDeleteRow
.
setInt
(
1
,
hash
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/fulltext/FullTextLucene.java
浏览文件 @
bfcce888
...
...
@@ -443,9 +443,8 @@ public class FullTextLucene extends FullText {
if
(
rs
.
next
())
{
String
columns
=
rs
.
getString
(
1
);
if
(
columns
!=
null
)
{
String
[]
list
=
StringUtils
.
arraySplit
(
columns
,
','
,
true
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
indexList
.
add
(
list
[
i
]);
for
(
String
s
:
StringUtils
.
arraySplit
(
columns
,
','
,
true
))
{
indexList
.
add
(
s
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
浏览文件 @
bfcce888
...
...
@@ -194,8 +194,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
debugCodeCall
(
"clearParameters"
);
checkClosed
();
ObjectArray
<
?
extends
ParameterInterface
>
parameters
=
command
.
getParameters
();
for
(
int
i
=
0
;
i
<
parameters
.
size
();
i
++)
{
ParameterInterface
param
=
parameters
.
get
(
i
);
for
(
ParameterInterface
param
:
parameters
)
{
// can only delete old temp files if they are not in the batch
param
.
setValue
(
null
,
batchParameters
==
null
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
浏览文件 @
bfcce888
...
...
@@ -154,8 +154,7 @@ implements XAConnection, XAResource
//## Java 1.4 begin ##
void
closedHandle
()
{
debugCode
(
"closedHandle();"
);
for
(
int
i
=
0
;
i
<
listeners
.
size
();
i
++)
{
ConnectionEventListener
listener
=
listeners
.
get
(
i
);
for
(
ConnectionEventListener
listener
:
New
.
arrayList
(
listeners
))
{
ConnectionEvent
event
=
new
ConnectionEvent
(
this
);
listener
.
connectionClosed
(
event
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
bfcce888
...
...
@@ -224,12 +224,10 @@ public class TcpServerThread implements Runnable {
cache
.
addObject
(
id
,
command
);
boolean
isQuery
=
command
.
isQuery
();
ObjectArray
<
?
extends
ParameterInterface
>
params
=
command
.
getParameters
();
int
paramCount
=
params
.
size
();
transfer
.
writeInt
(
getState
(
old
)).
writeBoolean
(
isQuery
).
writeBoolean
(
readonly
)
.
writeInt
(
param
Count
);
.
writeInt
(
param
s
.
size
()
);
if
(
operation
==
SessionRemote
.
SESSION_PREPARE_READ_PARAMS
)
{
for
(
int
i
=
0
;
i
<
paramCount
;
i
++)
{
ParameterInterface
p
=
params
.
get
(
i
);
for
(
ParameterInterface
p
:
params
)
{
ParameterRemote
.
writeMetaData
(
transfer
,
p
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
bfcce888
...
...
@@ -427,8 +427,7 @@ public class PgServerThread implements Runnable {
}
startMessage
(
'D'
);
writeShort
(
columns
);
for
(
int
i
=
0
;
i
<
columns
;
i
++)
{
String
s
=
values
[
i
];
for
(
String
s
:
values
)
{
if
(
s
==
null
)
{
writeInt
(-
1
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/DbContents.java
浏览文件 @
bfcce888
...
...
@@ -132,15 +132,15 @@ public class DbContents {
}
if
(
defaultSchema
==
null
)
{
String
best
=
null
;
for
(
int
i
=
0
;
i
<
schemas
.
length
;
i
++
)
{
if
(
"dbo"
.
equals
(
schema
s
[
i
]
.
name
))
{
for
(
DbSchema
schema
:
schemas
)
{
if
(
"dbo"
.
equals
(
schema
.
name
))
{
// MS SQL Server
defaultSchema
=
schema
s
[
i
]
;
defaultSchema
=
schema
;
break
;
}
if
(
defaultSchema
==
null
||
best
==
null
||
schema
s
[
i
]
.
name
.
length
()
<
best
.
length
())
{
best
=
schema
s
[
i
]
.
name
;
defaultSchema
=
schema
s
[
i
]
;
if
(
defaultSchema
==
null
||
best
==
null
||
schema
.
name
.
length
()
<
best
.
length
())
{
best
=
schema
.
name
;
defaultSchema
=
schema
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/DbSchema.java
浏览文件 @
bfcce888
...
...
@@ -80,8 +80,7 @@ public class DbSchema {
tables
=
new
DbTableOrView
[
list
.
size
()];
list
.
toArray
(
tables
);
if
(
tables
.
length
<
MAX_TABLES_LIST_COLUMNS
)
{
for
(
int
i
=
0
;
i
<
tables
.
length
;
i
++)
{
DbTableOrView
tab
=
tables
[
i
];
for
(
DbTableOrView
tab
:
tables
)
{
tab
.
readColumns
(
meta
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebServer.java
浏览文件 @
bfcce888
...
...
@@ -173,9 +173,7 @@ public class WebServer implements Service {
WebSession
getSession
(
String
sessionId
)
{
long
now
=
System
.
currentTimeMillis
();
if
(
lastTimeoutCheck
+
SESSION_TIMEOUT
<
now
)
{
Object
[]
list
=
sessions
.
keySet
().
toArray
();
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
String
id
=
(
String
)
list
[
i
];
for
(
String
id
:
New
.
arrayList
(
sessions
.
keySet
()))
{
WebSession
session
=
sessions
.
get
(
id
);
Long
last
=
(
Long
)
session
.
get
(
"lastAccess"
);
if
(
last
!=
null
&&
last
.
longValue
()
+
SESSION_TIMEOUT
<
now
)
{
...
...
@@ -280,8 +278,8 @@ public class WebServer implements Service {
startDateTime
=
format
.
format
(
new
Date
());
}
trace
(
startDateTime
);
for
(
int
i
=
0
;
i
<
LANGUAGES
.
length
;
i
++
)
{
languages
.
add
(
LANGUAGES
[
i
]
[
0
]);
for
(
String
[]
lang
:
LANGUAGES
)
{
languages
.
add
(
lang
[
0
]);
}
updateURL
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebThread.java
浏览文件 @
bfcce888
...
...
@@ -286,8 +286,7 @@ class WebThread extends Thread implements DatabaseEventListener {
private
String
getComboBox
(
String
[]
elements
,
String
selected
)
{
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
elements
.
length
;
i
++)
{
String
value
=
elements
[
i
];
for
(
String
value
:
elements
)
{
buff
.
append
(
"<option value=\""
);
buff
.
append
(
PageParser
.
escapeHtmlData
(
value
));
buff
.
append
(
"\""
);
...
...
@@ -303,8 +302,7 @@ class WebThread extends Thread implements DatabaseEventListener {
private
String
getComboBox
(
String
[][]
elements
,
String
selected
)
{
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
elements
.
length
;
i
++)
{
String
[]
n
=
elements
[
i
];
for
(
String
[]
n
:
elements
)
{
buff
.
append
(
"<option value=\""
);
buff
.
append
(
PageParser
.
escapeHtmlData
(
n
[
0
]));
buff
.
append
(
"\""
);
...
...
@@ -797,8 +795,7 @@ class WebThread extends Thread implements DatabaseEventListener {
}
boolean
isOracle
=
schema
.
contents
.
isOracle
;
boolean
notManyTables
=
tables
.
length
<
DbSchema
.
MAX_TABLES_LIST_INDEXES
;
for
(
int
i
=
0
;
i
<
tables
.
length
;
i
++)
{
DbTableOrView
table
=
tables
[
i
];
for
(
DbTableOrView
table
:
tables
)
{
if
(
table
.
isView
)
{
continue
;
}
...
...
@@ -822,8 +819,7 @@ class WebThread extends Thread implements DatabaseEventListener {
}
}
tables
=
schema
.
tables
;
for
(
int
i
=
0
;
i
<
tables
.
length
;
i
++)
{
DbTableOrView
view
=
tables
[
i
];
for
(
DbTableOrView
view
:
tables
)
{
if
(!
view
.
isView
)
{
continue
;
}
...
...
@@ -881,8 +877,7 @@ class WebThread extends Thread implements DatabaseEventListener {
DbSchema
defaultSchema
=
contents
.
defaultSchema
;
treeIndex
=
addTablesAndViews
(
defaultSchema
,
true
,
buff
,
treeIndex
);
DbSchema
[]
schemas
=
contents
.
schemas
;
for
(
int
i
=
0
;
i
<
schemas
.
length
;
i
++)
{
DbSchema
schema
=
schemas
[
i
];
for
(
DbSchema
schema
:
schemas
)
{
if
(
schema
==
defaultSchema
||
schema
==
null
)
{
continue
;
}
...
...
@@ -1360,8 +1355,7 @@ class WebThread extends Thread implements DatabaseEventListener {
DynamicClassLoader
cl
=
new
DynamicClassLoader
(
"Java"
,
data
);
Class
<
?
>
clazz
=
cl
.
loadClass
(
"Java"
);
Method
[]
methods
=
clazz
.
getMethods
();
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
Method
m
=
methods
[
i
];
for
(
Method
m
:
methods
)
{
if
(
m
.
getName
().
equals
(
"run"
))
{
return
""
+
m
.
invoke
(
null
,
new
Object
[
0
]);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileObjectSplit.java
浏览文件 @
bfcce888
...
...
@@ -33,8 +33,8 @@ public class FileObjectSplit implements FileObject {
}
public
void
close
()
throws
IOException
{
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++
)
{
list
[
i
]
.
close
();
for
(
FileObject
f
:
list
)
{
f
.
close
();
}
}
...
...
@@ -123,8 +123,8 @@ public class FileObjectSplit implements FileObject {
}
public
void
sync
()
throws
IOException
{
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++
)
{
list
[
i
]
.
sync
();
for
(
FileObject
f
:
list
)
{
f
.
sync
();
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/IndexColumn.java
浏览文件 @
bfcce888
...
...
@@ -73,8 +73,7 @@ public class IndexColumn {
* @param table the table from where to map the column names to columns
*/
public
static
void
mapColumns
(
IndexColumn
[]
indexColumns
,
Table
table
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
indexColumns
.
length
;
i
++)
{
IndexColumn
col
=
indexColumns
[
i
];
for
(
IndexColumn
col
:
indexColumns
)
{
col
.
column
=
table
.
getColumn
(
col
.
columnName
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
bfcce888
...
...
@@ -617,9 +617,7 @@ public class MetaTable extends Table {
String
catalog
=
identifier
(
database
.
getShortName
());
switch
(
type
)
{
case
TABLES:
{
ObjectArray
<
Table
>
tables
=
getAllTables
(
session
);
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
getAllTables
(
session
))
{
String
tableName
=
identifier
(
table
.
getName
());
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
...
...
@@ -658,9 +656,7 @@ public class MetaTable extends Table {
break
;
}
case
COLUMNS:
{
ObjectArray
<
Table
>
tables
=
getAllTables
(
session
);
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
getAllTables
(
session
))
{
String
tableName
=
identifier
(
table
.
getName
());
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
...
...
@@ -721,9 +717,7 @@ public class MetaTable extends Table {
break
;
}
case
INDEXES:
{
ObjectArray
<
Table
>
tables
=
getAllTables
(
session
);
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
getAllTables
(
session
))
{
String
tableName
=
identifier
(
table
.
getName
());
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
...
...
@@ -827,8 +821,7 @@ public class MetaTable extends Table {
"file.separator"
,
"path.separator"
,
"line.separator"
,
"user.country"
,
"user.language"
,
"user.variant"
,
"file.encoding"
};
for
(
int
i
=
0
;
i
<
settings
.
length
;
i
++)
{
String
s
=
settings
[
i
];
for
(
String
s
:
settings
)
{
add
(
rows
,
new
String
[]
{
"property."
+
s
,
SysProperties
.
getStringSetting
(
s
,
""
)
});
}
}
...
...
@@ -951,9 +944,8 @@ public class MetaTable extends Table {
break
;
}
case
SEQUENCES:
{
ObjectArray
<
SchemaObject
>
sequences
=
database
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
);
for
(
int
i
=
0
;
i
<
sequences
.
size
();
i
++)
{
Sequence
s
=
(
Sequence
)
sequences
.
get
(
i
);
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
))
{
Sequence
s
=
(
Sequence
)
obj
;
add
(
rows
,
new
String
[]
{
// SEQUENCE_CATALOG
catalog
,
...
...
@@ -978,9 +970,7 @@ public class MetaTable extends Table {
break
;
}
case
USERS:
{
ObjectArray
<
User
>
users
=
database
.
getAllUsers
();
for
(
int
i
=
0
;
i
<
users
.
size
();
i
++)
{
User
u
=
users
.
get
(
i
);
for
(
User
u
:
database
.
getAllUsers
())
{
add
(
rows
,
new
String
[]
{
// NAME
identifier
(
u
.
getName
()),
...
...
@@ -995,9 +985,7 @@ public class MetaTable extends Table {
break
;
}
case
ROLES:
{
ObjectArray
<
Role
>
roles
=
database
.
getAllRoles
();
for
(
int
i
=
0
;
i
<
roles
.
size
();
i
++)
{
Role
r
=
roles
.
get
(
i
);
for
(
Role
r
:
database
.
getAllRoles
())
{
add
(
rows
,
new
String
[]
{
// NAME
identifier
(
r
.
getName
()),
...
...
@@ -1010,9 +998,7 @@ public class MetaTable extends Table {
break
;
}
case
RIGHTS:
{
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
r
=
rights
.
get
(
i
);
for
(
Right
r
:
database
.
getAllRights
())
{
Role
role
=
r
.
getGrantedRole
();
DbObject
grantee
=
r
.
getGrantee
();
String
type
=
grantee
.
getType
()
==
DbObject
.
USER
?
"USER"
:
"ROLE"
;
...
...
@@ -1060,9 +1046,7 @@ public class MetaTable extends Table {
break
;
}
case
FUNCTION_ALIASES:
{
ObjectArray
<
FunctionAlias
>
aliases
=
database
.
getAllFunctionAliases
();
for
(
int
i
=
0
;
i
<
aliases
.
size
();
i
++)
{
FunctionAlias
alias
=
aliases
.
get
(
i
);
for
(
FunctionAlias
alias
:
database
.
getAllFunctionAliases
())
{
FunctionAlias
.
JavaMethod
[]
methods
=
alias
.
getJavaMethods
();
for
(
int
j
=
0
;
j
<
methods
.
length
;
j
++)
{
FunctionAlias
.
JavaMethod
method
=
methods
[
j
];
...
...
@@ -1092,9 +1076,7 @@ public class MetaTable extends Table {
});
}
}
ObjectArray
<
UserAggregate
>
aggregates
=
database
.
getAllAggregates
();
for
(
int
i
=
0
;
i
<
aggregates
.
size
();
i
++)
{
UserAggregate
agg
=
aggregates
.
get
(
i
);
for
(
UserAggregate
agg
:
database
.
getAllAggregates
())
{
int
returnsResult
=
DatabaseMetaData
.
procedureReturnsResult
;
add
(
rows
,
new
String
[]
{
// ALIAS_CATALOG
...
...
@@ -1122,9 +1104,7 @@ public class MetaTable extends Table {
break
;
}
case
FUNCTION_COLUMNS:
{
ObjectArray
<
FunctionAlias
>
aliases
=
database
.
getAllFunctionAliases
();
for
(
int
i
=
0
;
i
<
aliases
.
size
();
i
++)
{
FunctionAlias
alias
=
aliases
.
get
(
i
);
for
(
FunctionAlias
alias
:
database
.
getAllFunctionAliases
())
{
FunctionAlias
.
JavaMethod
[]
methods
=
alias
.
getJavaMethods
();
for
(
int
j
=
0
;
j
<
methods
.
length
;
j
++)
{
FunctionAlias
.
JavaMethod
method
=
methods
[
j
];
...
...
@@ -1175,10 +1155,8 @@ public class MetaTable extends Table {
break
;
}
case
SCHEMATA:
{
ObjectArray
<
Schema
>
schemas
=
database
.
getAllSchemas
();
String
collation
=
database
.
getCompareMode
().
getName
();
for
(
int
i
=
0
;
i
<
schemas
.
size
();
i
++)
{
Schema
schema
=
schemas
.
get
(
i
);
for
(
Schema
schema
:
database
.
getAllSchemas
())
{
add
(
rows
,
new
String
[]
{
// CATALOG_NAME
catalog
,
...
...
@@ -1201,9 +1179,7 @@ public class MetaTable extends Table {
break
;
}
case
TABLE_PRIVILEGES:
{
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
r
=
rights
.
get
(
i
);
for
(
Right
r
:
database
.
getAllRights
())
{
Table
table
=
r
.
getGrantedTable
();
if
(
table
==
null
)
{
continue
;
...
...
@@ -1217,9 +1193,7 @@ public class MetaTable extends Table {
break
;
}
case
COLUMN_PRIVILEGES:
{
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
r
=
rights
.
get
(
i
);
for
(
Right
r
:
database
.
getAllRights
())
{
Table
table
=
r
.
getGrantedTable
();
if
(
table
==
null
)
{
continue
;
...
...
@@ -1239,9 +1213,7 @@ public class MetaTable extends Table {
break
;
}
case
COLLATIONS:
{
Locale
[]
locales
=
Collator
.
getAvailableLocales
();
for
(
int
i
=
0
;
i
<
locales
.
length
;
i
++)
{
Locale
l
=
locales
[
i
];
for
(
Locale
l
:
Collator
.
getAvailableLocales
())
{
add
(
rows
,
new
String
[]
{
// NAME
CompareMode
.
getName
(
l
),
...
...
@@ -1252,9 +1224,7 @@ public class MetaTable extends Table {
break
;
}
case
VIEWS:
{
ObjectArray
<
Table
>
tables
=
getAllTables
(
session
);
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
getAllTables
(
session
))
{
if
(!
table
.
getTableType
().
equals
(
Table
.
VIEW
))
{
continue
;
}
...
...
@@ -1300,9 +1270,8 @@ public class MetaTable extends Table {
break
;
}
case
CROSS_REFERENCES:
{
ObjectArray
<
SchemaObject
>
constraints
=
database
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
);
for
(
int
i
=
0
;
i
<
constraints
.
size
();
i
++)
{
Constraint
constraint
=
(
Constraint
)
constraints
.
get
(
i
);
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
))
{
Constraint
constraint
=
(
Constraint
)
obj
;
if
(!(
constraint
.
getConstraintType
().
equals
(
Constraint
.
REFERENTIAL
)))
{
continue
;
}
...
...
@@ -1353,9 +1322,8 @@ public class MetaTable extends Table {
break
;
}
case
CONSTRAINTS:
{
ObjectArray
<
SchemaObject
>
constraints
=
database
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
);
for
(
int
i
=
0
;
i
<
constraints
.
size
();
i
++)
{
Constraint
constraint
=
(
Constraint
)
constraints
.
get
(
i
);
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
))
{
Constraint
constraint
=
(
Constraint
)
obj
;
String
type
=
constraint
.
getConstraintType
();
String
checkExpression
=
null
;
IndexColumn
[]
columns
=
null
;
...
...
@@ -1419,9 +1387,8 @@ public class MetaTable extends Table {
break
;
}
case
CONSTANTS:
{
ObjectArray
<
SchemaObject
>
constants
=
database
.
getAllSchemaObjects
(
DbObject
.
CONSTANT
);
for
(
int
i
=
0
;
i
<
constants
.
size
();
i
++)
{
Constant
constant
=
(
Constant
)
constants
.
get
(
i
);
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
DbObject
.
CONSTANT
))
{
Constant
constant
=
(
Constant
)
obj
;
ValueExpression
expr
=
constant
.
getValue
();
add
(
rows
,
new
String
[]
{
// CONSTANT_CATALOG
...
...
@@ -1443,9 +1410,7 @@ public class MetaTable extends Table {
break
;
}
case
DOMAINS:
{
ObjectArray
<
UserDataType
>
userDataTypes
=
database
.
getAllUserDataTypes
();
for
(
int
i
=
0
;
i
<
userDataTypes
.
size
();
i
++)
{
UserDataType
dt
=
userDataTypes
.
get
(
i
);
for
(
UserDataType
dt
:
database
.
getAllUserDataTypes
())
{
Column
col
=
dt
.
getColumn
();
add
(
rows
,
new
String
[]
{
// DOMAIN_CATALOG
...
...
@@ -1481,9 +1446,8 @@ public class MetaTable extends Table {
break
;
}
case
TRIGGERS:
{
ObjectArray
<
SchemaObject
>
triggers
=
database
.
getAllSchemaObjects
(
DbObject
.
TRIGGER
);
for
(
int
i
=
0
;
i
<
triggers
.
size
();
i
++)
{
TriggerObject
trigger
=
(
TriggerObject
)
triggers
.
get
(
i
);
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
DbObject
.
TRIGGER
))
{
TriggerObject
trigger
=
(
TriggerObject
)
obj
;
Table
table
=
trigger
.
getTable
();
add
(
rows
,
new
String
[]
{
// TRIGGER_CATALOG
...
...
@@ -1519,10 +1483,8 @@ public class MetaTable extends Table {
break
;
}
case
SESSIONS:
{
Session
[]
sessions
=
database
.
getSessions
(
false
);
boolean
admin
=
session
.
getUser
().
getAdmin
();
for
(
int
i
=
0
;
i
<
sessions
.
length
;
i
++)
{
Session
s
=
sessions
[
i
];
for
(
Session
s
:
database
.
getSessions
(
false
))
{
if
(
admin
||
s
==
session
)
{
Command
command
=
s
.
getCurrentCommand
();
add
(
rows
,
new
String
[]
{
...
...
@@ -1542,10 +1504,8 @@ public class MetaTable extends Table {
break
;
}
case
LOCKS:
{
Session
[]
sessions
=
database
.
getSessions
(
false
);
boolean
admin
=
session
.
getUser
().
getAdmin
();
for
(
int
i
=
0
;
i
<
sessions
.
length
;
i
++)
{
Session
s
=
sessions
[
i
];
for
(
Session
s
:
database
.
getSessions
(
false
))
{
if
(
admin
||
s
==
session
)
{
Table
[]
locks
=
s
.
getLocks
();
for
(
int
j
=
0
;
j
<
locks
.
length
;
j
++)
{
...
...
@@ -1566,9 +1526,7 @@ public class MetaTable extends Table {
break
;
}
case
SESSION_STATE:
{
String
[]
variableNames
=
session
.
getVariableNames
();
for
(
int
i
=
0
;
i
<
variableNames
.
length
;
i
++)
{
String
name
=
variableNames
[
i
];
for
(
String
name
:
session
.
getVariableNames
())
{
Value
v
=
session
.
getVariable
(
name
);
add
(
rows
,
new
String
[]
{
// KEY
...
...
@@ -1577,9 +1535,7 @@ public class MetaTable extends Table {
"SET @"
+
name
+
" "
+
v
.
getSQL
()
});
}
ObjectArray
<
Table
>
tables
=
session
.
getLocalTempTables
();
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
table
=
tables
.
get
(
i
);
for
(
Table
table
:
session
.
getLocalTempTables
())
{
add
(
rows
,
new
String
[]
{
// KEY
"TABLE "
+
table
.
getName
(),
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Plan.java
浏览文件 @
bfcce888
...
...
@@ -91,8 +91,7 @@ public class Plan {
}
f
.
removeUnusableIndexConditions
();
}
for
(
int
i
=
0
;
i
<
allFilters
.
length
;
i
++)
{
TableFilter
f
=
allFilters
[
i
];
for
(
TableFilter
f
:
allFilters
)
{
setEvaluatable
(
f
,
false
);
}
}
...
...
@@ -106,8 +105,7 @@ public class Plan {
public
double
calculateCost
(
Session
session
)
throws
SQLException
{
double
cost
=
1
;
boolean
invalidPlan
=
false
;
for
(
int
i
=
0
;
i
<
allFilters
.
length
;
i
++)
{
TableFilter
tableFilter
=
allFilters
[
i
];
for
(
TableFilter
tableFilter
:
allFilters
)
{
PlanItem
item
=
tableFilter
.
getBestPlanItem
(
session
);
planItems
.
put
(
tableFilter
,
item
);
cost
+=
cost
*
item
.
cost
;
...
...
@@ -123,8 +121,8 @@ public class Plan {
if
(
invalidPlan
)
{
cost
=
Double
.
POSITIVE_INFINITY
;
}
for
(
int
i
=
0
;
i
<
allFilters
.
length
;
i
++
)
{
setEvaluatable
(
allFilters
[
i
]
,
false
);
for
(
TableFilter
f
:
allFilters
)
{
setEvaluatable
(
f
,
false
);
}
return
cost
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Table.java
浏览文件 @
bfcce888
...
...
@@ -264,14 +264,14 @@ public abstract class Table extends SchemaObjectBase {
*/
public
void
addDependencies
(
HashSet
<
DbObject
>
dependencies
)
{
if
(
sequences
!=
null
)
{
for
(
int
i
=
0
;
i
<
sequences
.
size
();
i
++
)
{
dependencies
.
add
(
s
equences
.
get
(
i
)
);
for
(
Sequence
s
:
sequences
)
{
dependencies
.
add
(
s
);
}
}
ExpressionVisitor
visitor
=
ExpressionVisitor
.
get
(
ExpressionVisitor
.
GET_DEPENDENCIES
);
visitor
.
setDependencies
(
dependencies
);
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++
)
{
col
umns
[
i
]
.
isEverything
(
visitor
);
for
(
Column
col
:
columns
)
{
col
.
isEverything
(
visitor
);
}
}
...
...
@@ -294,8 +294,7 @@ public abstract class Table extends SchemaObjectBase {
children
.
addAll
(
views
);
}
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
rights
.
get
(
i
);
for
(
Right
right
:
rights
)
{
if
(
right
.
getGrantedTable
()
==
this
)
{
children
.
add
(
right
);
}
...
...
@@ -333,8 +332,7 @@ public abstract class Table extends SchemaObjectBase {
* @param newName the new column name
*/
public
void
renameColumn
(
Column
column
,
String
newName
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
c
=
columns
[
i
];
for
(
Column
c
:
columns
)
{
if
(
c
==
column
)
{
continue
;
}
...
...
@@ -401,9 +399,7 @@ public abstract class Table extends SchemaObjectBase {
constraints
.
remove
(
0
);
database
.
removeSchemaObject
(
session
,
constraint
);
}
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
for
(
int
i
=
0
;
i
<
rights
.
size
();
i
++)
{
Right
right
=
rights
.
get
(
i
);
for
(
Right
right
:
database
.
getAllRights
())
{
if
(
right
.
getGrantedTable
()
==
this
)
{
database
.
removeDatabaseObject
(
session
,
right
);
}
...
...
@@ -606,9 +602,8 @@ public abstract class Table extends SchemaObjectBase {
if
(
indexes
!=
null
)
{
remove
(
indexes
,
index
);
if
(
index
.
getIndexType
().
getPrimaryKey
())
{
Column
[]
cols
=
index
.
getColumns
();
for
(
int
i
=
0
;
i
<
cols
.
length
;
i
++)
{
cols
[
i
].
setPrimaryKey
(
false
);
for
(
Column
col
:
index
.
getColumns
())
{
col
.
setPrimaryKey
(
false
);
}
}
}
...
...
@@ -724,8 +719,7 @@ public abstract class Table extends SchemaObjectBase {
private
void
fire
(
Session
session
,
boolean
beforeAction
)
throws
SQLException
{
if
(
triggers
!=
null
)
{
for
(
int
i
=
0
;
i
<
triggers
.
size
();
i
++)
{
TriggerObject
trigger
=
triggers
.
get
(
i
);
for
(
TriggerObject
trigger
:
triggers
)
{
trigger
.
fire
(
session
,
beforeAction
);
}
}
...
...
@@ -755,8 +749,7 @@ public abstract class Table extends SchemaObjectBase {
private
void
fireConstraints
(
Session
session
,
Row
oldRow
,
Row
newRow
,
boolean
before
)
throws
SQLException
{
if
(
constraints
!=
null
)
{
for
(
int
i
=
0
;
i
<
constraints
.
size
();
i
++)
{
Constraint
constraint
=
constraints
.
get
(
i
);
for
(
Constraint
constraint
:
constraints
)
{
if
(
constraint
.
isBefore
()
==
before
)
{
constraint
.
checkRow
(
session
,
this
,
oldRow
,
newRow
);
}
...
...
@@ -778,8 +771,7 @@ public abstract class Table extends SchemaObjectBase {
private
void
fireRow
(
Session
session
,
Row
oldRow
,
Row
newRow
,
boolean
beforeAction
)
throws
SQLException
{
if
(
triggers
!=
null
)
{
for
(
int
i
=
0
;
i
<
triggers
.
size
();
i
++)
{
TriggerObject
trigger
=
triggers
.
get
(
i
);
for
(
TriggerObject
trigger
:
triggers
)
{
trigger
.
fireRow
(
session
,
oldRow
,
newRow
,
beforeAction
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableData.java
浏览文件 @
bfcce888
...
...
@@ -77,8 +77,8 @@ public class TableData extends Table implements RecordReader {
}
indexes
.
add
(
scanIndex
);
}
for
(
int
i
=
0
;
i
<
cols
.
length
;
i
++
)
{
if
(
DataType
.
isLargeObject
(
col
s
[
i
]
.
getType
()))
{
for
(
Column
col
:
cols
)
{
if
(
DataType
.
isLargeObject
(
col
.
getType
()))
{
containsLargeObject
=
true
;
memoryPerRow
=
Row
.
MEMORY_CALCULATE
;
}
...
...
@@ -91,8 +91,7 @@ public class TableData extends Table implements RecordReader {
}
public
void
close
(
Session
session
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
for
(
Index
index
:
indexes
)
{
index
.
close
(
session
);
}
}
...
...
@@ -153,8 +152,7 @@ public class TableData extends Table implements RecordReader {
}
public
Index
getUniqueIndex
()
{
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
idx
=
indexes
.
get
(
i
);
for
(
Index
idx
:
indexes
)
{
if
(
idx
.
getIndexType
().
getUnique
())
{
return
idx
;
}
...
...
@@ -460,9 +458,8 @@ public class TableData extends Table implements RecordReader {
private
String
getDeadlockDetails
(
ObjectArray
<
Session
>
sessions
)
{
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
sessions
.
size
();
i
++
)
{
for
(
Session
s
:
sessions
)
{
buff
.
append
(
'\n'
);
Session
s
=
sessions
.
get
(
i
);
Table
lock
=
s
.
getWaitForLock
();
buff
.
append
(
"Session "
).
append
(
s
).
append
(
" is waiting to lock "
).
append
(
lock
);
buff
.
append
(
" while locking "
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
bfcce888
...
...
@@ -127,8 +127,7 @@ public class TableFilter implements ColumnResolver {
}
else
{
int
len
=
table
.
getColumns
().
length
;
int
[]
masks
=
new
int
[
len
];
for
(
int
i
=
0
;
i
<
indexConditions
.
size
();
i
++)
{
IndexCondition
condition
=
indexConditions
.
get
(
i
);
for
(
IndexCondition
condition
:
indexConditions
)
{
if
(
condition
.
isEvaluatable
())
{
if
(
condition
.
isAlwaysFalse
())
{
masks
=
null
;
...
...
@@ -253,8 +252,7 @@ public class TableFilter implements ColumnResolver {
return
false
;
}
else
if
(
state
==
BEFORE_FIRST
)
{
SearchRow
start
=
null
,
end
=
null
;
for
(
int
i
=
0
;
i
<
indexConditions
.
size
();
i
++)
{
IndexCondition
condition
=
indexConditions
.
get
(
i
);
for
(
IndexCondition
condition
:
indexConditions
)
{
if
(
condition
.
isAlwaysFalse
())
{
alwaysFalse
=
true
;
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
bfcce888
...
...
@@ -482,8 +482,7 @@ public class TableLink extends Table {
}
public
Index
getUniqueIndex
()
{
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
idx
=
indexes
.
get
(
i
);
for
(
Index
idx
:
indexes
)
{
if
(
idx
.
getIndexType
().
getUnique
())
{
return
idx
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableView.java
浏览文件 @
bfcce888
...
...
@@ -281,8 +281,7 @@ public class TableView extends Table {
* @param session the session
*/
public
void
recompile
(
Session
session
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
tables
.
get
(
i
);
for
(
Table
t
:
tables
)
{
t
.
removeView
(
this
);
}
tables
.
clear
();
...
...
@@ -313,8 +312,7 @@ public class TableView extends Table {
private
void
removeViewFromTables
()
{
if
(
tables
!=
null
)
{
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
tables
.
get
(
i
);
for
(
Table
t
:
tables
)
{
t
.
removeView
(
this
);
}
tables
.
clear
();
...
...
@@ -322,8 +320,7 @@ public class TableView extends Table {
}
private
void
addViewToTables
()
{
for
(
int
i
=
0
;
i
<
tables
.
size
();
i
++)
{
Table
t
=
tables
.
get
(
i
);
for
(
Table
t
:
tables
)
{
t
.
addView
(
this
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/ChangeFileEncryption.java
浏览文件 @
bfcce888
...
...
@@ -142,8 +142,7 @@ public class ChangeFileEncryption extends Tool {
if
(
files
.
size
()
==
0
&&
!
quiet
)
{
printNoDatabaseFilesFound
(
dir
,
db
);
}
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
String
fileName
=
files
.
get
(
i
);
for
(
String
fileName
:
files
)
{
String
temp
=
dir
+
"/temp.db"
;
FileUtils
.
delete
(
temp
);
FileUtils
.
rename
(
fileName
,
temp
);
...
...
@@ -152,8 +151,7 @@ public class ChangeFileEncryption extends Tool {
// if this worked, the operation will (hopefully) be successful
// TODO changeFileEncryption: this is a workaround!
// make the operation atomic (all files or none)
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
String
fileName
=
files
.
get
(
i
);
for
(
String
fileName
:
files
)
{
change
.
process
(
fileName
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Csv.java
浏览文件 @
bfcce888
...
...
@@ -187,8 +187,8 @@ public class Csv implements SimpleRowSource {
initRead
();
SimpleResultSet
result
=
new
SimpleResultSet
(
this
);
makeColumnNamesUnique
();
for
(
int
i
=
0
;
i
<
columnNames
.
length
;
i
++
)
{
result
.
addColumn
(
columnName
s
[
i
]
,
Types
.
VARCHAR
,
Integer
.
MAX_VALUE
,
0
);
for
(
String
columnName
:
columnNames
)
{
result
.
addColumn
(
columnName
,
Types
.
VARCHAR
,
Integer
.
MAX_VALUE
,
0
);
}
return
result
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/DeleteDbFiles.java
浏览文件 @
bfcce888
...
...
@@ -91,8 +91,7 @@ public class DeleteDbFiles extends Tool {
if
(
files
.
size
()
==
0
&&
!
quiet
)
{
printNoDatabaseFilesFound
(
dir
,
db
);
}
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
String
fileName
=
files
.
get
(
i
);
for
(
String
fileName
:
files
)
{
delete
.
process
(
fileName
,
quiet
);
if
(!
quiet
)
{
out
.
println
(
"Processed: "
+
fileName
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/MultiDimension.java
浏览文件 @
bfcce888
...
...
@@ -114,9 +114,9 @@ public class MultiDimension {
buff
.
append
(
" D, TABLE(_FROM_ BIGINT=?, _TO_ BIGINT=?) WHERE "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
scalarColumn
));
buff
.
append
(
" BETWEEN _FROM_ AND _TO_"
);
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++
)
{
for
(
String
col
:
columns
)
{
buff
.
append
(
" AND "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
col
umns
[
i
]
));
buff
.
append
(
StringUtils
.
quoteIdentifier
(
col
));
buff
.
append
(
"+1 BETWEEN ?+1 AND ?+1"
);
}
return
buff
.
toString
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
bfcce888
...
...
@@ -1205,8 +1205,7 @@ public class Recover extends Tool implements DataHandler {
private
void
writeSchema
(
PrintWriter
writer
)
{
MetaRecord
.
sort
(
schema
);
for
(
int
i
=
0
;
i
<
schema
.
size
();
i
++)
{
MetaRecord
m
=
schema
.
get
(
i
);
for
(
MetaRecord
m
:
schema
)
{
writer
.
println
(
m
.
getSQL
()
+
";"
);
}
for
(
Map
.
Entry
<
Integer
,
String
>
entry
:
tableMap
.
entrySet
())
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Shell.java
浏览文件 @
bfcce888
...
...
@@ -512,8 +512,7 @@ public class Shell extends Tool {
println
(
buff
.
toString
());
}
if
(
rowCount
==
0
&&
listMode
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
String
label
=
columns
[
i
];
for
(
String
label
:
columns
)
{
buff
.
append
(
label
);
buff
.
append
(
'\n'
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/ClassUtils.java
浏览文件 @
bfcce888
...
...
@@ -68,8 +68,7 @@ public class ClassUtils {
public
static
Class
<
?
>
loadUserClass
(
String
className
)
throws
SQLException
{
if
(!
ALLOW_ALL
&&
!
ALLOWED_CLASS_NAMES
.
contains
(
className
))
{
boolean
allowed
=
false
;
for
(
int
i
=
0
;
i
<
ALLOWED_CLASS_NAME_PREFIXES
.
length
;
i
++)
{
String
s
=
ALLOWED_CLASS_NAME_PREFIXES
[
i
];
for
(
String
s
:
ALLOWED_CLASS_NAME_PREFIXES
)
{
if
(
className
.
startsWith
(
s
))
{
allowed
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/NetUtils.java
浏览文件 @
bfcce888
...
...
@@ -163,9 +163,7 @@ public class NetUtils {
InetAddress
localhost
=
InetAddress
.
getLocalHost
();
// localhost.getCanonicalHostName() is very very slow
String
host
=
localhost
.
getHostAddress
();
InetAddress
[]
list
=
InetAddress
.
getAllByName
(
host
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
InetAddress
addr
=
list
[
i
];
for
(
InetAddress
addr
:
InetAddress
.
getAllByName
(
host
))
{
if
(
test
.
equals
(
addr
))
{
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/RandomUtils.java
浏览文件 @
bfcce888
...
...
@@ -142,8 +142,8 @@ public class RandomUtils {
"getAllByName"
,
new
Class
[]
{
String
.
class
})
.
invoke
(
null
,
new
Object
[]
{
hostName
});
Method
getAddress
=
inetAddressClass
.
getMethod
(
"getAddress"
,
new
Class
[
0
]);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++
)
{
out
.
write
((
byte
[])
getAddress
.
invoke
(
list
[
i
]
,
new
Object
[
0
]));
for
(
Object
o
:
list
)
{
out
.
write
((
byte
[])
getAddress
.
invoke
(
o
,
new
Object
[
0
]));
}
}
catch
(
Throwable
e
)
{
// on some system, InetAddress is not supported
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/StartBrowser.java
浏览文件 @
bfcce888
...
...
@@ -73,9 +73,9 @@ public class StartBrowser {
}
else
{
String
[]
browsers
=
{
"firefox"
,
"mozilla-firefox"
,
"mozilla"
,
"konqueror"
,
"netscape"
,
"opera"
};
boolean
ok
=
false
;
for
(
int
i
=
0
;
i
<
browsers
.
length
;
i
++
)
{
for
(
String
b
:
browsers
)
{
try
{
rt
.
exec
(
new
String
[]
{
b
rowsers
[
i
]
,
url
});
rt
.
exec
(
new
String
[]
{
b
,
url
});
ok
=
true
;
break
;
}
catch
(
Exception
e
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/ValueHashMap.java
浏览文件 @
bfcce888
...
...
@@ -169,8 +169,7 @@ public class ValueHashMap<V> extends HashBase {
*/
public
ObjectArray
<
Value
>
keys
()
{
ObjectArray
<
Value
>
list
=
ObjectArray
.
newInstance
(
size
);
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
Value
k
=
keys
[
i
];
for
(
Value
k
:
keys
)
{
if
(
k
!=
null
&&
k
!=
ValueNull
.
DELETED
)
{
list
.
add
(
k
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/CompareMode.java
浏览文件 @
bfcce888
...
...
@@ -167,9 +167,7 @@ public class CompareMode {
}
}
if
(
result
==
null
)
{
Locale
[]
locales
=
Collator
.
getAvailableLocales
();
for
(
int
i
=
0
;
i
<
locales
.
length
;
i
++)
{
Locale
locale
=
locales
[
i
];
for
(
Locale
locale
:
Collator
.
getAvailableLocales
())
{
if
(
compareLocaleNames
(
locale
,
name
))
{
result
=
Collator
.
getInstance
(
locale
);
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/Transfer.java
浏览文件 @
bfcce888
...
...
@@ -400,8 +400,8 @@ public class Transfer {
case
Value
.
ARRAY
:
{
Value
[]
list
=
((
ValueArray
)
v
).
getList
();
writeInt
(
list
.
length
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++
)
{
writeValue
(
list
[
i
]
);
for
(
Value
value
:
list
)
{
writeValue
(
value
);
}
break
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
bfcce888
...
...
@@ -37,8 +37,8 @@ public class ValueArray extends Value {
return
hash
;
}
int
h
=
1
;
for
(
int
i
=
0
;
i
<
values
.
length
;
)
{
h
=
h
*
31
+
v
alues
[
i
++]
.
hashCode
();
for
(
Value
v
:
values
)
{
h
=
h
*
31
+
v
.
hashCode
();
}
hash
=
h
;
return
h
;
...
...
@@ -127,8 +127,8 @@ public class ValueArray extends Value {
}
public
int
getDisplaySize
()
{
long
size
=
0
;
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++
)
{
size
+=
v
alues
[
i
]
.
getDisplaySize
();
for
(
Value
v
:
values
)
{
size
+=
v
.
getDisplaySize
();
}
return
MathUtils
.
convertLongToInt
(
size
);
}
...
...
@@ -154,8 +154,8 @@ public class ValueArray extends Value {
public
int
getMemory
()
{
int
memory
=
0
;
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++
)
{
memory
+=
v
alues
[
i
]
.
getMemory
();
for
(
Value
v
:
values
)
{
memory
+=
v
.
getMemory
();
}
return
memory
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
bfcce888
...
...
@@ -256,8 +256,7 @@ public class ValueLob extends Value {
String
[]
list
=
getFileList
(
handler
,
dir
);
int
fileCount
=
0
;
boolean
[]
used
=
new
boolean
[
SysProperties
.
LOB_FILES_PER_DIRECTORY
];
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
String
name
=
list
[
i
];
for
(
String
name
:
list
)
{
if
(
name
.
endsWith
(
Constants
.
SUFFIX_DB_FILE
))
{
name
=
name
.
substring
(
name
.
lastIndexOf
(
File
.
separatorChar
)
+
1
);
String
n
=
name
.
substring
(
0
,
name
.
indexOf
(
'.'
));
...
...
@@ -754,8 +753,7 @@ public class ValueLob extends Value {
String
prefix
=
handler
.
getDatabasePath
();
String
dir
=
FileUtils
.
getParent
(
prefix
);
String
[]
list
=
FileUtils
.
listFiles
(
dir
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
String
name
=
list
[
i
];
for
(
String
name
:
list
)
{
if
(
name
.
startsWith
(
prefix
+
"."
+
tableId
+
"."
)
&&
name
.
endsWith
(
Constants
.
SUFFIX_LOB_FILE
))
{
deleteFile
(
handler
,
name
);
}
...
...
@@ -772,8 +770,7 @@ public class ValueLob extends Value {
public
static
boolean
existsLobFile
(
String
prefix
)
throws
SQLException
{
String
dir
=
FileUtils
.
getParent
(
prefix
);
String
[]
list
=
FileUtils
.
listFiles
(
dir
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
String
name
=
list
[
i
];
for
(
String
name:
list
)
{
if
(
name
.
startsWith
(
prefix
+
"."
)
&&
name
.
endsWith
(
Constants
.
SUFFIX_LOB_FILE
))
{
return
true
;
}
...
...
@@ -782,12 +779,10 @@ public class ValueLob extends Value {
}
private
static
void
removeAllForTable
(
DataHandler
handler
,
String
dir
,
int
tableId
)
throws
SQLException
{
String
[]
list
=
FileUtils
.
listFiles
(
dir
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
if
(
FileUtils
.
isDirectory
(
list
[
i
]))
{
removeAllForTable
(
handler
,
list
[
i
],
tableId
);
for
(
String
name
:
FileUtils
.
listFiles
(
dir
))
{
if
(
FileUtils
.
isDirectory
(
name
))
{
removeAllForTable
(
handler
,
name
,
tableId
);
}
else
{
String
name
=
list
[
i
];
if
(
name
.
endsWith
(
".t"
+
tableId
+
Constants
.
SUFFIX_LOB_FILE
))
{
deleteFile
(
handler
,
name
);
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论