Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
8970b560
提交
8970b560
authored
14 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make methods static if possible.
上级
d33e4c69
隐藏空白字符变更
内嵌
并排
正在显示
87 个修改的文件
包含
292 行增加
和
392 行删除
+292
-392
Bnf.java
h2/src/main/org/h2/bnf/Bnf.java
+2
-2
Parser.java
h2/src/main/org/h2/command/Parser.java
+2
-2
Prepared.java
h2/src/main/org/h2/command/Prepared.java
+2
-2
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+4
-4
AlterUser.java
h2/src/main/org/h2/command/ddl/AlterUser.java
+1
-2
CreateUser.java
h2/src/main/org/h2/command/ddl/CreateUser.java
+1
-2
BackupCommand.java
h2/src/main/org/h2/command/dml/BackupCommand.java
+1
-1
Query.java
h2/src/main/org/h2/command/dml/Query.java
+1
-1
ScriptBase.java
h2/src/main/org/h2/command/dml/ScriptBase.java
+1
-2
LZFInputStream.java
h2/src/main/org/h2/compress/LZFInputStream.java
+1
-1
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+1
-1
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+2
-3
Engine.java
h2/src/main/org/h2/engine/Engine.java
+1
-1
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+1
-1
Right.java
h2/src/main/org/h2/engine/Right.java
+1
-1
SessionRemote.java
h2/src/main/org/h2/engine/SessionRemote.java
+2
-6
User.java
h2/src/main/org/h2/engine/User.java
+3
-5
AggregateData.java
h2/src/main/org/h2/expression/AggregateData.java
+1
-1
Function.java
h2/src/main/org/h2/expression/Function.java
+14
-12
TableFunction.java
h2/src/main/org/h2/expression/TableFunction.java
+1
-1
LinkedIndex.java
h2/src/main/org/h2/index/LinkedIndex.java
+5
-5
PageBtreeIndex.java
h2/src/main/org/h2/index/PageBtreeIndex.java
+1
-1
PageBtreeLeaf.java
h2/src/main/org/h2/index/PageBtreeLeaf.java
+1
-1
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+0
-20
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+23
-2
TreeCursor.java
h2/src/main/org/h2/index/TreeCursor.java
+62
-3
TreeIndex.java
h2/src/main/org/h2/index/TreeIndex.java
+2
-60
ViewIndex.java
h2/src/main/org/h2/index/ViewIndex.java
+1
-1
JdbcArray.java
h2/src/main/org/h2/jdbc/JdbcArray.java
+2
-2
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+12
-12
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+3
-3
JdbcStatement.java
h2/src/main/org/h2/jdbc/JdbcStatement.java
+4
-4
JdbcDataSource.java
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
+2
-2
JdbcXAConnection.java
h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
+2
-2
TraceObject.java
h2/src/main/org/h2/message/TraceObject.java
+10
-10
ResultTempTable.java
h2/src/main/org/h2/result/ResultTempTable.java
+1
-1
RowList.java
h2/src/main/org/h2/result/RowList.java
+2
-2
TriggerObject.java
h2/src/main/org/h2/schema/TriggerObject.java
+1
-1
AES.java
h2/src/main/org/h2/security/AES.java
+1
-1
CipherFactory.java
h2/src/main/org/h2/security/CipherFactory.java
+1
-13
SHA256.java
h2/src/main/org/h2/security/SHA256.java
+6
-6
SecureFileStore.java
h2/src/main/org/h2/security/SecureFileStore.java
+3
-4
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+2
-2
ConnectionInfo.java
h2/src/main/org/h2/server/web/ConnectionInfo.java
+1
-1
DbContextRule.java
h2/src/main/org/h2/server/web/DbContextRule.java
+1
-1
DbStarter.java
h2/src/main/org/h2/server/web/DbStarter.java
+1
-1
WebApp.java
h2/src/main/org/h2/server/web/WebApp.java
+14
-34
WebServer.java
h2/src/main/org/h2/server/web/WebServer.java
+5
-9
WebThread.java
h2/src/main/org/h2/server/web/WebThread.java
+2
-2
FileLock.java
h2/src/main/org/h2/store/FileLock.java
+2
-2
PageInputStream.java
h2/src/main/org/h2/store/PageInputStream.java
+1
-1
PageOutputStream.java
h2/src/main/org/h2/store/PageOutputStream.java
+0
-2
PageStreamData.java
h2/src/main/org/h2/store/PageStreamData.java
+1
-1
FileObjectDiskMapped.java
h2/src/main/org/h2/store/fs/FileObjectDiskMapped.java
+1
-1
FileSystem.java
h2/src/main/org/h2/store/fs/FileSystem.java
+5
-1
FileSystemDisk.java
h2/src/main/org/h2/store/fs/FileSystemDisk.java
+2
-2
FileSystemSplit.java
h2/src/main/org/h2/store/fs/FileSystemSplit.java
+1
-5
FileSystemWrapper.java
h2/src/main/org/h2/store/fs/FileSystemWrapper.java
+0
-10
FileSystemZip.java
h2/src/main/org/h2/store/fs/FileSystemZip.java
+3
-3
Column.java
h2/src/main/org/h2/table/Column.java
+1
-1
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+2
-2
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+3
-3
Table.java
h2/src/main/org/h2/table/Table.java
+2
-2
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+3
-3
ChangeFileEncryption.java
h2/src/main/org/h2/tools/ChangeFileEncryption.java
+1
-2
CompressTool.java
h2/src/main/org/h2/tools/CompressTool.java
+1
-1
Console.java
h2/src/main/org/h2/tools/Console.java
+1
-1
ConvertTraceFile.java
h2/src/main/org/h2/tools/ConvertTraceFile.java
+2
-2
CreateCluster.java
h2/src/main/org/h2/tools/CreateCluster.java
+2
-2
Csv.java
h2/src/main/org/h2/tools/Csv.java
+3
-3
DeleteDbFiles.java
h2/src/main/org/h2/tools/DeleteDbFiles.java
+2
-3
MultiDimension.java
h2/src/main/org/h2/tools/MultiDimension.java
+4
-4
Recover.java
h2/src/main/org/h2/tools/Recover.java
+5
-6
Restore.java
h2/src/main/org/h2/tools/Restore.java
+1
-14
RunScript.java
h2/src/main/org/h2/tools/RunScript.java
+0
-4
Script.java
h2/src/main/org/h2/tools/Script.java
+11
-33
Shell.java
h2/src/main/org/h2/tools/Shell.java
+0
-2
TriggerAdapter.java
h2/src/main/org/h2/tools/TriggerAdapter.java
+1
-1
SourceCompiler.java
h2/src/main/org/h2/util/SourceCompiler.java
+1
-1
Value.java
h2/src/main/org/h2/value/Value.java
+5
-5
ValueByte.java
h2/src/main/org/h2/value/ValueByte.java
+1
-1
ValueInt.java
h2/src/main/org/h2/value/ValueInt.java
+1
-1
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+4
-4
ValueLong.java
h2/src/main/org/h2/value/ValueLong.java
+2
-2
ValueShort.java
h2/src/main/org/h2/value/ValueShort.java
+1
-1
ValueUuid.java
h2/src/main/org/h2/value/ValueUuid.java
+1
-1
TestWeb.java
h2/src/test/org/h2/test/server/TestWeb.java
+1
-2
没有找到文件。
h2/src/main/org/h2/bnf/Bnf.java
浏览文件 @
8970b560
...
...
@@ -78,7 +78,7 @@ public class Bnf {
Csv
csv
=
Csv
.
getInstance
();
csv
.
setLineCommentCharacter
(
'#'
);
ResultSet
rs
=
csv
.
read
(
reader
,
null
);
for
(
int
id
=
0
;
rs
.
next
();
id
++
)
{
while
(
rs
.
next
()
)
{
String
section
=
rs
.
getString
(
"SECTION"
).
trim
();
if
(
section
.
startsWith
(
"System"
))
{
continue
;
...
...
@@ -336,7 +336,7 @@ public class Bnf {
* @param s the syntax
* @return the tokenizer
*/
public
StringTokenizer
getTokenizer
(
String
s
)
{
public
static
StringTokenizer
getTokenizer
(
String
s
)
{
return
new
StringTokenizer
(
s
,
" [](){}|.,\r\n<>:-+*/=<\">!'$"
,
true
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/Parser.java
浏览文件 @
8970b560
...
...
@@ -850,7 +850,7 @@ public class Parser {
return
prepare
(
session
,
buff
.
toString
(),
paramValues
);
}
private
Prepared
prepare
(
Session
s
,
String
sql
,
ArrayList
<
Value
>
paramValues
)
{
private
static
Prepared
prepare
(
Session
s
,
String
sql
,
ArrayList
<
Value
>
paramValues
)
{
Prepared
prep
=
s
.
prepare
(
sql
);
ArrayList
<
Parameter
>
params
=
prep
.
getParameters
();
if
(
params
!=
null
)
{
...
...
@@ -5076,7 +5076,7 @@ public class Parser {
return
command
;
}
private
int
getCompareType
(
int
tokenType
)
{
private
static
int
getCompareType
(
int
tokenType
)
{
switch
(
tokenType
)
{
case
EQUAL:
return
Comparison
.
EQUAL
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/Prepared.java
浏览文件 @
8970b560
...
...
@@ -359,7 +359,7 @@ public abstract class Prepared {
* @param values the value list
* @return the SQL snippet
*/
protected
String
getSQL
(
Value
[]
values
)
{
protected
static
String
getSQL
(
Value
[]
values
)
{
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
Value
v
:
values
)
{
buff
.
appendExceptFirst
(
", "
);
...
...
@@ -376,7 +376,7 @@ public abstract class Prepared {
* @param list the expression list
* @return the SQL snippet
*/
protected
String
getSQL
(
Expression
[]
list
)
{
protected
static
String
getSQL
(
Expression
[]
list
)
{
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
Expression
e
:
list
)
{
buff
.
appendExceptFirst
(
", "
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
8970b560
...
...
@@ -270,7 +270,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
this
.
updateAction
=
action
;
}
private
Index
getUniqueIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
private
static
Index
getUniqueIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
for
(
Index
idx
:
t
.
getIndexes
())
{
if
(
canUseUniqueIndex
(
idx
,
t
,
cols
))
{
return
idx
;
...
...
@@ -279,7 +279,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
return
null
;
}
private
Index
getIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
private
static
Index
getIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
for
(
Index
idx
:
t
.
getIndexes
())
{
if
(
canUseIndex
(
idx
,
t
,
cols
))
{
return
idx
;
...
...
@@ -288,7 +288,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
return
null
;
}
private
boolean
canUseUniqueIndex
(
Index
idx
,
Table
table
,
IndexColumn
[]
cols
)
{
private
static
boolean
canUseUniqueIndex
(
Index
idx
,
Table
table
,
IndexColumn
[]
cols
)
{
if
(
idx
.
getTable
()
!=
table
||
!
idx
.
getIndexType
().
isUnique
())
{
return
false
;
}
...
...
@@ -310,7 +310,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
return
true
;
}
private
boolean
canUseIndex
(
Index
existingIndex
,
Table
table
,
IndexColumn
[]
cols
)
{
private
static
boolean
canUseIndex
(
Index
existingIndex
,
Table
table
,
IndexColumn
[]
cols
)
{
if
(
existingIndex
.
getTable
()
!=
table
||
existingIndex
.
getCreateSQL
()
==
null
)
{
// can't use the scan index or index of another table
return
false
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterUser.java
浏览文件 @
8970b560
...
...
@@ -84,9 +84,8 @@ public class AlterUser extends DefineCommand {
user
.
setSaltAndHash
(
getByteArray
(
salt
),
getByteArray
(
hash
));
}
else
{
String
name
=
newName
==
null
?
user
.
getName
()
:
newName
;
SHA256
sha
=
new
SHA256
();
char
[]
passwordChars
=
getCharArray
(
password
);
byte
[]
userPasswordHash
=
sha
.
getKeyPasswordHash
(
name
,
passwordChars
);
byte
[]
userPasswordHash
=
SHA256
.
getKeyPasswordHash
(
name
,
passwordChars
);
user
.
setUserPasswordHash
(
userPasswordHash
);
}
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/CreateUser.java
浏览文件 @
8970b560
...
...
@@ -80,8 +80,7 @@ public class CreateUser extends DefineCommand {
if
(
userName
.
length
()
==
0
&&
passwordChars
.
length
==
0
&&
SysProperties
.
EMPTY_PASSWORD
)
{
userPasswordHash
=
new
byte
[
0
];
}
else
{
SHA256
sha
=
new
SHA256
();
userPasswordHash
=
sha
.
getKeyPasswordHash
(
userName
,
passwordChars
);
userPasswordHash
=
SHA256
.
getKeyPasswordHash
(
userName
,
passwordChars
);
}
user
.
setUserPasswordHash
(
userPasswordHash
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/BackupCommand.java
浏览文件 @
8970b560
...
...
@@ -99,7 +99,7 @@ public class BackupCommand extends Prepared {
out
.
closeEntry
();
}
private
void
backupFile
(
ZipOutputStream
out
,
String
base
,
String
fn
)
throws
IOException
{
private
static
void
backupFile
(
ZipOutputStream
out
,
String
base
,
String
fn
)
throws
IOException
{
String
f
=
IOUtils
.
getAbsolutePath
(
fn
);
base
=
IOUtils
.
getAbsolutePath
(
base
);
if
(!
f
.
startsWith
(
base
))
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
8970b560
...
...
@@ -275,7 +275,7 @@ public abstract class Query extends Prepared {
* @param mustBeInResult all order by expressions must be in the select list
* @return the new list (expressions may be added)
*/
void
initOrder
(
ArrayList
<
Expression
>
expressions
,
ArrayList
<
String
>
expressionSQL
,
ArrayList
<
SelectOrderBy
>
orderList
,
int
visible
,
static
void
initOrder
(
ArrayList
<
Expression
>
expressions
,
ArrayList
<
String
>
expressionSQL
,
ArrayList
<
SelectOrderBy
>
orderList
,
int
visible
,
boolean
mustBeInResult
)
{
for
(
SelectOrderBy
o
:
orderList
)
{
Expression
e
=
o
.
expression
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/ScriptBase.java
浏览文件 @
8970b560
...
...
@@ -75,8 +75,7 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
}
public
void
setPassword
(
char
[]
password
)
{
SHA256
sha
=
new
SHA256
();
key
=
sha
.
getKeyPasswordHash
(
"script"
,
password
);
key
=
SHA256
.
getKeyPasswordHash
(
"script"
,
password
);
}
public
void
setFileNameExpr
(
Expression
file
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/compress/LZFInputStream.java
浏览文件 @
8970b560
...
...
@@ -31,7 +31,7 @@ public class LZFInputStream extends InputStream {
}
}
private
byte
[]
ensureSize
(
byte
[]
buff
,
int
len
)
{
private
static
byte
[]
ensureSize
(
byte
[]
buff
,
int
len
)
{
return
buff
==
null
||
buff
.
length
<
len
?
Utils
.
newBytes
(
len
)
:
buff
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
8970b560
...
...
@@ -75,7 +75,7 @@ public class ConstraintReferential extends Constraint {
return
Constraint
.
REFERENTIAL
;
}
private
void
appendAction
(
StatementBuilder
buff
,
int
action
)
{
private
static
void
appendAction
(
StatementBuilder
buff
,
int
action
)
{
switch
(
action
)
{
case
CASCADE:
buff
.
append
(
"CASCADE"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
8970b560
...
...
@@ -267,15 +267,14 @@ public class ConnectionInfo implements Cloneable {
userPasswordHash
=
hashPassword
(
passwordHash
,
user
,
password
);
}
private
byte
[]
hashPassword
(
boolean
passwordHash
,
String
userName
,
char
[]
password
)
{
private
static
byte
[]
hashPassword
(
boolean
passwordHash
,
String
userName
,
char
[]
password
)
{
if
(
passwordHash
)
{
return
StringUtils
.
convertStringToBytes
(
new
String
(
password
));
}
if
(
userName
.
length
()
==
0
&&
password
.
length
==
0
&&
SysProperties
.
EMPTY_PASSWORD
)
{
return
new
byte
[
0
];
}
SHA256
sha
=
new
SHA256
();
return
sha
.
getKeyPasswordHash
(
userName
,
password
);
return
SHA256
.
getKeyPasswordHash
(
userName
,
password
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Engine.java
浏览文件 @
8970b560
...
...
@@ -203,7 +203,7 @@ public class Engine implements SessionFactory {
return
session
;
}
private
void
checkClustering
(
ConnectionInfo
ci
,
Database
database
)
{
private
static
void
checkClustering
(
ConnectionInfo
ci
,
Database
database
)
{
String
clusterSession
=
ci
.
getProperty
(
SetTypes
.
CLUSTER
,
null
);
if
(
Constants
.
CLUSTERING_DISABLED
.
equals
(
clusterSession
))
{
// in this case, no checking is made
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
8970b560
...
...
@@ -165,7 +165,7 @@ public class FunctionAlias extends SchemaObjectBase {
Arrays
.
sort
(
javaMethods
);
}
private
String
getMethodSignature
(
Method
m
)
{
private
static
String
getMethodSignature
(
Method
m
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
m
.
getName
());
buff
.
append
(
'('
);
for
(
Class
<?>
p
:
m
.
getParameterTypes
())
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Right.java
浏览文件 @
8970b560
...
...
@@ -60,7 +60,7 @@ public class Right extends DbObjectBase {
this
.
grantedTable
=
grantedRightOnTable
;
}
private
boolean
appendRight
(
StringBuilder
buff
,
int
right
,
int
mask
,
String
name
,
boolean
comma
)
{
private
static
boolean
appendRight
(
StringBuilder
buff
,
int
right
,
int
mask
,
String
name
,
boolean
comma
)
{
if
((
right
&
mask
)
!=
0
)
{
if
(
comma
)
{
buff
.
append
(
", "
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
8970b560
...
...
@@ -258,14 +258,10 @@ public class SessionRemote extends SessionWithState implements DataHandler {
/**
* Open a new (remote or embedded) session.
*
* @param
ci the connection info
* @param
openNew whether to open a new session in any case
* @return the session
*/
public
SessionInterface
createSession
(
ConnectionInfo
ci
)
{
return
new
SessionRemote
(
ci
).
connectEmbeddedOrServer
(
false
);
}
private
SessionInterface
connectEmbeddedOrServer
(
boolean
openNew
)
{
public
SessionInterface
connectEmbeddedOrServer
(
boolean
openNew
)
{
ConnectionInfo
ci
=
connectionInfo
;
if
(
ci
.
isRemote
())
{
connectServer
(
ci
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/User.java
浏览文件 @
8970b560
...
...
@@ -69,8 +69,7 @@ public class User extends RightOwner {
}
else
{
salt
=
new
byte
[
Constants
.
SALT_LEN
];
MathUtils
.
randomBytes
(
salt
);
SHA256
sha
=
new
SHA256
();
passwordHash
=
sha
.
getHashWithSalt
(
userPasswordHash
,
salt
);
passwordHash
=
SHA256
.
getHashWithSalt
(
userPasswordHash
,
salt
);
}
}
}
...
...
@@ -182,11 +181,10 @@ public class User extends RightOwner {
if
(
userPasswordHash
.
length
==
0
&&
passwordHash
.
length
==
0
)
{
return
true
;
}
SHA256
sha
=
new
SHA256
();
if
(
userPasswordHash
.
length
==
0
)
{
userPasswordHash
=
sha
.
getKeyPasswordHash
(
getName
(),
new
char
[
0
]);
userPasswordHash
=
SHA256
.
getKeyPasswordHash
(
getName
(),
new
char
[
0
]);
}
byte
[]
hash
=
sha
.
getHashWithSalt
(
userPasswordHash
,
salt
);
byte
[]
hash
=
SHA256
.
getHashWithSalt
(
userPasswordHash
,
salt
);
return
Utils
.
compareSecure
(
hash
,
passwordHash
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/AggregateData.java
浏览文件 @
8970b560
...
...
@@ -235,7 +235,7 @@ class AggregateData {
return
v
==
null
?
ValueNull
.
INSTANCE
:
v
.
convertTo
(
dataType
);
}
private
Value
divide
(
Value
a
,
long
by
)
{
private
static
Value
divide
(
Value
a
,
long
by
)
{
if
(
by
==
0
)
{
return
ValueNull
.
INSTANCE
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Function.java
浏览文件 @
8970b560
...
...
@@ -408,7 +408,7 @@ public class Function extends Expression implements FunctionCall {
}
}
private
strictfp
double
log10
(
double
value
)
{
private
st
atic
st
rictfp
double
log10
(
double
value
)
{
return
roundmagic
(
StrictMath
.
log
(
value
)
/
StrictMath
.
log
(
10
));
}
...
...
@@ -416,7 +416,7 @@ public class Function extends Expression implements FunctionCall {
return
getValueWithArgs
(
session
,
args
);
}
private
Value
getNullOrValue
(
Session
session
,
Expression
[]
x
,
int
i
)
{
private
static
Value
getNullOrValue
(
Session
session
,
Expression
[]
x
,
int
i
)
{
if
(
i
<
x
.
length
)
{
Expression
e
=
x
[
i
];
if
(
e
!=
null
)
{
...
...
@@ -824,7 +824,7 @@ public class Function extends Expression implements FunctionCall {
return
result
;
}
private
boolean
cancelStatement
(
Session
session
,
int
targetSessionId
)
{
private
static
boolean
cancelStatement
(
Session
session
,
int
targetSessionId
)
{
session
.
getUser
().
checkAdmin
();
Session
[]
sessions
=
session
.
getDatabase
().
getSessions
(
false
);
for
(
Session
s
:
sessions
)
{
...
...
@@ -1174,7 +1174,7 @@ public class Function extends Expression implements FunctionCall {
return
database
.
getSchema
(
schemaName
).
getSequence
(
sequenceName
);
}
private
long
length
(
Value
v
)
{
private
static
long
length
(
Value
v
)
{
switch
(
v
.
getType
())
{
case
Value
.
BLOB
:
case
Value
.
CLOB
:
...
...
@@ -1186,14 +1186,14 @@ public class Function extends Expression implements FunctionCall {
}
}
private
byte
[]
getPaddedArrayCopy
(
byte
[]
data
,
int
blockSize
)
{
private
static
byte
[]
getPaddedArrayCopy
(
byte
[]
data
,
int
blockSize
)
{
int
size
=
MathUtils
.
roundUpInt
(
data
.
length
,
blockSize
);
byte
[]
newData
=
Utils
.
newBytes
(
size
);
System
.
arraycopy
(
data
,
0
,
newData
,
0
,
data
.
length
);
return
newData
;
}
private
byte
[]
decrypt
(
String
algorithm
,
byte
[]
key
,
byte
[]
data
)
{
private
static
byte
[]
decrypt
(
String
algorithm
,
byte
[]
key
,
byte
[]
data
)
{
BlockCipher
cipher
=
CipherFactory
.
getBlockCipher
(
algorithm
);
byte
[]
newKey
=
getPaddedArrayCopy
(
key
,
cipher
.
getKeyLength
());
cipher
.
setKey
(
newKey
);
...
...
@@ -1202,7 +1202,7 @@ public class Function extends Expression implements FunctionCall {
return
newData
;
}
private
byte
[]
encrypt
(
String
algorithm
,
byte
[]
key
,
byte
[]
data
)
{
private
static
byte
[]
encrypt
(
String
algorithm
,
byte
[]
key
,
byte
[]
data
)
{
BlockCipher
cipher
=
CipherFactory
.
getBlockCipher
(
algorithm
);
byte
[]
newKey
=
getPaddedArrayCopy
(
key
,
cipher
.
getKeyLength
());
cipher
.
setKey
(
newKey
);
...
...
@@ -1211,10 +1211,12 @@ public class Function extends Expression implements FunctionCall {
return
newData
;
}
private
byte
[]
getHash
(
String
algorithm
,
byte
[]
bytes
,
int
iterations
)
{
SHA256
hash
=
CipherFactory
.
getHash
(
algorithm
);
private
static
byte
[]
getHash
(
String
algorithm
,
byte
[]
bytes
,
int
iterations
)
{
if
(!
"SHA256"
.
equalsIgnoreCase
(
algorithm
))
{
throw
DbException
.
getInvalidValueException
(
"algorithm"
,
algorithm
);
}
for
(
int
i
=
0
;
i
<
iterations
;
i
++)
{
bytes
=
hash
.
getHash
(
bytes
,
false
);
bytes
=
SHA256
.
getHash
(
bytes
,
false
);
}
return
bytes
;
}
...
...
@@ -1454,7 +1456,7 @@ public class Function extends Expression implements FunctionCall {
return
e
;
}
private
double
roundmagic
(
double
d
)
{
private
static
double
roundmagic
(
double
d
)
{
if
((
d
<
0.0000000000001
)
&&
(
d
>
-
0.0000000000001
))
{
return
0.0
;
}
...
...
@@ -1944,7 +1946,7 @@ public class Function extends Expression implements FunctionCall {
return
(
ValueResultSet
)
getValueWithArgs
(
session
,
argList
);
}
private
void
setCsvDelimiterEscape
(
Csv
csv
,
String
fieldSeparator
,
String
fieldDelimiter
,
String
escapeCharacter
)
{
private
static
void
setCsvDelimiterEscape
(
Csv
csv
,
String
fieldSeparator
,
String
fieldDelimiter
,
String
escapeCharacter
)
{
if
(
fieldSeparator
!=
null
)
{
csv
.
setFieldSeparatorWrite
(
fieldSeparator
);
if
(
fieldSeparator
.
length
()
>
0
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/TableFunction.java
浏览文件 @
8970b560
...
...
@@ -123,7 +123,7 @@ public class TableFunction extends Function {
return
vr
;
}
private
SimpleResultSet
getSimpleResultSet
(
ResultInterface
rs
,
int
maxrows
)
{
private
static
SimpleResultSet
getSimpleResultSet
(
ResultInterface
rs
,
int
maxrows
)
{
int
columnCount
=
rs
.
getVisibleColumnCount
();
SimpleResultSet
simple
=
new
SimpleResultSet
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/LinkedIndex.java
浏览文件 @
8970b560
...
...
@@ -44,7 +44,7 @@ public class LinkedIndex extends BaseIndex {
// nothing to do
}
private
boolean
isNull
(
Value
v
)
{
private
static
boolean
isNull
(
Value
v
)
{
return
v
==
null
||
v
==
ValueNull
.
INSTANCE
;
}
...
...
@@ -77,7 +77,7 @@ public class LinkedIndex extends BaseIndex {
prep
.
executeUpdate
();
rowCount
++;
}
catch
(
Exception
e
)
{
throw
l
ink
.
wrapException
(
sql
,
e
);
throw
TableL
ink
.
wrapException
(
sql
,
e
);
}
}
}
...
...
@@ -137,7 +137,7 @@ public class LinkedIndex extends BaseIndex {
ResultSet
rs
=
prep
.
executeQuery
();
return
new
LinkedCursor
(
link
,
rs
,
session
,
sql
,
prep
);
}
catch
(
Exception
e
)
{
throw
l
ink
.
wrapException
(
sql
,
e
);
throw
TableL
ink
.
wrapException
(
sql
,
e
);
}
}
}
...
...
@@ -214,7 +214,7 @@ public class LinkedIndex extends BaseIndex {
int
count
=
prep
.
executeUpdate
();
rowCount
-=
count
;
}
catch
(
Exception
e
)
{
throw
l
ink
.
wrapException
(
sql
,
e
);
throw
TableL
ink
.
wrapException
(
sql
,
e
);
}
}
}
...
...
@@ -276,7 +276,7 @@ public class LinkedIndex extends BaseIndex {
// this has no effect but at least it allows to debug the update count
rowCount
=
rowCount
+
count
-
count
;
}
catch
(
Exception
e
)
{
throw
l
ink
.
wrapException
(
sql
,
e
);
throw
TableL
ink
.
wrapException
(
sql
,
e
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageBtreeIndex.java
浏览文件 @
8970b560
...
...
@@ -455,7 +455,7 @@ public class PageBtreeIndex extends PageIndex {
*
* @return true if it is
*/
publ
ic
boolean
isMemoryChangeRequired
()
{
stat
ic
boolean
isMemoryChangeRequired
()
{
if
(
memoryChangeRequired
--
<=
0
)
{
memoryChangeRequired
=
10
;
return
true
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageBtreeLeaf.java
浏览文件 @
8970b560
...
...
@@ -363,7 +363,7 @@ public class PageBtreeLeaf extends PageBtree {
}
protected
void
memoryChange
()
{
if
(!
i
ndex
.
isMemoryChangeRequired
())
{
if
(!
PageBtreeI
ndex
.
isMemoryChangeRequired
())
{
return
;
}
int
memory
=
Constants
.
MEMORY_PAGE_BTREE
+
index
.
getPageStore
().
getPageSize
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
8970b560
...
...
@@ -18,7 +18,6 @@ import org.h2.engine.UndoLogRecord;
import
org.h2.message.DbException
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.store.Data
;
import
org.h2.store.Page
;
import
org.h2.store.PageStore
;
import
org.h2.table.Column
;
...
...
@@ -400,25 +399,6 @@ public class PageDataIndex extends PageIndex {
return
store
;
}
/**
* Read a row from the data page at the given position.
*
* @param data the data page
* @param pos the position to read from
* @param columnCount the number of columns
* @return the row
*/
Row
readRow
(
Data
data
,
int
pos
,
int
columnCount
)
{
Value
[]
values
=
new
Value
[
columnCount
];
synchronized
(
data
)
{
data
.
setPos
(
pos
);
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
values
[
i
]
=
data
.
readValue
();
}
}
return
tableData
.
createRow
(
values
);
}
public
long
getRowCountApproximation
()
{
return
rowCount
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
8970b560
...
...
@@ -17,6 +17,8 @@ import org.h2.result.Row;
import
org.h2.store.Data
;
import
org.h2.store.Page
;
import
org.h2.store.PageStore
;
import
org.h2.table.RegularTable
;
import
org.h2.value.Value
;
/**
* A leaf page that contains data of one or multiple rows. Format:
...
...
@@ -324,7 +326,7 @@ public class PageDataLeaf extends PageData {
Row
r
=
rows
[
at
];
if
(
r
==
null
)
{
if
(
firstOverflowPageId
==
0
)
{
r
=
index
.
readRow
(
data
,
offsets
[
at
],
columnCount
);
r
=
readRow
(
data
,
offsets
[
at
],
columnCount
);
}
else
{
if
(
rowRef
!=
null
)
{
r
=
rowRef
.
get
();
...
...
@@ -343,7 +345,7 @@ public class PageDataLeaf extends PageData {
next
=
page
.
readInto
(
buff
);
}
while
(
next
!=
0
);
overflowRowSize
=
pageSize
+
buff
.
length
();
r
=
index
.
readRow
(
buff
,
0
,
columnCount
);
r
=
readRow
(
buff
,
0
,
columnCount
);
}
r
.
setKey
(
keys
[
at
]);
if
(
firstOverflowPageId
!=
0
)
{
...
...
@@ -580,4 +582,23 @@ public class PageDataLeaf extends PageData {
return
firstOverflowPageId
>
0
;
}
/**
* Read a row from the data page at the given position.
*
* @param data the data page
* @param pos the position to read from
* @param columnCount the number of columns
* @return the row
*/
private
static
Row
readRow
(
Data
data
,
int
pos
,
int
columnCount
)
{
Value
[]
values
=
new
Value
[
columnCount
];
synchronized
(
data
)
{
data
.
setPos
(
pos
);
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
values
[
i
]
=
data
.
readValue
();
}
}
return
RegularTable
.
createRow
(
values
);
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/TreeCursor.java
浏览文件 @
8970b560
...
...
@@ -41,10 +41,10 @@ public class TreeCursor implements Cursor {
return
false
;
}
if
(
first
!=
null
&&
tree
.
compareRows
(
node
.
row
,
first
)
<
0
)
{
node
=
tree
.
next
(
node
);
node
=
next
(
node
);
}
}
else
{
node
=
tree
.
next
(
node
);
node
=
next
(
node
);
}
if
(
node
!=
null
&&
last
!=
null
)
{
if
(
tree
.
compareRows
(
node
.
row
,
last
)
>
0
)
{
...
...
@@ -55,8 +55,67 @@ public class TreeCursor implements Cursor {
}
public
boolean
previous
()
{
node
=
tree
.
previous
(
node
);
node
=
previous
(
node
);
return
node
!=
null
;
}
/**
* Get the next node if there is one.
*
* @param x the node
* @return the next node or null
*/
private
static
TreeNode
next
(
TreeNode
x
)
{
if
(
x
==
null
)
{
return
null
;
}
TreeNode
r
=
x
.
right
;
if
(
r
!=
null
)
{
x
=
r
;
TreeNode
l
=
x
.
left
;
while
(
l
!=
null
)
{
x
=
l
;
l
=
x
.
left
;
}
return
x
;
}
TreeNode
ch
=
x
;
x
=
x
.
parent
;
while
(
x
!=
null
&&
ch
==
x
.
right
)
{
ch
=
x
;
x
=
x
.
parent
;
}
return
x
;
}
/**
* Get the previous node if there is one.
*
* @param x the node
* @return the previous node or null
*/
private
static
TreeNode
previous
(
TreeNode
x
)
{
if
(
x
==
null
)
{
return
null
;
}
TreeNode
l
=
x
.
left
;
if
(
l
!=
null
)
{
x
=
l
;
TreeNode
r
=
x
.
right
;
while
(
r
!=
null
)
{
x
=
r
;
r
=
x
.
right
;
}
return
x
;
}
TreeNode
ch
=
x
;
x
=
x
.
parent
;
while
(
x
!=
null
&&
ch
==
x
.
left
)
{
ch
=
x
;
x
=
x
.
parent
;
}
return
x
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/TreeIndex.java
浏览文件 @
8970b560
...
...
@@ -108,7 +108,7 @@ public class TreeIndex extends BaseIndex {
}
}
private
TreeNode
child
(
TreeNode
x
,
boolean
isLeft
)
{
private
static
TreeNode
child
(
TreeNode
x
,
boolean
isLeft
)
{
return
isLeft
?
x
.
left
:
x
.
right
;
}
...
...
@@ -123,7 +123,7 @@ public class TreeIndex extends BaseIndex {
}
}
private
void
set
(
TreeNode
parent
,
boolean
left
,
TreeNode
n
)
{
private
static
void
set
(
TreeNode
parent
,
boolean
left
,
TreeNode
n
)
{
if
(
left
)
{
parent
.
left
=
n
;
}
else
{
...
...
@@ -304,64 +304,6 @@ public class TreeIndex extends BaseIndex {
rowCount
=
0
;
}
/**
* Get the next node if there is one.
*
* @param x the node
* @return the next node or null
*/
TreeNode
next
(
TreeNode
x
)
{
if
(
x
==
null
)
{
return
null
;
}
TreeNode
r
=
x
.
right
;
if
(
r
!=
null
)
{
x
=
r
;
TreeNode
l
=
x
.
left
;
while
(
l
!=
null
)
{
x
=
l
;
l
=
x
.
left
;
}
return
x
;
}
TreeNode
ch
=
x
;
x
=
x
.
parent
;
while
(
x
!=
null
&&
ch
==
x
.
right
)
{
ch
=
x
;
x
=
x
.
parent
;
}
return
x
;
}
/**
* Get the previous node if there is one.
*
* @param x the node
* @return the previous node or null
*/
TreeNode
previous
(
TreeNode
x
)
{
if
(
x
==
null
)
{
return
null
;
}
TreeNode
l
=
x
.
left
;
if
(
l
!=
null
)
{
x
=
l
;
TreeNode
r
=
x
.
right
;
while
(
r
!=
null
)
{
x
=
r
;
r
=
x
.
right
;
}
return
x
;
}
TreeNode
ch
=
x
;
x
=
x
.
parent
;
while
(
x
!=
null
&&
ch
==
x
.
left
)
{
ch
=
x
;
x
=
x
.
parent
;
}
return
x
;
}
public
void
checkRename
()
{
// nothing to do
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/ViewIndex.java
浏览文件 @
8970b560
...
...
@@ -234,7 +234,7 @@ public class ViewIndex extends BaseIndex {
return
new
ViewCursor
(
table
,
result
);
}
private
void
setParameter
(
ArrayList
<
Parameter
>
paramList
,
int
x
,
Value
v
)
{
private
static
void
setParameter
(
ArrayList
<
Parameter
>
paramList
,
int
x
,
Value
v
)
{
if
(
x
>=
paramList
.
size
())
{
// the parameter may be optimized away as in
// select * from (select null as x) where x=1;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcArray.java
浏览文件 @
8970b560
...
...
@@ -226,7 +226,7 @@ public class JdbcArray extends TraceObject implements Array {
value
=
null
;
}
private
ResultSet
getResultSet
(
Object
[]
array
,
long
offset
)
{
private
static
ResultSet
getResultSet
(
Object
[]
array
,
long
offset
)
{
SimpleResultSet
rs
=
new
SimpleResultSet
();
rs
.
addColumn
(
"INDEX"
,
Types
.
BIGINT
,
0
,
0
);
// TODO array result set: there are multiple data types possible
...
...
@@ -263,7 +263,7 @@ public class JdbcArray extends TraceObject implements Array {
return
subset
;
}
private
void
checkMap
(
Map
<
String
,
Class
<?>>
map
)
{
private
static
void
checkMap
(
Map
<
String
,
Class
<?>>
map
)
{
if
(
map
!=
null
&&
map
.
size
()
>
0
)
{
throw
DbException
.
getUnsupportedException
(
"map.size > 0"
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
8970b560
...
...
@@ -107,7 +107,7 @@ public class JdbcConnection extends TraceObject implements Connection {
}
checkJavaVersion
();
// this will return an embedded or server connection
session
=
new
SessionRemote
(
ci
).
c
reateSession
(
ci
);
session
=
new
SessionRemote
(
ci
).
c
onnectEmbeddedOrServer
(
false
);
trace
=
session
.
getTrace
();
int
id
=
getNextId
(
TraceObject
.
CONNECTION
);
setTrace
(
trace
,
TraceObject
.
CONNECTION
,
id
);
...
...
@@ -346,7 +346,7 @@ public class JdbcConnection extends TraceObject implements Connection {
setQueryTimeout
=
closeAndSetNull
(
setQueryTimeout
);
}
private
CommandInterface
closeAndSetNull
(
CommandInterface
command
)
{
private
static
CommandInterface
closeAndSetNull
(
CommandInterface
command
)
{
if
(
command
!=
null
)
{
command
.
close
();
}
...
...
@@ -960,7 +960,7 @@ public class JdbcConnection extends TraceObject implements Connection {
}
}
private
JdbcSavepoint
convertSavepoint
(
Savepoint
savepoint
)
{
private
static
JdbcSavepoint
convertSavepoint
(
Savepoint
savepoint
)
{
if
(!(
savepoint
instanceof
JdbcSavepoint
))
{
throw
DbException
.
get
(
ErrorCode
.
SAVEPOINT_IS_INVALID_1
,
""
+
savepoint
);
}
...
...
@@ -1066,7 +1066,7 @@ public class JdbcConnection extends TraceObject implements Connection {
// =============================================================
private
void
checkJavaVersion
()
{
private
static
void
checkJavaVersion
()
{
try
{
//## Java 1.4 begin ##
// check for existence of this class (avoiding Class . forName)
...
...
@@ -1093,7 +1093,7 @@ public class JdbcConnection extends TraceObject implements Connection {
return
old
==
null
?
session
.
prepareCommand
(
sql
,
Integer
.
MAX_VALUE
)
:
old
;
}
private
int
translateGetEnd
(
String
sql
,
int
i
,
char
c
)
{
private
static
int
translateGetEnd
(
String
sql
,
int
i
,
char
c
)
{
int
len
=
sql
.
length
();
switch
(
c
)
{
case
'$'
:
{
...
...
@@ -1161,7 +1161,7 @@ public class JdbcConnection extends TraceObject implements Connection {
* @param sql the SQL statement with or without JDBC escape sequences
* @return the SQL statement without JDBC escape sequences
*/
private
String
translateSQL
(
String
sql
)
{
private
static
String
translateSQL
(
String
sql
)
{
return
translateSQL
(
sql
,
true
);
}
...
...
@@ -1173,7 +1173,7 @@ public class JdbcConnection extends TraceObject implements Connection {
* @param escapeProcessing whether escape sequences should be replaced
* @return the SQL statement without JDBC escape sequences
*/
String
translateSQL
(
String
sql
,
boolean
escapeProcessing
)
{
static
String
translateSQL
(
String
sql
,
boolean
escapeProcessing
)
{
if
(
sql
==
null
)
{
throw
DbException
.
getInvalidValueException
(
"SQL"
,
null
);
}
...
...
@@ -1291,17 +1291,17 @@ public class JdbcConnection extends TraceObject implements Connection {
return
sql
;
}
private
void
checkRunOver
(
int
i
,
int
len
,
String
sql
)
{
private
static
void
checkRunOver
(
int
i
,
int
len
,
String
sql
)
{
if
(
i
>=
len
)
{
throw
DbException
.
getSyntaxError
(
sql
,
i
);
}
}
private
boolean
found
(
String
sql
,
int
start
,
String
other
)
{
private
static
boolean
found
(
String
sql
,
int
start
,
String
other
)
{
return
sql
.
regionMatches
(
true
,
start
,
other
,
0
,
other
.
length
());
}
private
void
checkTypeConcurrency
(
int
resultSetType
,
int
resultSetConcurrency
)
{
private
static
void
checkTypeConcurrency
(
int
resultSetType
,
int
resultSetConcurrency
)
{
switch
(
resultSetType
)
{
case
ResultSet
.
TYPE_FORWARD_ONLY
:
case
ResultSet
.
TYPE_SCROLL_INSENSITIVE
:
...
...
@@ -1319,7 +1319,7 @@ public class JdbcConnection extends TraceObject implements Connection {
}
}
private
void
checkHoldability
(
int
resultSetHoldability
)
{
private
static
void
checkHoldability
(
int
resultSetHoldability
)
{
// TODO compatibility / correctness: DBPool uses
// ResultSet.HOLD_CURSORS_OVER_COMMIT
//## Java 1.4 begin ##
...
...
@@ -1666,7 +1666,7 @@ public class JdbcConnection extends TraceObject implements Connection {
return
v
;
}
private
void
checkMap
(
Map
<
String
,
Class
<?>>
map
)
{
private
static
void
checkMap
(
Map
<
String
,
Class
<?>>
map
)
{
if
(
map
!=
null
&&
map
.
size
()
>
0
)
{
throw
DbException
.
getUnsupportedException
(
"map.size > 0"
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
8970b560
...
...
@@ -2741,15 +2741,15 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
conn
.
checkClosed
();
}
private
String
getPattern
(
String
pattern
)
{
private
static
String
getPattern
(
String
pattern
)
{
return
pattern
==
null
?
"%"
:
pattern
;
}
private
String
getSchemaPattern
(
String
pattern
)
{
private
static
String
getSchemaPattern
(
String
pattern
)
{
return
pattern
==
null
?
"%"
:
pattern
.
length
()
==
0
?
Constants
.
SCHEMA_MAIN
:
pattern
;
}
private
String
getCatalogPattern
(
String
catalogPattern
)
{
private
static
String
getCatalogPattern
(
String
catalogPattern
)
{
// Workaround for OpenOffice: getColumns is called with "" as the catalog
return
catalogPattern
==
null
||
catalogPattern
.
length
()
==
0
?
"%"
:
catalogPattern
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcStatement.java
浏览文件 @
8970b560
...
...
@@ -67,7 +67,7 @@ public class JdbcStatement extends TraceObject implements Statement {
synchronized
(
session
)
{
checkClosed
();
closeOldResultSet
();
sql
=
con
n
.
translateSQL
(
sql
,
escapeProcessing
);
sql
=
JdbcConnectio
n
.
translateSQL
(
sql
,
escapeProcessing
);
CommandInterface
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
ResultInterface
result
;
boolean
scrollable
=
resultSetType
!=
ResultSet
.
TYPE_FORWARD_ONLY
;
...
...
@@ -118,7 +118,7 @@ public class JdbcStatement extends TraceObject implements Statement {
checkClosedForWrite
();
try
{
closeOldResultSet
();
sql
=
con
n
.
translateSQL
(
sql
,
escapeProcessing
);
sql
=
JdbcConnectio
n
.
translateSQL
(
sql
,
escapeProcessing
);
CommandInterface
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
synchronized
(
session
)
{
setExecutingStatement
(
command
);
...
...
@@ -161,7 +161,7 @@ public class JdbcStatement extends TraceObject implements Statement {
checkClosedForWrite
();
try
{
closeOldResultSet
();
sql
=
con
n
.
translateSQL
(
sql
,
escapeProcessing
);
sql
=
JdbcConnectio
n
.
translateSQL
(
sql
,
escapeProcessing
);
CommandInterface
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
boolean
returnsResultSet
;
synchronized
(
session
)
{
...
...
@@ -587,7 +587,7 @@ public class JdbcStatement extends TraceObject implements Statement {
try
{
debugCodeCall
(
"addBatch"
,
sql
);
checkClosed
();
sql
=
con
n
.
translateSQL
(
sql
,
escapeProcessing
);
sql
=
JdbcConnectio
n
.
translateSQL
(
sql
,
escapeProcessing
);
if
(
batchCommands
==
null
)
{
batchCommands
=
New
.
arrayList
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
浏览文件 @
8970b560
...
...
@@ -228,11 +228,11 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
this
.
passwordChars
=
password
;
}
private
char
[]
convertToCharArray
(
String
s
)
{
private
static
char
[]
convertToCharArray
(
String
s
)
{
return
s
==
null
?
null
:
s
.
toCharArray
();
}
private
String
convertToString
(
char
[]
a
)
{
private
static
String
convertToString
(
char
[]
a
)
{
return
a
==
null
?
null
:
new
String
(
a
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
浏览文件 @
8970b560
...
...
@@ -421,13 +421,13 @@ implements XAConnection, XAResource
return
getTraceObjectName
()
+
": "
+
physicalConn
;
}
private
XAException
convertException
(
SQLException
e
)
{
private
static
XAException
convertException
(
SQLException
e
)
{
XAException
xa
=
new
XAException
(
e
.
getMessage
());
xa
.
initCause
(
e
);
return
xa
;
}
private
String
quoteFlags
(
int
flags
)
{
private
static
String
quoteFlags
(
int
flags
)
{
StringBuilder
buff
=
new
StringBuilder
();
if
((
flags
&
XAResource
.
TMENDRSCAN
)
!=
0
)
{
buff
.
append
(
"|XAResource.TMENDRSCAN"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/message/TraceObject.java
浏览文件 @
8970b560
...
...
@@ -163,7 +163,7 @@ public class TraceObject {
* @param type the object type
* @return the new trace object id
*/
protected
int
getNextId
(
int
type
)
{
protected
static
int
getNextId
(
int
type
)
{
return
ID
[
type
]++;
}
...
...
@@ -257,7 +257,7 @@ public class TraceObject {
* @param s the string to convert
* @return the Java string literal
*/
protected
String
quote
(
String
s
)
{
protected
static
String
quote
(
String
s
)
{
return
StringUtils
.
quoteJavaString
(
s
);
}
...
...
@@ -267,7 +267,7 @@ public class TraceObject {
* @param x the time to convert
* @return the Java source code
*/
protected
String
quoteTime
(
java
.
sql
.
Time
x
)
{
protected
static
String
quoteTime
(
java
.
sql
.
Time
x
)
{
if
(
x
==
null
)
{
return
"null"
;
}
...
...
@@ -280,7 +280,7 @@ public class TraceObject {
* @param x the timestamp to convert
* @return the Java source code
*/
protected
String
quoteTimestamp
(
java
.
sql
.
Timestamp
x
)
{
protected
static
String
quoteTimestamp
(
java
.
sql
.
Timestamp
x
)
{
if
(
x
==
null
)
{
return
"null"
;
}
...
...
@@ -293,7 +293,7 @@ public class TraceObject {
* @param x the date to convert
* @return the Java source code
*/
protected
String
quoteDate
(
java
.
sql
.
Date
x
)
{
protected
static
String
quoteDate
(
java
.
sql
.
Date
x
)
{
if
(
x
==
null
)
{
return
"null"
;
}
...
...
@@ -306,7 +306,7 @@ public class TraceObject {
* @param x the big decimal to convert
* @return the Java source code
*/
protected
String
quoteBigDecimal
(
BigDecimal
x
)
{
protected
static
String
quoteBigDecimal
(
BigDecimal
x
)
{
if
(
x
==
null
)
{
return
"null"
;
}
...
...
@@ -319,7 +319,7 @@ public class TraceObject {
* @param x the byte array to convert
* @return the Java source code
*/
protected
String
quoteBytes
(
byte
[]
x
)
{
protected
static
String
quoteBytes
(
byte
[]
x
)
{
if
(
x
==
null
)
{
return
"null"
;
}
...
...
@@ -333,7 +333,7 @@ public class TraceObject {
* @param s the string array to convert
* @return the Java source code
*/
protected
String
quoteArray
(
String
[]
s
)
{
protected
static
String
quoteArray
(
String
[]
s
)
{
return
StringUtils
.
quoteJavaStringArray
(
s
);
}
...
...
@@ -343,7 +343,7 @@ public class TraceObject {
* @param s the int array to convert
* @return the Java source code
*/
protected
String
quoteIntArray
(
int
[]
s
)
{
protected
static
String
quoteIntArray
(
int
[]
s
)
{
return
StringUtils
.
quoteJavaIntArray
(
s
);
}
...
...
@@ -353,7 +353,7 @@ public class TraceObject {
* @param map the map to convert
* @return the Java source code
*/
protected
String
quoteMap
(
Map
<
String
,
Class
<?>>
map
)
{
protected
static
String
quoteMap
(
Map
<
String
,
Class
<?>>
map
)
{
if
(
map
==
null
)
{
return
"null"
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/ResultTempTable.java
浏览文件 @
8970b560
...
...
@@ -183,7 +183,7 @@ public class ResultTempTable implements ResultExternal {
resultCursor
=
index
.
find
(
session
,
null
,
null
);
}
private
Row
convertToRow
(
Value
[]
values
)
{
private
static
Row
convertToRow
(
Value
[]
values
)
{
ValueArray
data
=
ValueArray
.
get
(
values
);
return
new
Row
(
new
Value
[]{
data
},
Row
.
MEMORY_CALCULATE
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/RowList.java
浏览文件 @
8970b560
...
...
@@ -106,7 +106,7 @@ public class RowList {
memory
=
0
;
}
private
void
initBuffer
(
Data
buff
)
{
private
static
void
initBuffer
(
Data
buff
)
{
buff
.
reset
();
buff
.
writeInt
(
0
);
}
...
...
@@ -218,7 +218,7 @@ public class RowList {
if
(
len
-
min
>
0
)
{
file
.
readFully
(
buff
.
getBytes
(),
min
,
len
-
min
);
}
for
(
int
i
=
0
;;
i
++
)
{
while
(
true
)
{
r
=
readRow
(
buff
);
if
(
r
==
null
)
{
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/schema/TriggerObject.java
浏览文件 @
8970b560
...
...
@@ -128,7 +128,7 @@ public class TriggerObject extends SchemaObjectBase {
}
}
private
Object
[]
convertToObjectList
(
Row
row
)
{
private
static
Object
[]
convertToObjectList
(
Row
row
)
{
if
(
row
==
null
)
{
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/security/AES.java
浏览文件 @
8970b560
...
...
@@ -85,7 +85,7 @@ public class AES implements BlockCipher {
}
}
private
int
getDec
(
int
t
)
{
private
static
int
getDec
(
int
t
)
{
return
RT0
[
FS
[(
t
>>
24
)
&
255
]]
^
RT1
[
FS
[(
t
>>
16
)
&
255
]]
^
RT2
[
FS
[(
t
>>
8
)
&
255
]]
^
RT3
[
FS
[
t
&
255
]];
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/security/CipherFactory.java
浏览文件 @
8970b560
...
...
@@ -43,6 +43,7 @@ public class CipherFactory {
* The default password to use for the .h2.keystore file
*/
public
static
final
String
KEYSTORE_PASSWORD
=
"h2pass"
;
private
static
final
String
KEYSTORE
=
"~/.h2.keystore"
;
private
static
final
String
KEYSTORE_KEY
=
"javax.net.ssl.keyStore"
;
private
static
final
String
KEYSTORE_PASSWORD_KEY
=
"javax.net.ssl.keyStorePassword"
;
...
...
@@ -69,19 +70,6 @@ public class CipherFactory {
throw
DbException
.
get
(
ErrorCode
.
UNSUPPORTED_CIPHER
,
algorithm
);
}
/**
* Get a new cryptographic hash object for the given algorithm.
*
* @param algorithm the algorithm
* @return a new hash object
*/
public
static
SHA256
getHash
(
String
algorithm
)
{
if
(
"SHA256"
.
equalsIgnoreCase
(
algorithm
))
{
return
new
SHA256
();
}
throw
DbException
.
getInvalidValueException
(
"algorithm"
,
algorithm
);
}
/**
* Create a secure client socket that is connected to the given address and port.
*
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/security/SHA256.java
浏览文件 @
8970b560
...
...
@@ -42,7 +42,7 @@ public class SHA256 {
* @param salt the salt to use
* @return the hash code
*/
public
byte
[]
getHashWithSalt
(
byte
[]
data
,
byte
[]
salt
)
{
public
static
byte
[]
getHashWithSalt
(
byte
[]
data
,
byte
[]
salt
)
{
byte
[]
buff
=
new
byte
[
data
.
length
+
salt
.
length
];
System
.
arraycopy
(
data
,
0
,
buff
,
0
,
data
.
length
);
System
.
arraycopy
(
salt
,
0
,
buff
,
data
.
length
,
salt
.
length
);
...
...
@@ -60,7 +60,7 @@ public class SHA256 {
* @param password the password
* @return the hash code
*/
public
byte
[]
getKeyPasswordHash
(
String
userName
,
char
[]
password
)
{
public
static
byte
[]
getKeyPasswordHash
(
String
userName
,
char
[]
password
)
{
String
user
=
userName
+
"@"
;
byte
[]
buff
=
new
byte
[
2
*
(
user
.
length
()
+
password
.
length
)];
int
n
=
0
;
...
...
@@ -85,7 +85,7 @@ public class SHA256 {
* the hash code
* @return the hash code
*/
public
byte
[]
getHash
(
byte
[]
data
,
boolean
nullData
)
{
public
static
byte
[]
getHash
(
byte
[]
data
,
boolean
nullData
)
{
int
byteLen
=
data
.
length
;
int
intLen
=
((
byteLen
+
9
+
63
)
/
64
)
*
16
;
byte
[]
bytes
=
new
byte
[
intLen
*
4
];
...
...
@@ -152,16 +152,16 @@ public class SHA256 {
return
result
;
}
private
int
rot
(
int
i
,
int
count
)
{
private
static
int
rot
(
int
i
,
int
count
)
{
return
(
i
<<
(
32
-
count
))
|
(
i
>>>
count
);
}
private
int
readInt
(
byte
[]
b
,
int
i
)
{
private
static
int
readInt
(
byte
[]
b
,
int
i
)
{
return
((
b
[
i
]
&
0xff
)
<<
24
)
+
((
b
[
i
+
1
]
&
0xff
)
<<
16
)
+
((
b
[
i
+
2
]
&
0xff
)
<<
8
)
+
(
b
[
i
+
3
]
&
0xff
);
}
private
void
writeInt
(
byte
[]
b
,
int
i
,
int
value
)
{
private
static
void
writeInt
(
byte
[]
b
,
int
i
,
int
value
)
{
b
[
i
]
=
(
byte
)
(
value
>>
24
);
b
[
i
+
1
]
=
(
byte
)
(
value
>>
16
);
b
[
i
+
2
]
=
(
byte
)
(
value
>>
8
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/security/SecureFileStore.java
浏览文件 @
8970b560
...
...
@@ -40,13 +40,12 @@ public class SecureFileStore extends FileStore {
}
protected
void
initKey
(
byte
[]
salt
)
{
SHA256
sha
=
new
SHA256
();
key
=
sha
.
getHashWithSalt
(
key
,
salt
);
key
=
SHA256
.
getHashWithSalt
(
key
,
salt
);
for
(
int
i
=
0
;
i
<
keyIterations
;
i
++)
{
key
=
sha
.
getHash
(
key
,
true
);
key
=
SHA256
.
getHash
(
key
,
true
);
}
cipher
.
setKey
(
key
);
key
=
sha
.
getHash
(
key
,
true
);
key
=
SHA256
.
getHash
(
key
,
true
);
cipherForInitVector
.
setKey
(
key
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
8970b560
...
...
@@ -582,7 +582,7 @@ public class PgServerThread implements Runnable {
}
}
private
int
getTypeSize
(
int
pgType
,
int
precision
)
{
private
static
int
getTypeSize
(
int
pgType
,
int
precision
)
{
switch
(
pgType
)
{
case
PgServer
.
PG_TYPE_VARCHAR
:
return
Math
.
max
(
255
,
precision
+
10
);
...
...
@@ -657,7 +657,7 @@ public class PgServerThread implements Runnable {
}
}
private
void
installPgCatalog
(
Statement
stat
)
throws
SQLException
{
private
static
void
installPgCatalog
(
Statement
stat
)
throws
SQLException
{
Reader
r
=
null
;
try
{
r
=
new
InputStreamReader
(
new
ByteArrayInputStream
(
Utils
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/ConnectionInfo.java
浏览文件 @
8970b560
...
...
@@ -52,7 +52,7 @@ public class ConnectionInfo implements Comparable<ConnectionInfo> {
user
=
get
(
array
,
3
);
}
private
String
get
(
String
[]
array
,
int
i
)
{
private
static
String
get
(
String
[]
array
,
int
i
)
{
return
array
!=
null
&&
array
.
length
>
i
?
array
[
i
]
:
""
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/DbContextRule.java
浏览文件 @
8970b560
...
...
@@ -185,7 +185,7 @@ public class DbContextRule implements Rule {
return
false
;
}
private
String
autoCompleteTableAlias
(
Sentence
sentence
,
boolean
newAlias
)
{
private
static
String
autoCompleteTableAlias
(
Sentence
sentence
,
boolean
newAlias
)
{
String
s
=
sentence
.
getQuery
();
String
up
=
sentence
.
getQueryUpper
();
int
i
=
0
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/DbStarter.java
浏览文件 @
8970b560
...
...
@@ -54,7 +54,7 @@ public class DbStarter implements ServletContextListener {
}
}
private
String
getParameter
(
ServletContext
servletContext
,
String
key
,
String
defaultValue
)
{
private
static
String
getParameter
(
ServletContext
servletContext
,
String
key
,
String
defaultValue
)
{
String
value
=
servletContext
.
getInitParameter
(
key
);
return
value
==
null
?
defaultValue
:
value
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebApp.java
浏览文件 @
8970b560
...
...
@@ -166,7 +166,7 @@ public class WebApp {
return
file
;
}
private
String
getComboBox
(
String
[]
elements
,
String
selected
)
{
private
static
String
getComboBox
(
String
[]
elements
,
String
selected
)
{
StringBuilder
buff
=
new
StringBuilder
();
for
(
String
value
:
elements
)
{
buff
.
append
(
"<option value=\""
).
...
...
@@ -182,7 +182,7 @@ public class WebApp {
return
buff
.
toString
();
}
private
String
getComboBox
(
String
[][]
elements
,
String
selected
)
{
private
static
String
getComboBox
(
String
[][]
elements
,
String
selected
)
{
StringBuilder
buff
=
new
StringBuilder
();
for
(
String
[]
n
:
elements
)
{
buff
.
append
(
"<option value=\""
).
...
...
@@ -420,7 +420,7 @@ public class WebApp {
}
private
String
index
()
{
String
[][]
languageArray
=
server
.
getLanguageArray
()
;
String
[][]
languageArray
=
WebServer
.
LANGUAGES
;
String
language
=
(
String
)
attributes
.
get
(
"language"
);
Locale
locale
=
session
.
locale
;
if
(
language
!=
null
)
{
...
...
@@ -465,7 +465,7 @@ public class WebApp {
return
"query.jsp"
;
}
private
int
addColumns
(
boolean
mainSchema
,
DbTableOrView
table
,
StringBuilder
buff
,
int
treeIndex
,
boolean
showColumnTypes
,
private
static
int
addColumns
(
boolean
mainSchema
,
DbTableOrView
table
,
StringBuilder
buff
,
int
treeIndex
,
boolean
showColumnTypes
,
StringBuilder
columnsBuffer
)
{
DbColumn
[]
columns
=
table
.
columns
;
for
(
int
i
=
0
;
columns
!=
null
&&
i
<
columns
.
length
;
i
++)
{
...
...
@@ -509,7 +509,7 @@ public class WebApp {
String
columns
;
}
private
int
addIndexes
(
boolean
mainSchema
,
DatabaseMetaData
meta
,
String
table
,
String
schema
,
StringBuilder
buff
,
int
treeIndex
)
private
static
int
addIndexes
(
boolean
mainSchema
,
DatabaseMetaData
meta
,
String
table
,
String
schema
,
StringBuilder
buff
,
int
treeIndex
)
throws
SQLException
{
ResultSet
rs
;
try
{
...
...
@@ -767,7 +767,7 @@ public class WebApp {
}
}
private
String
linkToSource
(
String
s
)
{
private
static
String
linkToSource
(
String
s
)
{
try
{
StringBuilder
result
=
new
StringBuilder
(
s
.
length
());
int
idx
=
s
.
indexOf
(
"<br />"
);
...
...
@@ -810,7 +810,7 @@ public class WebApp {
}
}
private
String
formatAsError
(
String
s
)
{
private
static
String
formatAsError
(
String
s
)
{
return
"<div class=\"error\">"
+
s
+
"</div>"
;
}
...
...
@@ -887,9 +887,6 @@ public class WebApp {
session
.
put
(
"autoCommit"
,
"checked"
);
session
.
put
(
"autoComplete"
,
"1"
);
session
.
put
(
"maxrows"
,
"1000"
);
if
(
loginAsync
(
driver
,
url
,
user
,
password
))
{
return
""
;
}
boolean
isH2
=
url
.
startsWith
(
"jdbc:h2:"
);
try
{
Connection
conn
=
server
.
getConnection
(
driver
,
url
,
user
,
password
);
...
...
@@ -905,19 +902,6 @@ public class WebApp {
}
}
/**
* Login in a separate thread if possible.
*
* @param driver the driver class
* @param url the database URL
* @param user the user name
* @param password the password
* @return false if asynchronous login is not possible
*/
protected
boolean
loginAsync
(
String
driver
,
String
url
,
String
user
,
String
password
)
{
return
false
;
}
private
String
logout
()
{
try
{
Connection
conn
=
session
.
getConnection
();
...
...
@@ -1168,7 +1152,7 @@ public class WebApp {
return
null
;
}
private
void
addDatabaseMetaData
(
SimpleResultSet
rs
,
DatabaseMetaData
meta
)
{
private
static
void
addDatabaseMetaData
(
SimpleResultSet
rs
,
DatabaseMetaData
meta
)
{
Method
[]
methods
=
DatabaseMetaData
.
class
.
getDeclaredMethods
();
Arrays
.
sort
(
methods
,
new
Comparator
<
Method
>()
{
public
int
compare
(
Method
o1
,
Method
o2
)
{
...
...
@@ -1189,7 +1173,7 @@ public class WebApp {
}
}
private
String
[]
split
(
String
s
)
{
private
static
String
[]
split
(
String
s
)
{
String
[]
list
=
new
String
[
10
];
String
[]
t
=
StringUtils
.
arraySplit
(
s
,
' '
,
true
);
System
.
arraycopy
(
t
,
0
,
list
,
0
,
t
.
length
);
...
...
@@ -1283,8 +1267,7 @@ public class WebApp {
}
else
if
(
isBuiltIn
(
sql
,
"@password_hash"
))
{
sql
=
sql
.
substring
(
"@password_hash"
.
length
()).
trim
();
String
[]
p
=
split
(
sql
);
SHA256
sha
=
new
SHA256
();
return
StringUtils
.
convertBytesToString
(
sha
.
getKeyPasswordHash
(
p
[
0
],
p
[
1
].
toCharArray
()));
return
StringUtils
.
convertBytesToString
(
SHA256
.
getKeyPasswordHash
(
p
[
0
],
p
[
1
].
toCharArray
()));
}
else
if
(
isBuiltIn
(
sql
,
"@prof_start"
))
{
if
(
profiler
!=
null
)
{
profiler
.
stopCollecting
();
...
...
@@ -1359,7 +1342,7 @@ public class WebApp {
}
}
private
boolean
isBuiltIn
(
String
sql
,
String
builtIn
)
{
private
static
boolean
isBuiltIn
(
String
sql
,
String
builtIn
)
{
return
StringUtils
.
startsWithIgnoreCase
(
sql
,
builtIn
);
}
...
...
@@ -1379,7 +1362,6 @@ public class WebApp {
}
idx
++;
}
int
rows
=
0
;
boolean
prepared
;
Random
random
=
new
Random
(
1
);
long
time
=
System
.
currentTimeMillis
();
...
...
@@ -1400,7 +1382,6 @@ public class WebApp {
if
(
stat
.
execute
(
s
))
{
ResultSet
rs
=
stat
.
getResultSet
();
while
(!
stop
&&
rs
.
next
())
{
rows
++;
// maybe get the data as well
}
rs
.
close
();
...
...
@@ -1425,7 +1406,6 @@ public class WebApp {
if
(
prep
.
execute
())
{
ResultSet
rs
=
prep
.
getResultSet
();
while
(!
stop
&&
rs
.
next
())
{
rows
++;
// maybe get the data as well
}
rs
.
close
();
...
...
@@ -1469,7 +1449,7 @@ public class WebApp {
return
buff
.
toString
();
}
private
String
getParameterResultSet
(
ParameterMetaData
meta
)
throws
SQLException
{
private
static
String
getParameterResultSet
(
ParameterMetaData
meta
)
throws
SQLException
{
StringBuilder
buff
=
new
StringBuilder
();
if
(
meta
==
null
)
{
return
"No parameter meta data"
;
...
...
@@ -1683,7 +1663,7 @@ public class WebApp {
return
"index.do"
;
}
private
String
escapeData
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
private
static
String
escapeData
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
String
d
=
rs
.
getString
(
columnIndex
);
if
(
d
==
null
)
{
return
"<i>null</i>"
;
...
...
@@ -1701,7 +1681,7 @@ public class WebApp {
return
PageParser
.
escapeHtml
(
d
);
}
private
boolean
isBinary
(
int
sqlType
)
{
private
static
boolean
isBinary
(
int
sqlType
)
{
switch
(
sqlType
)
{
case
Types
.
BINARY
:
case
Types
.
BLOB
:
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebServer.java
浏览文件 @
8970b560
...
...
@@ -49,9 +49,7 @@ public class WebServer implements Service {
static
final
String
TRANSFER
=
"transfer"
;
private
static
final
String
DEFAULT_LANGUAGE
=
"en"
;
private
static
final
String
[][]
LANGUAGES
=
{
static
final
String
[][]
LANGUAGES
=
{
{
"cs"
,
"\u010ce\u0161tina"
},
{
"de"
,
"Deutsch"
},
{
"en"
,
"English"
},
...
...
@@ -73,6 +71,8 @@ public class WebServer implements Service {
{
"zh_TW"
,
"\u4e2d\u6587 (\u7e41\u9ad4)"
},
};
private
static
final
String
DEFAULT_LANGUAGE
=
"en"
;
private
static
final
String
[]
GENERIC
=
{
"Generic JNDI Data Source|javax.naming.InitialContext|java:comp/env/jdbc/Test|sa"
,
"Generic Firebird Server|org.firebirdsql.jdbc.FBDriver|jdbc:firebirdsql:localhost:c:/temp/firebird/test|sysdba"
,
...
...
@@ -177,7 +177,7 @@ public class WebServer implements Service {
* @param s the string
* @return true if it's a simple name
*/
boolean
isSimpleName
(
String
s
)
{
static
boolean
isSimpleName
(
String
s
)
{
for
(
char
c
:
s
.
toCharArray
())
{
if
(
c
!=
'.'
&&
c
!=
'_'
&&
c
!=
'-'
&&
!
Character
.
isLetterOrDigit
(
c
))
{
return
false
;
...
...
@@ -195,7 +195,7 @@ public class WebServer implements Service {
running
.
remove
(
t
);
}
private
String
generateSessionId
()
{
private
static
String
generateSessionId
()
{
byte
[]
buff
=
MathUtils
.
secureRandomBytes
(
16
);
return
StringUtils
.
convertBytesToString
(
buff
);
}
...
...
@@ -453,10 +453,6 @@ public class WebServer implements Service {
session
.
put
(
"text"
,
new
HashMap
<
Object
,
Object
>(
text
));
}
String
[][]
getLanguageArray
()
{
return
LANGUAGES
;
}
ArrayList
<
HashMap
<
String
,
Object
>>
getSessions
()
{
ArrayList
<
HashMap
<
String
,
Object
>>
list
=
New
.
arrayList
();
for
(
WebSession
s
:
sessions
.
values
())
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebThread.java
浏览文件 @
8970b560
...
...
@@ -348,7 +348,7 @@ class WebThread extends WebApp implements Runnable {
}
trace
(
" "
+
line
);
}
if
(!
s
erver
.
isSimpleName
(
fileName
))
{
if
(!
WebS
erver
.
isSimpleName
(
fileName
))
{
return
;
}
len
-=
headerBytes
;
...
...
@@ -376,7 +376,7 @@ class WebThread extends WebApp implements Runnable {
f
.
close
();
}
private
String
getHeaderLineValue
(
String
line
)
{
private
static
String
getHeaderLineValue
(
String
line
)
{
return
line
.
substring
(
line
.
indexOf
(
':'
)
+
1
).
trim
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/FileLock.java
浏览文件 @
8970b560
...
...
@@ -427,7 +427,7 @@ public class FileLock implements Runnable {
watchdog
.
start
();
}
private
void
sleep
(
int
time
)
{
private
static
void
sleep
(
int
time
)
{
try
{
Thread
.
sleep
(
time
);
}
catch
(
InterruptedException
e
)
{
...
...
@@ -435,7 +435,7 @@ public class FileLock implements Runnable {
}
}
private
DbException
getExceptionFatal
(
String
reason
,
Throwable
t
)
{
private
static
DbException
getExceptionFatal
(
String
reason
,
Throwable
t
)
{
return
DbException
.
get
(
ErrorCode
.
ERROR_OPENING_DATABASE_1
,
t
,
reason
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/PageInputStream.java
浏览文件 @
8970b560
...
...
@@ -121,7 +121,7 @@ public class PageInputStream extends InputStream {
endOfFile
=
true
;
return
;
}
dataPos
=
d
ata
.
getReadStart
();
dataPos
=
PageStreamD
ata
.
getReadStart
();
remaining
=
store
.
getPageSize
()
-
dataPos
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/PageOutputStream.java
浏览文件 @
8970b560
...
...
@@ -29,7 +29,6 @@ public class PageOutputStream {
private
int
trunkIndex
;
private
PageStreamData
data
;
private
int
reserved
;
private
int
remaining
;
private
boolean
needFlush
;
private
boolean
writing
;
private
int
pageCount
;
...
...
@@ -135,7 +134,6 @@ public class PageOutputStream {
len
-=
l
;
}
needFlush
=
true
;
remaining
-=
len
;
}
finally
{
writing
=
false
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/PageStreamData.java
浏览文件 @
8970b560
...
...
@@ -161,7 +161,7 @@ public class PageStreamData extends Page {
return
true
;
}
public
int
getReadStart
()
{
public
static
int
getReadStart
()
{
return
DATA_START
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileObjectDiskMapped.java
浏览文件 @
8970b560
...
...
@@ -113,7 +113,7 @@ public class FileObjectDiskMapped implements FileObject {
this
.
pos
=
Math
.
min
(
oldPos
,
(
int
)
length
);
}
private
void
checkFileSizeLimit
(
long
length
)
throws
IOException
{
private
static
void
checkFileSizeLimit
(
long
length
)
throws
IOException
{
if
(
length
>
Integer
.
MAX_VALUE
)
{
throw
new
IOException
(
"File over 2GB is not supported yet when using this file system"
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileSystem.java
浏览文件 @
8970b560
...
...
@@ -304,7 +304,7 @@ public abstract class FileSystem {
* @param newRandom if the random part of the filename should change
* @return the file name part
*/
protected
synchronized
String
getNextTempFileNamePart
(
boolean
newRandom
)
{
protected
s
tatic
s
ynchronized
String
getNextTempFileNamePart
(
boolean
newRandom
)
{
if
(
newRandom
||
tempRandom
==
null
)
{
byte
[]
prefix
=
new
byte
[
8
];
MathUtils
.
randomBytes
(
prefix
);
...
...
@@ -346,4 +346,8 @@ public abstract class FileSystem {
*/
public
abstract
String
unwrap
(
String
fileName
);
protected
static
FileSystem
getFileSystem
(
String
fileName
)
{
return
FileSystem
.
getInstance
(
fileName
);
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileSystemDisk.java
浏览文件 @
8970b560
...
...
@@ -56,7 +56,7 @@ public class FileSystemDisk extends FileSystem {
* @param fileName the file name
* @return the native file name
*/
protected
String
translateFileName
(
String
fileName
)
{
protected
static
String
translateFileName
(
String
fileName
)
{
return
expandUserHomeDirectory
(
fileName
);
}
...
...
@@ -286,7 +286,7 @@ public class FileSystemDisk extends FileSystem {
return
canWriteInternal
(
new
File
(
fileName
));
}
private
boolean
canWriteInternal
(
File
file
)
{
private
static
boolean
canWriteInternal
(
File
file
)
{
try
{
if
(!
file
.
canWrite
())
{
return
false
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileSystemSplit.java
浏览文件 @
8970b560
...
...
@@ -182,7 +182,7 @@ public class FileSystemSplit extends FileSystemWrapper {
return
fo
;
}
private
void
closeAndThrow
(
FileObject
[]
array
,
FileObject
o
,
long
maxLength
)
throws
IOException
{
private
static
void
closeAndThrow
(
FileObject
[]
array
,
FileObject
o
,
long
maxLength
)
throws
IOException
{
String
message
=
"Expected file length: "
+
maxLength
+
" got: "
+
o
.
length
()
+
" for "
+
o
.
getName
();
for
(
FileObject
f
:
array
)
{
f
.
close
();
...
...
@@ -260,10 +260,6 @@ public class FileSystemSplit extends FileSystemWrapper {
return
fileName
;
}
private
FileSystem
getFileSystem
(
String
fileName
)
{
return
FileSystem
.
getInstance
(
fileName
);
}
protected
String
getPrefix
()
{
return
PREFIX
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileSystemWrapper.java
浏览文件 @
8970b560
...
...
@@ -25,16 +25,6 @@ public abstract class FileSystemWrapper extends FileSystem {
*/
protected
abstract
String
getPrefix
();
/**
* Wrap the file object if required.
*
* @param o the file object
* @return the wrapped object
*/
protected
FileObject
wrap
(
FileObject
o
)
{
return
null
;
}
public
boolean
canWrite
(
String
fileName
)
{
return
IOUtils
.
canWrite
(
unwrap
(
fileName
));
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileSystemZip.java
浏览文件 @
8970b560
...
...
@@ -219,7 +219,7 @@ public class FileSystemZip extends FileSystem {
return
false
;
}
private
String
translateFileName
(
String
fileName
)
{
private
static
String
translateFileName
(
String
fileName
)
{
if
(
fileName
.
startsWith
(
PREFIX
))
{
fileName
=
fileName
.
substring
(
PREFIX
.
length
());
}
...
...
@@ -230,7 +230,7 @@ public class FileSystemZip extends FileSystem {
return
FileSystemDisk
.
expandUserHomeDirectory
(
fileName
);
}
private
String
getEntryName
(
String
fileName
)
{
private
static
String
getEntryName
(
String
fileName
)
{
int
idx
=
fileName
.
indexOf
(
'!'
);
if
(
idx
<=
0
)
{
fileName
=
""
;
...
...
@@ -244,7 +244,7 @@ public class FileSystemZip extends FileSystem {
return
fileName
;
}
private
ZipFile
openZipFile
(
String
fileName
)
throws
IOException
{
private
static
ZipFile
openZipFile
(
String
fileName
)
throws
IOException
{
fileName
=
translateFileName
(
fileName
);
return
new
ZipFile
(
fileName
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Column.java
浏览文件 @
8970b560
...
...
@@ -358,7 +358,7 @@ public class Column {
originalSQL
=
"BIGINT"
;
}
String
sequenceName
;
for
(
int
i
=
0
;;
i
++
)
{
while
(
true
)
{
ValueUuid
uuid
=
ValueUuid
.
getNewRandom
();
String
s
=
uuid
.
getString
();
s
=
s
.
replace
(
'-'
,
'_'
).
toUpperCase
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
8970b560
...
...
@@ -598,7 +598,7 @@ public class MetaTable extends Table {
return
true
;
}
private
String
replaceNullWithEmpty
(
String
s
)
{
private
static
String
replaceNullWithEmpty
(
String
s
)
{
return
s
==
null
?
""
:
s
;
}
...
...
@@ -1596,7 +1596,7 @@ public class MetaTable extends Table {
return
rows
;
}
private
int
getRefAction
(
int
action
)
{
private
static
int
getRefAction
(
int
action
)
{
switch
(
action
)
{
case
ConstraintReferential
.
CASCADE
:
return
DatabaseMetaData
.
importedKeyCascade
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
8970b560
...
...
@@ -315,7 +315,7 @@ public class RegularTable extends TableBase {
return
true
;
}
private
void
addRowsToIndex
(
Session
session
,
ArrayList
<
Row
>
list
,
Index
index
)
{
private
static
void
addRowsToIndex
(
Session
session
,
ArrayList
<
Row
>
list
,
Index
index
)
{
final
Index
idx
=
index
;
Collections
.
sort
(
list
,
new
Comparator
<
Row
>()
{
public
int
compare
(
Row
r1
,
Row
r2
)
{
...
...
@@ -523,7 +523,7 @@ public class RegularTable extends TableBase {
}
}
private
String
getDeadlockDetails
(
ArrayList
<
Session
>
sessions
)
{
private
static
String
getDeadlockDetails
(
ArrayList
<
Session
>
sessions
)
{
StringBuilder
buff
=
new
StringBuilder
();
for
(
Session
s
:
sessions
)
{
Table
lock
=
s
.
getWaitForLock
();
...
...
@@ -631,7 +631,7 @@ public class RegularTable extends TableBase {
* @param data the value list
* @return the row
*/
public
Row
createRow
(
Value
[]
data
)
{
public
static
Row
createRow
(
Value
[]
data
)
{
return
new
Row
(
data
,
Row
.
MEMORY_CALCULATE
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Table.java
浏览文件 @
8970b560
...
...
@@ -655,7 +655,7 @@ public abstract class Table extends SchemaObjectBase {
}
}
private
void
remove
(
ArrayList
<?
extends
DbObject
>
list
,
DbObject
obj
)
{
private
static
void
remove
(
ArrayList
<?
extends
DbObject
>
list
,
DbObject
obj
)
{
if
(
list
!=
null
)
{
int
i
=
list
.
indexOf
(
obj
);
if
(
i
>=
0
)
{
...
...
@@ -760,7 +760,7 @@ public abstract class Table extends SchemaObjectBase {
triggers
=
add
(
triggers
,
trigger
);
}
private
<
T
>
ArrayList
<
T
>
add
(
ArrayList
<
T
>
list
,
T
obj
)
{
private
static
<
T
>
ArrayList
<
T
>
add
(
ArrayList
<
T
>
list
,
T
obj
)
{
if
(
list
==
null
)
{
list
=
New
.
arrayList
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
8970b560
...
...
@@ -259,7 +259,7 @@ public class TableLink extends Table {
}
}
private
long
convertPrecision
(
int
sqlType
,
long
precision
)
{
private
static
long
convertPrecision
(
int
sqlType
,
long
precision
)
{
// workaround for an Oracle problem:
// for DATE columns, the reported precision is 7
// for DECIMAL columns, the reported precision is 0
...
...
@@ -282,7 +282,7 @@ public class TableLink extends Table {
return
precision
;
}
private
int
convertScale
(
int
sqlType
,
int
scale
)
{
private
static
int
convertScale
(
int
sqlType
,
int
scale
)
{
// workaround for an Oracle problem:
// for DECIMAL columns, the reported precision is -127
switch
(
sqlType
)
{
...
...
@@ -415,7 +415,7 @@ public class TableLink extends Table {
* @param ex the exception from the remote database
* @return the wrapped exception
*/
public
DbException
wrapException
(
String
sql
,
Exception
ex
)
{
public
static
DbException
wrapException
(
String
sql
,
Exception
ex
)
{
SQLException
e
=
DbException
.
toSQLException
(
ex
);
return
DbException
.
get
(
ErrorCode
.
ERROR_ACCESSING_LINKED_TABLE_2
,
e
,
sql
,
e
.
toString
());
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/ChangeFileEncryption.java
浏览文件 @
8970b560
...
...
@@ -105,8 +105,7 @@ public class ChangeFileEncryption extends Tool {
if
(
password
==
null
)
{
return
null
;
}
SHA256
sha
=
new
SHA256
();
return
sha
.
getKeyPasswordHash
(
"file"
,
password
);
return
SHA256
.
getKeyPasswordHash
(
"file"
,
password
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/CompressTool.java
浏览文件 @
8970b560
...
...
@@ -262,7 +262,7 @@ public class CompressTool {
}
}
private
Compressor
getCompressor
(
int
algorithm
)
{
private
static
Compressor
getCompressor
(
int
algorithm
)
{
switch
(
algorithm
)
{
case
Compressor
.
NO
:
return
new
CompressNo
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Console.java
浏览文件 @
8970b560
...
...
@@ -219,7 +219,7 @@ ShutdownHandler {
}
}
private
Image
loadImage
(
String
name
)
{
private
static
Image
loadImage
(
String
name
)
{
try
{
byte
[]
imageData
=
Utils
.
getResource
(
name
);
if
(
imageData
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/ConvertTraceFile.java
浏览文件 @
8970b560
...
...
@@ -199,11 +199,11 @@ public class ConvertTraceFile extends Tool {
scriptWriter
.
close
();
}
private
String
removeNewlines
(
String
s
)
{
private
static
String
removeNewlines
(
String
s
)
{
return
s
==
null
?
s
:
s
.
replace
(
'\r'
,
' '
).
replace
(
'\n'
,
' '
);
}
private
String
padNumberLeft
(
long
number
,
int
digits
)
{
private
static
String
padNumberLeft
(
long
number
,
int
digits
)
{
return
StringUtils
.
pad
(
String
.
valueOf
(
number
),
digits
,
" "
,
false
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/CreateCluster.java
浏览文件 @
8970b560
...
...
@@ -92,7 +92,7 @@ public class CreateCluster extends Tool {
* @throws SQLException
*/
public
void
execute
(
String
urlSource
,
String
urlTarget
,
String
user
,
String
password
,
String
serverList
)
throws
SQLException
{
new
CreateCluster
().
process
(
urlSource
,
urlTarget
,
user
,
password
,
serverList
);
process
(
urlSource
,
urlTarget
,
user
,
password
,
serverList
);
}
private
void
process
(
String
urlSource
,
String
urlTarget
,
String
user
,
String
password
,
String
serverList
)
throws
SQLException
{
...
...
@@ -139,7 +139,7 @@ public class CreateCluster extends Tool {
OutputStream
scriptOut
=
null
;
try
{
scriptOut
=
IOUtils
.
openFileOutputStream
(
scriptFile
,
false
);
s
cript
.
process
(
connSource
,
scriptOut
);
S
cript
.
process
(
connSource
,
scriptOut
);
}
finally
{
IOUtils
.
closeSilently
(
scriptOut
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Csv.java
浏览文件 @
8970b560
...
...
@@ -367,7 +367,7 @@ public class Csv implements SimpleRowSource {
list
.
toArray
(
columnNames
);
}
private
boolean
isSimpleColumnName
(
String
columnName
)
{
private
static
boolean
isSimpleColumnName
(
String
columnName
)
{
for
(
int
i
=
0
,
length
=
columnName
.
length
();
i
<
length
;
i
++)
{
char
ch
=
columnName
.
charAt
(
i
);
if
(
i
==
0
)
{
...
...
@@ -589,7 +589,7 @@ public class Csv implements SimpleRowSource {
return
row
;
}
private
SQLException
convertException
(
String
message
,
Exception
e
)
{
private
static
SQLException
convertException
(
String
message
,
Exception
e
)
{
return
DbException
.
get
(
ErrorCode
.
IO_EXCEPTION_1
,
e
,
message
).
getSQLException
();
}
...
...
@@ -819,7 +819,7 @@ public class Csv implements SimpleRowSource {
return
charset
;
}
private
boolean
isParam
(
String
key
,
String
...
values
)
{
private
static
boolean
isParam
(
String
key
,
String
...
values
)
{
for
(
String
v
:
values
)
{
if
(
key
.
equalsIgnoreCase
(
v
))
{
return
true
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/DeleteDbFiles.java
浏览文件 @
8970b560
...
...
@@ -89,16 +89,15 @@ public class DeleteDbFiles extends Tool {
if
(
files
.
size
()
==
0
&&
!
quiet
)
{
printNoDatabaseFilesFound
(
dir
,
db
);
}
DeleteDbFiles
delete
=
new
DeleteDbFiles
();
for
(
String
fileName
:
files
)
{
delete
.
process
(
fileName
,
quiet
);
process
(
fileName
,
quiet
);
if
(!
quiet
)
{
out
.
println
(
"Processed: "
+
fileName
);
}
}
}
private
void
process
(
String
fileName
,
boolean
quiet
)
{
private
static
void
process
(
String
fileName
,
boolean
quiet
)
{
if
(
IOUtils
.
isDirectory
(
fileName
))
{
// only delete empty directories
IOUtils
.
tryDelete
(
fileName
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/MultiDimension.java
浏览文件 @
8970b560
...
...
@@ -71,7 +71,7 @@ public class MultiDimension implements Comparator<long[]> {
return
(
int
)
((
1L
<<
bitsPerValue
)
-
1
);
}
private
int
getBitsPerValue
(
int
dimensions
)
{
private
static
int
getBitsPerValue
(
int
dimensions
)
{
return
Math
.
min
(
31
,
64
/
dimensions
);
}
...
...
@@ -224,7 +224,7 @@ public class MultiDimension implements Comparator<long[]> {
return
ranges
;
}
private
int
getSize
(
int
[]
min
,
int
[]
max
,
int
len
)
{
private
static
int
getSize
(
int
[]
min
,
int
[]
max
,
int
len
)
{
int
size
=
1
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
diff
=
max
[
i
]
-
min
[
i
];
...
...
@@ -306,11 +306,11 @@ public class MultiDimension implements Comparator<long[]> {
}
}
private
int
roundUp
(
int
x
,
int
blockSizePowerOf2
)
{
private
static
int
roundUp
(
int
x
,
int
blockSizePowerOf2
)
{
return
(
x
+
blockSizePowerOf2
-
1
)
&
(-
blockSizePowerOf2
);
}
private
int
findMiddle
(
int
a
,
int
b
)
{
private
static
int
findMiddle
(
int
a
,
int
b
)
{
int
diff
=
b
-
a
-
1
;
if
(
diff
==
0
)
{
return
a
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
8970b560
...
...
@@ -463,7 +463,7 @@ public class Recover extends Tool implements DataHandler {
}
}
private
String
getPageType
(
int
type
)
{
private
static
String
getPageType
(
int
type
)
{
switch
(
type
)
{
case
0
:
return
"free"
;
...
...
@@ -1054,10 +1054,9 @@ public class Recover extends Tool implements DataHandler {
// TODO doesn't work for all cases ("" inside user name)
userName
=
userName
.
substring
(
1
,
userName
.
length
()
-
1
);
}
SHA256
sha
=
new
SHA256
();
byte
[]
userPasswordHash
=
sha
.
getKeyPasswordHash
(
userName
,
""
.
toCharArray
());
byte
[]
userPasswordHash
=
SHA256
.
getKeyPasswordHash
(
userName
,
""
.
toCharArray
());
byte
[]
salt
=
MathUtils
.
secureRandomBytes
(
Constants
.
SALT_LEN
);
byte
[]
passwordHash
=
sha
.
getHashWithSalt
(
userPasswordHash
,
salt
);
byte
[]
passwordHash
=
SHA256
.
getHashWithSalt
(
userPasswordHash
,
salt
);
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
"SALT '"
).
append
(
StringUtils
.
convertBytesToString
(
salt
)).
...
...
@@ -1228,7 +1227,7 @@ public class Recover extends Tool implements DataHandler {
}
}
private
String
extractTableOrViewName
(
String
sql
)
{
private
static
String
extractTableOrViewName
(
String
sql
)
{
int
indexTable
=
sql
.
indexOf
(
" TABLE "
);
int
indexView
=
sql
.
indexOf
(
" VIEW "
);
if
(
indexTable
>
0
&&
indexView
>
0
)
{
...
...
@@ -1263,7 +1262,7 @@ public class Recover extends Tool implements DataHandler {
}
private
void
closeSilently
(
FileStore
fileStore
)
{
private
static
void
closeSilently
(
FileStore
fileStore
)
{
if
(
fileStore
!=
null
)
{
fileStore
.
closeSilently
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Restore.java
浏览文件 @
8970b560
...
...
@@ -68,7 +68,7 @@ public class Restore extends Tool {
throwUnsupportedOption
(
arg
);
}
}
process
(
zipFileName
,
dir
,
db
);
execute
(
zipFileName
,
dir
,
db
,
false
);
}
private
static
String
getOriginalDbName
(
String
fileName
,
String
db
)
throws
IOException
{
...
...
@@ -121,19 +121,6 @@ public class Restore extends Tool {
* @throws SQLException
*/
public
static
void
execute
(
String
zipFileName
,
String
directory
,
String
db
,
boolean
quiet
)
throws
SQLException
{
new
Restore
().
process
(
zipFileName
,
directory
,
db
);
}
/**
* Restores database files.
*
* @param zipFileName the name of the backup file
* @param directory the directory name
* @param db the database name (null for all databases)
* @param quiet don't print progress information
* @throws SQLException
*/
private
void
process
(
String
zipFileName
,
String
directory
,
String
db
)
throws
SQLException
{
InputStream
in
=
null
;
try
{
if
(!
IOUtils
.
exists
(
zipFileName
))
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
8970b560
...
...
@@ -152,10 +152,6 @@ public class RunScript extends Tool {
* @return the last result set
*/
public
static
ResultSet
execute
(
Connection
conn
,
Reader
reader
)
throws
SQLException
{
return
new
RunScript
().
process
(
conn
,
reader
);
}
private
ResultSet
process
(
Connection
conn
,
Reader
reader
)
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
=
null
;
ScriptReader
r
=
new
ScriptReader
(
reader
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Script.java
浏览文件 @
8970b560
...
...
@@ -97,11 +97,11 @@ public class Script extends Tool {
if
(
options1
!=
null
)
{
processScript
(
url
,
user
,
password
,
file
,
options1
,
options2
);
}
else
{
process
(
url
,
user
,
password
,
file
);
execute
(
url
,
user
,
password
,
file
);
}
}
private
void
processScript
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
options1
,
String
options2
)
throws
SQLException
{
private
static
void
processScript
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
options1
,
String
options2
)
throws
SQLException
{
Connection
conn
=
null
;
Statement
stat
=
null
;
try
{
...
...
@@ -125,70 +125,48 @@ public class Script extends Tool {
* @param fileName the script file
*/
public
static
void
execute
(
String
url
,
String
user
,
String
password
,
String
fileName
)
throws
SQLException
{
new
Script
().
process
(
url
,
user
,
password
,
fileName
);
}
/**
* Backs up a database to a stream. The stream is not closed.
*
* @param url the database URL
* @param user the user name
* @param password the password
* @param out the output stream
*/
public
static
void
execute
(
String
url
,
String
user
,
String
password
,
OutputStream
out
)
throws
SQLException
{
new
Script
().
process
(
url
,
user
,
password
,
out
);
}
/**
* Backs up a database to a SQL script file.
*
* @param url the database URL
* @param user the user name
* @param password the password
* @param fileName the script file
*/
void
process
(
String
url
,
String
user
,
String
password
,
String
fileName
)
throws
SQLException
{
OutputStream
o
=
null
;
try
{
o
=
IOUtils
.
openFileOutputStream
(
fileName
,
false
);
process
(
url
,
user
,
password
,
o
);
execute
(
url
,
user
,
password
,
o
);
}
finally
{
IOUtils
.
closeSilently
(
o
);
}
}
/**
* Backs up a database to a stream. The stream is not closed.
*
* @param url the database URL
* @param user the user name
* @param password the password
* @param o the output stream
* @param o
ut
the output stream
*/
void
process
(
String
url
,
String
user
,
String
password
,
OutputStream
o
)
throws
SQLException
{
public
static
void
execute
(
String
url
,
String
user
,
String
password
,
OutputStream
out
)
throws
SQLException
{
Connection
conn
=
null
;
try
{
org
.
h2
.
Driver
.
load
();
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
process
(
conn
,
o
);
process
(
conn
,
o
ut
);
}
finally
{
JdbcUtils
.
closeSilently
(
conn
);
}
}
/**
* Backs up a database to a stream. The stream is not closed.
* The connection is not closed.
*
* @param conn the connection
* @param o the output stream
* @param o
ut
the output stream
*/
void
process
(
Connection
conn
,
OutputStream
o
)
throws
SQLException
{
static
void
process
(
Connection
conn
,
OutputStream
out
)
throws
SQLException
{
Statement
stat
=
null
;
try
{
stat
=
conn
.
createStatement
();
PrintWriter
writer
=
new
PrintWriter
(
IOUtils
.
getBufferedWriter
(
o
));
PrintWriter
writer
=
new
PrintWriter
(
IOUtils
.
getBufferedWriter
(
o
ut
));
ResultSet
rs
=
stat
.
executeQuery
(
"SCRIPT"
);
while
(
rs
.
next
())
{
String
s
=
rs
.
getString
(
1
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Shell.java
浏览文件 @
8970b560
...
...
@@ -500,7 +500,6 @@ public class Shell extends Tool implements Runnable {
int
len
=
meta
.
getColumnCount
();
String
[]
columns
=
new
String
[
len
];
int
[]
columnSizes
=
new
int
[
len
];
int
total
=
0
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
String
s
=
meta
.
getColumnLabel
(
i
+
1
);
int
l
=
s
.
length
();
...
...
@@ -514,7 +513,6 @@ public class Shell extends Tool implements Runnable {
columns
[
i
]
=
s
;
columnSizes
[
i
]
=
l
;
longest
=
Math
.
max
(
longest
,
l
);
total
+=
l
;
}
StringBuilder
buff
=
new
StringBuilder
();
if
(!
asList
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/TriggerAdapter.java
浏览文件 @
8970b560
...
...
@@ -122,7 +122,7 @@ public abstract class TriggerAdapter implements Trigger {
*/
public
abstract
void
fire
(
Connection
conn
,
ResultSet
oldRow
,
ResultSet
newRow
)
throws
SQLException
;
private
SimpleResultSet
wrap
(
SimpleResultSet
rs
,
TriggerRowSource
source
,
Object
[]
row
)
throws
SQLException
{
private
static
SimpleResultSet
wrap
(
SimpleResultSet
rs
,
TriggerRowSource
source
,
Object
[]
row
)
throws
SQLException
{
if
(
row
==
null
)
{
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/SourceCompiler.java
浏览文件 @
8970b560
...
...
@@ -215,7 +215,7 @@ public class SourceCompiler {
}
}
private
void
copyInThread
(
final
InputStream
in
,
final
OutputStream
out
)
{
private
static
void
copyInThread
(
final
InputStream
in
,
final
OutputStream
out
)
{
new
Task
()
{
public
void
call
()
throws
IOException
{
while
(
true
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/Value.java
浏览文件 @
8970b560
...
...
@@ -910,28 +910,28 @@ public abstract class Value {
return
this
;
}
private
byte
convertToByte
(
long
x
)
{
private
static
byte
convertToByte
(
long
x
)
{
if
(
x
>
Byte
.
MAX_VALUE
||
x
<
Byte
.
MIN_VALUE
)
{
throw
DbException
.
get
(
ErrorCode
.
NUMERIC_VALUE_OUT_OF_RANGE
);
}
return
(
byte
)
x
;
}
private
short
convertToShort
(
long
x
)
{
private
s
tatic
s
hort
convertToShort
(
long
x
)
{
if
(
x
>
Short
.
MAX_VALUE
||
x
<
Short
.
MIN_VALUE
)
{
throw
DbException
.
get
(
ErrorCode
.
NUMERIC_VALUE_OUT_OF_RANGE
);
}
return
(
short
)
x
;
}
private
int
convertToInt
(
long
x
)
{
private
static
int
convertToInt
(
long
x
)
{
if
(
x
>
Integer
.
MAX_VALUE
||
x
<
Integer
.
MIN_VALUE
)
{
throw
DbException
.
get
(
ErrorCode
.
NUMERIC_VALUE_OUT_OF_RANGE
);
}
return
(
int
)
x
;
}
private
long
convertToLong
(
double
x
)
{
private
static
long
convertToLong
(
double
x
)
{
if
(
x
>
Long
.
MAX_VALUE
||
x
<
Long
.
MIN_VALUE
)
{
// TODO document that +Infinity, -Infinity throw an exception and NaN returns 0
throw
DbException
.
get
(
ErrorCode
.
NUMERIC_VALUE_OUT_OF_RANGE
);
...
...
@@ -939,7 +939,7 @@ public abstract class Value {
return
Math
.
round
(
x
);
}
private
long
convertToLong
(
BigDecimal
x
)
{
private
static
long
convertToLong
(
BigDecimal
x
)
{
if
(
x
.
compareTo
(
MAX_LONG_DECIMAL
)
>
0
||
x
.
compareTo
(
Value
.
MIN_LONG_DECIMAL
)
<
0
)
{
throw
DbException
.
get
(
ErrorCode
.
NUMERIC_VALUE_OUT_OF_RANGE
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueByte.java
浏览文件 @
8970b560
...
...
@@ -39,7 +39,7 @@ public class ValueByte extends Value {
return
checkRange
(
value
+
other
.
value
);
}
private
ValueByte
checkRange
(
int
x
)
{
private
static
ValueByte
checkRange
(
int
x
)
{
if
(
x
<
Byte
.
MIN_VALUE
||
x
>
Byte
.
MAX_VALUE
)
{
throw
DbException
.
get
(
ErrorCode
.
OVERFLOW_FOR_TYPE_1
,
DataType
.
getDataType
(
Value
.
BYTE
).
name
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueInt.java
浏览文件 @
8970b560
...
...
@@ -69,7 +69,7 @@ public class ValueInt extends Value {
return
checkRange
((
long
)
value
+
(
long
)
other
.
value
);
}
private
ValueInt
checkRange
(
long
x
)
{
private
static
ValueInt
checkRange
(
long
x
)
{
if
(
x
<
Integer
.
MIN_VALUE
||
x
>
Integer
.
MAX_VALUE
)
{
throw
DbException
.
get
(
ErrorCode
.
OVERFLOW_FOR_TYPE_1
,
DataType
.
getDataType
(
Value
.
INT
).
name
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
8970b560
...
...
@@ -239,7 +239,7 @@ public class ValueLob extends Value {
return
name
;
}
private
int
getNewObjectId
(
DataHandler
h
)
{
private
static
int
getNewObjectId
(
DataHandler
h
)
{
String
path
=
h
.
getDatabasePath
();
if
((
path
!=
null
)
&&
(
path
.
length
()
==
0
))
{
path
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
),
SysProperties
.
PREFIX_TEMP_FILE
).
getAbsolutePath
();
...
...
@@ -307,7 +307,7 @@ public class ValueLob extends Value {
dirCounter
=
0
;
}
private
void
invalidateFileList
(
DataHandler
h
,
String
dir
)
{
private
static
void
invalidateFileList
(
DataHandler
h
,
String
dir
)
{
SmallLRUCache
<
String
,
String
[]>
cache
=
h
.
getLobFileListCache
();
if
(
cache
!=
null
)
{
synchronized
(
cache
)
{
...
...
@@ -316,7 +316,7 @@ public class ValueLob extends Value {
}
}
private
String
[]
getFileList
(
DataHandler
h
,
String
dir
)
{
private
static
String
[]
getFileList
(
DataHandler
h
,
String
dir
)
{
SmallLRUCache
<
String
,
String
[]>
cache
=
h
.
getLobFileListCache
();
String
[]
list
;
if
(
cache
==
null
)
{
...
...
@@ -756,7 +756,7 @@ public class ValueLob extends Value {
}
}
private
void
copyFileTo
(
DataHandler
h
,
String
sourceFileName
,
String
targetFileName
)
{
private
static
void
copyFileTo
(
DataHandler
h
,
String
sourceFileName
,
String
targetFileName
)
{
synchronized
(
h
.
getLobSyncObject
())
{
FileSystem
.
getInstance
(
sourceFileName
).
copy
(
sourceFileName
,
targetFileName
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLong.java
浏览文件 @
8970b560
...
...
@@ -84,7 +84,7 @@ public class ValueLong extends Value {
return
ValueLong
.
get
(-
value
);
}
private
DbException
getOverflow
()
{
private
static
DbException
getOverflow
()
{
return
DbException
.
get
(
ErrorCode
.
OVERFLOW_FOR_TYPE_1
,
DataType
.
getDataType
(
Value
.
LONG
).
name
);
}
...
...
@@ -102,7 +102,7 @@ public class ValueLong extends Value {
return
add
(
other
.
negate
());
}
private
boolean
isInteger
(
long
a
)
{
private
static
boolean
isInteger
(
long
a
)
{
return
a
>=
Integer
.
MIN_VALUE
&&
a
<=
Integer
.
MAX_VALUE
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueShort.java
浏览文件 @
8970b560
...
...
@@ -39,7 +39,7 @@ public class ValueShort extends Value {
return
checkRange
(
value
+
other
.
value
);
}
private
ValueShort
checkRange
(
int
x
)
{
private
static
ValueShort
checkRange
(
int
x
)
{
if
(
x
<
Short
.
MIN_VALUE
||
x
>
Short
.
MAX_VALUE
)
{
throw
DbException
.
get
(
ErrorCode
.
OVERFLOW_FOR_TYPE_1
,
DataType
.
getDataType
(
Value
.
SHORT
).
name
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueUuid.java
浏览文件 @
8970b560
...
...
@@ -123,7 +123,7 @@ public class ValueUuid extends Value {
return
PRECISION
;
}
private
void
appendHex
(
StringBuilder
buff
,
long
x
,
int
bytes
)
{
private
static
void
appendHex
(
StringBuilder
buff
,
long
x
,
int
bytes
)
{
for
(
int
i
=
bytes
*
8
-
4
;
i
>=
0
;
i
-=
8
)
{
buff
.
append
(
Integer
.
toHexString
((
int
)
(
x
>>
i
)
&
0xf
)).
append
(
Integer
.
toHexString
((
int
)
(
x
>>
(
i
-
4
))
&
0xf
));
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/server/TestWeb.java
浏览文件 @
8970b560
...
...
@@ -197,9 +197,8 @@ public class TestWeb extends TestBase {
result
=
client
.
get
(
url
,
"tables.do"
);
result
=
client
.
get
(
url
,
"query.jsp"
);
result
=
client
.
get
(
url
,
"query.do?sql=select * from test"
);
result
=
client
.
get
(
url
,
"query.do?sql=drop table test if exists"
);
result
=
client
.
get
(
url
,
"query.do?sql=select * from test"
);
assertContains
(
result
,
"Hello"
);
result
=
client
.
get
(
url
,
"query.do?sql=select * from test"
);
result
=
client
.
get
(
url
,
"query.do?sql=@META select * from test"
);
assertContains
(
result
,
"typeName"
);
result
=
client
.
get
(
url
,
"query.do?sql=delete from test"
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论