Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
87b97ef0
提交
87b97ef0
authored
13 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split long lines.
上级
ced54a0a
显示空白字符变更
内嵌
并排
正在显示
29 个修改的文件
包含
250 行增加
和
87 行删除
+250
-87
Schema.java
h2/src/main/org/h2/schema/Schema.java
+5
-2
AES.java
h2/src/main/org/h2/security/AES.java
+16
-8
CipherFactory.java
h2/src/main/org/h2/security/CipherFactory.java
+54
-2
Fog.java
h2/src/main/org/h2/security/Fog.java
+16
-8
PgServer.java
h2/src/main/org/h2/server/pg/PgServer.java
+2
-1
WebApp.java
h2/src/main/org/h2/server/web/WebApp.java
+29
-11
WebServer.java
h2/src/main/org/h2/server/web/WebServer.java
+4
-3
LobStorage.java
h2/src/main/org/h2/store/LobStorage.java
+12
-6
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+3
-1
FileObjectMemoryData.java
h2/src/main/org/h2/store/fs/FileObjectMemoryData.java
+2
-1
RangeTable.java
h2/src/main/org/h2/table/RangeTable.java
+3
-1
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+9
-3
TableLinkConnection.java
h2/src/main/org/h2/table/TableLinkConnection.java
+6
-2
TableView.java
h2/src/main/org/h2/table/TableView.java
+2
-1
ChangeFileEncryption.java
h2/src/main/org/h2/tools/ChangeFileEncryption.java
+4
-2
ConvertTraceFile.java
h2/src/main/org/h2/tools/ConvertTraceFile.java
+6
-3
CreateCluster.java
h2/src/main/org/h2/tools/CreateCluster.java
+7
-3
Recover.java
h2/src/main/org/h2/tools/Recover.java
+2
-1
RunScript.java
h2/src/main/org/h2/tools/RunScript.java
+11
-5
Script.java
h2/src/main/org/h2/tools/Script.java
+2
-1
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+3
-1
IOUtils.java
h2/src/main/org/h2/util/IOUtils.java
+3
-1
Utils.java
h2/src/main/org/h2/util/Utils.java
+8
-2
DataType.java
h2/src/main/org/h2/value/DataType.java
+19
-9
Value.java
h2/src/main/org/h2/value/Value.java
+8
-2
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+4
-2
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+2
-1
FileFunctions.java
h2/src/test/org/h2/samples/FileFunctions.java
+6
-3
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-1
没有找到文件。
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
87b97ef0
...
...
@@ -558,10 +558,13 @@ public class Schema extends DbObjectBase {
* @param force create the object even if the database can not be accessed
* @return the {@link TableLink} object
*/
public
TableLink
createTableLink
(
int
id
,
String
tableName
,
String
driver
,
String
url
,
String
user
,
String
password
,
public
TableLink
createTableLink
(
int
id
,
String
tableName
,
String
driver
,
String
url
,
String
user
,
String
password
,
String
originalSchema
,
String
originalTable
,
boolean
emitUpdates
,
boolean
force
)
{
synchronized
(
database
)
{
return
new
TableLink
(
this
,
id
,
tableName
,
driver
,
url
,
user
,
password
,
originalSchema
,
originalTable
,
emitUpdates
,
force
);
return
new
TableLink
(
this
,
id
,
tableName
,
driver
,
url
,
user
,
password
,
originalSchema
,
originalTable
,
emitUpdates
,
force
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/security/AES.java
浏览文件 @
87b97ef0
...
...
@@ -189,10 +189,14 @@ public class AES implements BlockCipher {
x1
=
((
FS
[(
y1
>>
24
)
&
255
]
<<
24
)
|
(
FS
[(
y2
>>
16
)
&
255
]
<<
16
)
|
(
FS
[(
y3
>>
8
)
&
255
]
<<
8
)
|
FS
[
y0
&
255
])
^
k
[
41
];
x2
=
((
FS
[(
y2
>>
24
)
&
255
]
<<
24
)
|
(
FS
[(
y3
>>
16
)
&
255
]
<<
16
)
|
(
FS
[(
y0
>>
8
)
&
255
]
<<
8
)
|
FS
[
y1
&
255
])
^
k
[
42
];
x3
=
((
FS
[(
y3
>>
24
)
&
255
]
<<
24
)
|
(
FS
[(
y0
>>
16
)
&
255
]
<<
16
)
|
(
FS
[(
y1
>>
8
)
&
255
]
<<
8
)
|
FS
[
y2
&
255
])
^
k
[
43
];
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
}
private
void
decryptBlock
(
byte
[]
in
,
byte
[]
out
,
int
off
)
{
...
...
@@ -241,10 +245,14 @@ public class AES implements BlockCipher {
x1
=
((
RS
[(
y1
>>
24
)
&
255
]
<<
24
)
|
(
RS
[(
y0
>>
16
)
&
255
]
<<
16
)
|
(
RS
[(
y3
>>
8
)
&
255
]
<<
8
)
|
RS
[
y2
&
255
])
^
k
[
41
];
x2
=
((
RS
[(
y2
>>
24
)
&
255
]
<<
24
)
|
(
RS
[(
y1
>>
16
)
&
255
]
<<
16
)
|
(
RS
[(
y0
>>
8
)
&
255
]
<<
8
)
|
RS
[
y3
&
255
])
^
k
[
42
];
x3
=
((
RS
[(
y3
>>
24
)
&
255
]
<<
24
)
|
(
RS
[(
y2
>>
16
)
&
255
]
<<
16
)
|
(
RS
[(
y1
>>
8
)
&
255
]
<<
8
)
|
RS
[
y0
&
255
])
^
k
[
43
];
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
}
public
int
getKeyLength
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/security/CipherFactory.java
浏览文件 @
87b97ef0
...
...
@@ -153,13 +153,65 @@ public class CipherFactory {
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
"RSA"
);
store
.
load
(
null
,
password
.
toCharArray
());
PKCS8EncodedKeySpec
keySpec
=
new
PKCS8EncodedKeySpec
(
StringUtils
.
convertHexToBytes
(
"30820277020100300d06092a864886f70d0101010500048202613082025d02010002818100dc0a13c602b7141110eade2f051b54777b060d0f74e6a110f9cce81159f271ebc88d8e8aa1f743b505fc2e7dfe38d33b8d3f64d1b363d1af4d877833897954cbaec2fa384c22a415498cf306bb07ac09b76b001cd68bf77ea0a628f5101959cf2993a9c23dbee79b19305977f8715ae78d023471194cc900b231eecb0aaea98d02030100010281810099aa4ff4d0a09a5af0bd953cb10c4d08c3d98df565664ac5582e494314d5c3c92dddedd5d316a32a206be4ec084616fe57be15e27cad111aa3c21fa79e32258c6ca8430afc69eddd52d3b751b37da6b6860910b94653192c0db1d02abcfd6ce14c01f238eec7c20bd3bb750940004bacba2880349a9494d10e139ecb2355d101024100ffdc3defd9c05a2d377ef6019fa62b3fbd5b0020a04cc8533bca730e1f6fcf5dfceea1b044fbe17d9eababfbc7d955edad6bc60f9be826ad2c22ba77d19a9f65024100dc28d43fdbbc93852cc3567093157702bc16f156f709fb7db0d9eec028f41fd0edcd17224c866e66be1744141fb724a10fd741c8a96afdd9141b36d67fff6309024077b1cddbde0f69604bdcfe33263fb36ddf24aa3b9922327915b890f8a36648295d0139ecdf68c245652c4489c6257b58744fbdd961834a4cab201801a3b1e52d024100b17142e8991d1b350a0802624759d48ae2b8071a158ff91fabeb6a8f7c328e762143dc726b8529f42b1fab6220d1c676fdc27ba5d44e847c72c52064afd351a902407c6e23fe35bcfcd1a662aa82a2aa725fcece311644d5b6e3894853fd4ce9fe78218c957b1ff03fc9e5ef8ffeb6bd58235f6a215c97d354fdace7e781e4a63e8b"
));
StringUtils
.
convertHexToBytes
(
"30820277020100300d06092a864886f70d010101"
+
"0500048202613082025d02010002818100dc0a13"
+
"c602b7141110eade2f051b54777b060d0f74e6a1"
+
"10f9cce81159f271ebc88d8e8aa1f743b505fc2e"
+
"7dfe38d33b8d3f64d1b363d1af4d877833897954"
+
"cbaec2fa384c22a415498cf306bb07ac09b76b00"
+
"1cd68bf77ea0a628f5101959cf2993a9c23dbee7"
+
"9b19305977f8715ae78d023471194cc900b231ee"
+
"cb0aaea98d02030100010281810099aa4ff4d0a0"
+
"9a5af0bd953cb10c4d08c3d98df565664ac5582e"
+
"494314d5c3c92dddedd5d316a32a206be4ec0846"
+
"16fe57be15e27cad111aa3c21fa79e32258c6ca8"
+
"430afc69eddd52d3b751b37da6b6860910b94653"
+
"192c0db1d02abcfd6ce14c01f238eec7c20bd3bb"
+
"750940004bacba2880349a9494d10e139ecb2355"
+
"d101024100ffdc3defd9c05a2d377ef6019fa62b"
+
"3fbd5b0020a04cc8533bca730e1f6fcf5dfceea1"
+
"b044fbe17d9eababfbc7d955edad6bc60f9be826"
+
"ad2c22ba77d19a9f65024100dc28d43fdbbc9385"
+
"2cc3567093157702bc16f156f709fb7db0d9eec0"
+
"28f41fd0edcd17224c866e66be1744141fb724a1"
+
"0fd741c8a96afdd9141b36d67fff6309024077b1"
+
"cddbde0f69604bdcfe33263fb36ddf24aa3b9922"
+
"327915b890f8a36648295d0139ecdf68c245652c"
+
"4489c6257b58744fbdd961834a4cab201801a3b1"
+
"e52d024100b17142e8991d1b350a0802624759d4"
+
"8ae2b8071a158ff91fabeb6a8f7c328e762143dc"
+
"726b8529f42b1fab6220d1c676fdc27ba5d44e84"
+
"7c72c52064afd351a902407c6e23fe35bcfcd1a6"
+
"62aa82a2aa725fcece311644d5b6e3894853fd4c"
+
"e9fe78218c957b1ff03fc9e5ef8ffeb6bd58235f"
+
"6a215c97d354fdace7e781e4a63e8b"
));
PrivateKey
privateKey
=
keyFactory
.
generatePrivate
(
keySpec
);
Certificate
[]
certs
=
{
CertificateFactory
.
getInstance
(
"X.509"
)
.
generateCertificate
(
new
ByteArrayInputStream
(
StringUtils
.
convertHexToBytes
(
"3082018b3081f502044295ce6b300d06092a864886f70d0101040500300d310b3009060355040313024832301e170d3035303532363133323630335a170d3337303933303036353734375a300d310b300906035504031302483230819f300d06092a864886f70d010101050003818d0030818902818100dc0a13c602b7141110eade2f051b54777b060d0f74e6a110f9cce81159f271ebc88d8e8aa1f743b505fc2e7dfe38d33b8d3f64d1b363d1af4d877833897954cbaec2fa384c22a415498cf306bb07ac09b76b001cd68bf77ea0a628f5101959cf2993a9c23dbee79b19305977f8715ae78d023471194cc900b231eecb0aaea98d0203010001300d06092a864886f70d01010405000381810083f4401a279453701bef9a7681a5b8b24f153f7d18c7c892133d97bd5f13736be7505290a445a7d5ceb75522403e5097515cd966ded6351ff60d5193de34cd36e5cb04d380398e66286f99923fd92296645fd4ada45844d194dfd815e6cd57f385c117be982809028bba1116c85740b3d27a55b1a0948bf291ddba44bed337b9"
))),
};
StringUtils
.
convertHexToBytes
(
"3082018b3081f502044295ce6b300d06092a8648"
+
"86f70d0101040500300d310b3009060355040313"
+
"024832301e170d3035303532363133323630335a"
+
"170d3337303933303036353734375a300d310b30"
+
"0906035504031302483230819f300d06092a8648"
+
"86f70d010101050003818d0030818902818100dc"
+
"0a13c602b7141110eade2f051b54777b060d0f74"
+
"e6a110f9cce81159f271ebc88d8e8aa1f743b505"
+
"fc2e7dfe38d33b8d3f64d1b363d1af4d87783389"
+
"7954cbaec2fa384c22a415498cf306bb07ac09b7"
+
"6b001cd68bf77ea0a628f5101959cf2993a9c23d"
+
"bee79b19305977f8715ae78d023471194cc900b2"
+
"31eecb0aaea98d0203010001300d06092a864886"
+
"f70d01010405000381810083f4401a279453701b"
+
"ef9a7681a5b8b24f153f7d18c7c892133d97bd5f"
+
"13736be7505290a445a7d5ceb75522403e509751"
+
"5cd966ded6351ff60d5193de34cd36e5cb04d380"
+
"398e66286f99923fd92296645fd4ada45844d194"
+
"dfd815e6cd57f385c117be982809028bba1116c8"
+
"5740b3d27a55b1a0948bf291ddba44bed337b9"
))),
};
store
.
setKeyEntry
(
"h2"
,
privateKey
,
password
.
toCharArray
(),
certs
);
// --- generated code end ---
return
store
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/security/Fog.java
浏览文件 @
87b97ef0
...
...
@@ -45,10 +45,14 @@ public class Fog implements BlockCipher {
x1
=
(
x1
<<
s
)
|
(
x1
>>>
(
32
-
s
));
x3
^=
k
;
x3
=
(
x3
<<
s
)
|
(
x3
>>>
(
32
-
s
));
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
}
private
void
decryptBlock
(
byte
[]
in
,
byte
[]
out
,
int
off
)
{
...
...
@@ -67,10 +71,14 @@ public class Fog implements BlockCipher {
x0
^=
k
;
x2
=
(
x2
<<
s
)
|
(
x2
>>>
(
32
-
s
));
x2
^=
k
;
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
}
public
int
getKeyLength
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/pg/PgServer.java
浏览文件 @
87b97ef0
...
...
@@ -289,7 +289,8 @@ public class PgServer implements Service {
}
return
""
;
}
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select column_name from information_schema.indexes where id=? and ordinal_position=?"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select column_name from information_schema.indexes where id=? and ordinal_position=?"
);
prep
.
setInt
(
1
,
indexId
);
prep
.
setInt
(
2
,
ordinalPosition
.
intValue
());
ResultSet
rs
=
prep
.
executeQuery
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebApp.java
浏览文件 @
87b97ef0
...
...
@@ -465,7 +465,8 @@ public class WebApp {
return
"query.jsp"
;
}
private
static
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 +510,8 @@ public class WebApp {
String
columns
;
}
private
static
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
{
...
...
@@ -846,7 +848,8 @@ public class WebApp {
long
time
=
System
.
currentTimeMillis
()
-
start
;
String
success
;
if
(
time
>
1000
)
{
success
=
"<a class=\"error\" href=\"#\" onclick=\"var x=document.getElementById('prof').style;x.display=x.display==''?'none':'';\">"
+
success
=
"<a class=\"error\" href=\"#\" "
+
"onclick=\"var x=document.getElementById('prof').style;x.display=x.display==''?'none':'';\">"
+
"${text.login.testSuccessful}</a>"
+
"<span style=\"display: none;\" id=\"prof\"><br />"
+
PageParser
.
escapeHtml
(
profOpen
)
+
...
...
@@ -1575,10 +1578,19 @@ public class WebApp {
append
(
"<img onclick=\"javascript:editRow("
).
append
(
rs
.
getRow
()).
append
(
",'${sessionId}', '${text.resultEdit.save}', '${text.resultEdit.cancel}'"
).
append
(
")\" width=16 height=16 src=\"ico_write.gif\" onmouseover = \"this.className ='icon_hover'\" onmouseout = \"this.className ='icon'\" class=\"icon\" alt=\"${text.resultEdit.edit}\" title=\"${text.resultEdit.edit}\" border=\"1\"/>"
).
append
(
")\" width=16 height=16 src=\"ico_write.gif\" "
+
"onmouseover = \"this.className ='icon_hover'\" "
+
"onmouseout = \"this.className ='icon'\" "
+
"class=\"icon\" alt=\"${text.resultEdit.edit}\" "
+
"title=\"${text.resultEdit.edit}\" border=\"1\"/>"
).
append
(
"<a href=\"editResult.do?op=2&row="
).
append
(
rs
.
getRow
()).
append
(
"&jsessionid=${sessionId}\" target=\"h2result\" ><img width=16 height=16 src=\"ico_remove.gif\" onmouseover = \"this.className ='icon_hover'\" onmouseout = \"this.className ='icon'\" class=\"icon\" alt=\"${text.resultEdit.delete}\" title=\"${text.resultEdit.delete}\" border=\"1\" /></a>"
).
append
(
"&jsessionid=${sessionId}\" target=\"h2result\" >"
+
"<img width=16 height=16 src=\"ico_remove.gif\" "
+
"onmouseover = \"this.className ='icon_hover'\" "
+
"onmouseout = \"this.className ='icon'\" "
+
"class=\"icon\" alt=\"${text.resultEdit.delete}\" "
+
"title=\"${text.resultEdit.delete}\" border=\"1\" /></a>"
).
append
(
"</td>"
);
}
for
(
int
i
=
0
;
i
<
columns
;
i
++)
{
...
...
@@ -1609,7 +1621,11 @@ public class WebApp {
if
(
edit
)
{
buff
.
append
(
"<tr><td>"
).
append
(
"<img onclick=\"javascript:editRow(-1, '${sessionId}', '${text.resultEdit.save}', '${text.resultEdit.cancel}'"
).
append
(
")\" width=16 height=16 src=\"ico_add.gif\" onmouseover = \"this.className ='icon_hover'\" onmouseout = \"this.className ='icon'\" class=\"icon\" alt=\"${text.resultEdit.add}\" title=\"${text.resultEdit.add}\" border=\"1\"/>"
).
append
(
")\" width=16 height=16 src=\"ico_add.gif\" "
+
"onmouseover = \"this.className ='icon_hover'\" "
+
"onmouseout = \"this.className ='icon'\" "
+
"class=\"icon\" alt=\"${text.resultEdit.add}\" "
+
"title=\"${text.resultEdit.add}\" border=\"1\"/>"
).
append
(
"</td>"
);
for
(
int
i
=
0
;
i
<
columns
;
i
++)
{
buff
.
append
(
"<td></td>"
);
...
...
@@ -1631,7 +1647,9 @@ public class WebApp {
time
=
System
.
currentTimeMillis
()
-
time
;
buff
.
append
(
time
).
append
(
" ms)"
);
if
(!
edit
&&
isUpdatable
&&
allowEdit
)
{
buff
.
append
(
"<br /><br /><form name=\"editResult\" method=\"post\" action=\"query.do?jsessionid=${sessionId}\" target=\"h2result\">"
+
buff
.
append
(
"<br /><br />"
+
"<form name=\"editResult\" method=\"post\" "
+
"action=\"query.do?jsessionid=${sessionId}\" target=\"h2result\">"
+
"<input type=\"submit\" class=\"button\" value=\"${text.resultEdit.editResult}\" />"
+
"<input type=\"hidden\" name=\"sql\" value=\"@edit "
).
append
(
PageParser
.
escapeHtmlData
(
sql
)).
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebServer.java
浏览文件 @
87b97ef0
...
...
@@ -77,12 +77,13 @@ public class WebServer implements Service {
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"
,
"Generic OneDollarDB|in.co.daffodil.db.jdbc.DaffodilDBDriver|jdbc:daffodilDB_embedded:school;path=C:/temp;create=true|sa"
,
"Generic SQLite|org.sqlite.JDBC|jdbc:sqlite:test|sa"
,
"Generic DB2|COM.ibm.db2.jdbc.net.DB2Driver|jdbc:db2://localhost/test|"
,
"Generic Oracle|oracle.jdbc.driver.OracleDriver|jdbc:oracle:thin:@localhost:1521:XE|sa"
,
"Generic MS SQL Server 2000|com.microsoft.jdbc.sqlserver.SQLServerDriver|jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sqlexpress|sa"
,
"Generic MS SQL Server 2005|com.microsoft.sqlserver.jdbc.SQLServerDriver|jdbc:sqlserver://localhost;DatabaseName=test|sa"
,
"Generic MS SQL Server 2000|com.microsoft.jdbc.sqlserver.SQLServerDriver|"
+
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sqlexpress|sa"
,
"Generic MS SQL Server 2005|com.microsoft.sqlserver.jdbc.SQLServerDriver|"
+
"jdbc:sqlserver://localhost;DatabaseName=test|sa"
,
"Generic PostgreSQL|org.postgresql.Driver|jdbc:postgresql:test|"
,
"Generic MySQL|com.mysql.jdbc.Driver|jdbc:mysql://localhost:3306/test|"
,
"Generic HSQLDB|org.hsqldb.jdbcDriver|jdbc:hsqldb:test;hsqldb.default_table_type=cached|sa"
,
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/LobStorage.java
浏览文件 @
87b97ef0
...
...
@@ -95,12 +95,18 @@ public class LobStorage {
Statement
stat
=
conn
.
createStatement
();
// stat.execute("SET UNDO_LOG 0");
// stat.execute("SET REDO_LOG_BINARY 0");
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS "
+
LOBS
+
"(ID BIGINT PRIMARY KEY, BYTE_COUNT BIGINT, TABLE INT) HIDDEN"
);
stat
.
execute
(
"CREATE INDEX IF NOT EXISTS INFORMATION_SCHEMA.INDEX_LOB_TABLE ON "
+
LOBS
+
"(TABLE)"
);
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS "
+
LOB_MAP
+
"(LOB BIGINT, SEQ INT, OFFSET BIGINT, HASH INT, BLOCK BIGINT, PRIMARY KEY(LOB, SEQ)) HIDDEN"
);
stat
.
execute
(
"ALTER TABLE "
+
LOB_MAP
+
" ADD IF NOT EXISTS OFFSET BIGINT BEFORE HASH"
);
stat
.
execute
(
"CREATE INDEX IF NOT EXISTS INFORMATION_SCHEMA.INDEX_LOB_MAP_DATA_LOB ON "
+
LOB_MAP
+
"(BLOCK, LOB)"
);
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS "
+
LOB_DATA
+
"(BLOCK BIGINT PRIMARY KEY, COMPRESSED INT, DATA BINARY) HIDDEN"
);
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS "
+
LOBS
+
"(ID BIGINT PRIMARY KEY, BYTE_COUNT BIGINT, TABLE INT) HIDDEN"
);
stat
.
execute
(
"CREATE INDEX IF NOT EXISTS "
+
"INFORMATION_SCHEMA.INDEX_LOB_TABLE ON "
+
LOBS
+
"(TABLE)"
);
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS "
+
LOB_MAP
+
"(LOB BIGINT, SEQ INT, OFFSET BIGINT, HASH INT, BLOCK BIGINT, PRIMARY KEY(LOB, SEQ)) HIDDEN"
);
stat
.
execute
(
"ALTER TABLE "
+
LOB_MAP
+
" ADD IF NOT EXISTS OFFSET BIGINT BEFORE HASH"
);
stat
.
execute
(
"CREATE INDEX IF NOT EXISTS "
+
"INFORMATION_SCHEMA.INDEX_LOB_MAP_DATA_LOB ON "
+
LOB_MAP
+
"(BLOCK, LOB)"
);
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS "
+
LOB_DATA
+
"(BLOCK BIGINT PRIMARY KEY, COMPRESSED INT, DATA BINARY) HIDDEN"
);
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"SELECT MAX(BLOCK) FROM "
+
LOB_DATA
);
rs
.
next
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
87b97ef0
...
...
@@ -1699,7 +1699,9 @@ public class PageStore implements CacheWriter {
int
key
=
index
.
getId
()
+
1
;
Row
row
=
metaIndex
.
getRow
(
session
,
key
);
if
(
row
.
getKey
()
!=
key
)
{
throw
DbException
.
get
(
ErrorCode
.
FILE_CORRUPTED_1
,
"key: "
+
key
+
" index: "
+
index
+
" table: "
+
index
.
getTable
()
+
" row: "
+
row
);
throw
DbException
.
get
(
ErrorCode
.
FILE_CORRUPTED_1
,
"key: "
+
key
+
" index: "
+
index
+
" table: "
+
index
.
getTable
()
+
" row: "
+
row
);
}
metaIndex
.
remove
(
session
,
row
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileObjectMemoryData.java
浏览文件 @
87b97ef0
...
...
@@ -27,7 +27,8 @@ class FileObjectMemoryData {
private
static
final
byte
[]
BUFFER
=
new
byte
[
BLOCK_SIZE
*
2
];
private
static
final
byte
[]
COMPRESSED_EMPTY_BLOCK
;
private
static
final
Cache
<
CompressItem
,
CompressItem
>
COMPRESS_LATER
=
new
Cache
<
CompressItem
,
CompressItem
>(
CACHE_SIZE
);
private
static
final
Cache
<
CompressItem
,
CompressItem
>
COMPRESS_LATER
=
new
Cache
<
CompressItem
,
CompressItem
>(
CACHE_SIZE
);
private
String
name
;
private
final
boolean
compress
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/RangeTable.java
浏览文件 @
87b97ef0
...
...
@@ -75,7 +75,9 @@ public class RangeTable extends Table {
return
false
;
}
public
Index
addIndex
(
Session
session
,
String
indexName
,
int
indexId
,
IndexColumn
[]
cols
,
IndexType
indexType
,
boolean
create
,
String
indexComment
)
{
public
Index
addIndex
(
Session
session
,
String
indexName
,
int
indexId
,
IndexColumn
[]
cols
,
IndexType
indexType
,
boolean
create
,
String
indexComment
)
{
throw
DbException
.
getUnsupportedException
(
"SYSTEM_RANGE"
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
87b97ef0
...
...
@@ -89,7 +89,10 @@ public class RegularTable extends TableBase {
}
}
if
(
data
.
persistData
&&
database
.
isPersistent
())
{
mainIndex
=
new
PageDataIndex
(
this
,
data
.
id
,
IndexColumn
.
wrap
(
getColumns
()),
IndexType
.
createScan
(
data
.
persistData
),
data
.
create
,
data
.
session
);
mainIndex
=
new
PageDataIndex
(
this
,
data
.
id
,
IndexColumn
.
wrap
(
getColumns
()),
IndexType
.
createScan
(
data
.
persistData
),
data
.
create
,
data
.
session
);
scanIndex
=
mainIndex
;
}
else
{
scanIndex
=
new
ScanIndex
(
this
,
data
.
id
,
IndexColumn
.
wrap
(
getColumns
()),
IndexType
.
createScan
(
data
.
persistData
));
...
...
@@ -172,7 +175,9 @@ public class RegularTable extends TableBase {
if
(!(
index
instanceof
PageDelegateIndex
))
{
long
rc
=
index
.
getRowCount
(
session
);
if
(
rc
!=
rowCount
+
offset
)
{
DbException
.
throwInternalError
(
"rowCount expected "
+
(
rowCount
+
offset
)
+
" got "
+
rc
+
" "
+
getName
()
+
"."
+
index
.
getName
());
DbException
.
throwInternalError
(
"rowCount expected "
+
(
rowCount
+
offset
)
+
" got "
+
rc
+
" "
+
getName
()
+
"."
+
index
.
getName
());
}
}
}
...
...
@@ -600,7 +605,8 @@ public class RegularTable extends TableBase {
private
void
traceLock
(
Session
session
,
boolean
exclusive
,
String
s
)
{
if
(
traceLock
.
isDebugEnabled
())
{
traceLock
.
debug
(
"{0} {1} {2} {3}"
,
session
.
getId
(),
exclusive
?
"exclusive write lock"
:
"shared read lock"
,
s
,
getName
());
traceLock
.
debug
(
"{0} {1} {2} {3}"
,
session
.
getId
(),
exclusive
?
"exclusive write lock"
:
"shared read lock"
,
s
,
getName
());
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableLinkConnection.java
浏览文件 @
87b97ef0
...
...
@@ -40,7 +40,9 @@ public class TableLinkConnection {
*/
private
int
useCounter
;
private
TableLinkConnection
(
HashMap
<
TableLinkConnection
,
TableLinkConnection
>
map
,
String
driver
,
String
url
,
String
user
,
String
password
)
{
private
TableLinkConnection
(
HashMap
<
TableLinkConnection
,
TableLinkConnection
>
map
,
String
driver
,
String
url
,
String
user
,
String
password
)
{
this
.
map
=
map
;
this
.
driver
=
driver
;
this
.
url
=
url
;
...
...
@@ -60,7 +62,9 @@ public class TableLinkConnection {
* @param shareLinkedConnections if connections should be shared
* @return a connection
*/
public
static
TableLinkConnection
open
(
HashMap
<
TableLinkConnection
,
TableLinkConnection
>
map
,
String
driver
,
String
url
,
String
user
,
String
password
,
boolean
shareLinkedConnections
)
{
public
static
TableLinkConnection
open
(
HashMap
<
TableLinkConnection
,
TableLinkConnection
>
map
,
String
driver
,
String
url
,
String
user
,
String
password
,
boolean
shareLinkedConnections
)
{
TableLinkConnection
t
=
new
TableLinkConnection
(
map
,
driver
,
url
,
user
,
password
);
if
(!
shareLinkedConnections
)
{
t
.
open
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableView.java
浏览文件 @
87b97ef0
...
...
@@ -83,7 +83,8 @@ public class TableView extends Table {
}
}
private
void
init
(
String
querySQL
,
ArrayList
<
Parameter
>
params
,
String
[]
columnNames
,
Session
session
,
boolean
recursive
)
{
private
void
init
(
String
querySQL
,
ArrayList
<
Parameter
>
params
,
String
[]
columnNames
,
Session
session
,
boolean
recursive
)
{
this
.
querySQL
=
querySQL
;
this
.
columnNames
=
columnNames
;
this
.
recursive
=
recursive
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/ChangeFileEncryption.java
浏览文件 @
87b97ef0
...
...
@@ -121,7 +121,8 @@ public class ChangeFileEncryption extends Tool {
* @param quiet don't print progress information
* @throws SQLException
*/
public
static
void
execute
(
String
dir
,
String
db
,
String
cipher
,
char
[]
decryptPassword
,
char
[]
encryptPassword
,
boolean
quiet
)
throws
SQLException
{
public
static
void
execute
(
String
dir
,
String
db
,
String
cipher
,
char
[]
decryptPassword
,
char
[]
encryptPassword
,
boolean
quiet
)
throws
SQLException
{
try
{
new
ChangeFileEncryption
().
process
(
dir
,
db
,
cipher
,
decryptPassword
,
encryptPassword
,
quiet
);
}
catch
(
Exception
e
)
{
...
...
@@ -129,7 +130,8 @@ public class ChangeFileEncryption extends Tool {
}
}
private
void
process
(
String
dir
,
String
db
,
String
cipher
,
char
[]
decryptPassword
,
char
[]
encryptPassword
,
boolean
quiet
)
throws
SQLException
{
private
void
process
(
String
dir
,
String
db
,
String
cipher
,
char
[]
decryptPassword
,
char
[]
encryptPassword
,
boolean
quiet
)
throws
SQLException
{
dir
=
FileLister
.
getDir
(
dir
);
ChangeFileEncryption
change
=
new
ChangeFileEncryption
();
if
(
encryptPassword
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/ConvertTraceFile.java
浏览文件 @
87b97ef0
...
...
@@ -110,9 +110,12 @@ public class ConvertTraceFile extends Tool {
* @throws IOException
*/
private
void
convertFile
(
String
traceFileName
,
String
javaClassName
,
String
script
)
throws
IOException
{
LineNumberReader
reader
=
new
LineNumberReader
(
IOUtils
.
getBufferedReader
(
IOUtils
.
openFileInputStream
(
traceFileName
)));
PrintWriter
javaWriter
=
new
PrintWriter
(
IOUtils
.
getBufferedWriter
(
IOUtils
.
openFileOutputStream
(
javaClassName
+
".java"
,
false
)));
PrintWriter
scriptWriter
=
new
PrintWriter
(
IOUtils
.
getBufferedWriter
(
IOUtils
.
openFileOutputStream
(
script
,
false
)));
LineNumberReader
reader
=
new
LineNumberReader
(
IOUtils
.
getBufferedReader
(
IOUtils
.
openFileInputStream
(
traceFileName
)));
PrintWriter
javaWriter
=
new
PrintWriter
(
IOUtils
.
getBufferedWriter
(
IOUtils
.
openFileOutputStream
(
javaClassName
+
".java"
,
false
)));
PrintWriter
scriptWriter
=
new
PrintWriter
(
IOUtils
.
getBufferedWriter
(
IOUtils
.
openFileOutputStream
(
script
,
false
)));
javaWriter
.
println
(
"import java.io.*;"
);
javaWriter
.
println
(
"import java.sql.*;"
);
javaWriter
.
println
(
"import java.math.*;"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/CreateCluster.java
浏览文件 @
87b97ef0
...
...
@@ -91,11 +91,13 @@ public class CreateCluster extends Tool {
* @param serverList the server list
* @throws SQLException
*/
public
void
execute
(
String
urlSource
,
String
urlTarget
,
String
user
,
String
password
,
String
serverList
)
throws
SQLException
{
public
void
execute
(
String
urlSource
,
String
urlTarget
,
String
user
,
String
password
,
String
serverList
)
throws
SQLException
{
process
(
urlSource
,
urlTarget
,
user
,
password
,
serverList
);
}
private
void
process
(
String
urlSource
,
String
urlTarget
,
String
user
,
String
password
,
String
serverList
)
throws
SQLException
{
private
void
process
(
String
urlSource
,
String
urlTarget
,
String
user
,
String
password
,
String
serverList
)
throws
SQLException
{
Connection
connSource
=
null
,
connTarget
=
null
;
Statement
statSource
=
null
,
statTarget
=
null
;
String
scriptFile
=
"backup.sql"
;
...
...
@@ -106,7 +108,9 @@ public class CreateCluster extends Tool {
// or if it exists (an old cluster instance), it is deleted
boolean
exists
=
true
;
try
{
connTarget
=
DriverManager
.
getConnection
(
urlTarget
+
";IFEXISTS=TRUE;CLUSTER="
+
Constants
.
CLUSTERING_ENABLED
,
user
,
password
);
connTarget
=
DriverManager
.
getConnection
(
urlTarget
+
";IFEXISTS=TRUE;CLUSTER="
+
Constants
.
CLUSTERING_ENABLED
,
user
,
password
);
Statement
stat
=
connTarget
.
createStatement
();
stat
.
execute
(
"DROP ALL OBJECTS DELETE FILES"
);
stat
.
close
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
87b97ef0
...
...
@@ -575,7 +575,8 @@ public class Recover extends Tool implements DataHandler {
}
}
private
void
dumpPageLogStream
(
PrintWriter
writer
,
int
logKey
,
int
logFirstTrunkPage
,
int
logFirstDataPage
)
throws
IOException
{
private
void
dumpPageLogStream
(
PrintWriter
writer
,
int
logKey
,
int
logFirstTrunkPage
,
int
logFirstDataPage
)
throws
IOException
{
Data
s
=
Data
.
create
(
this
,
pageSize
);
DataReader
in
=
new
DataReader
(
new
PageInputStream
(
writer
,
this
,
store
,
logKey
,
logFirstTrunkPage
,
logFirstDataPage
,
pageSize
)
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
87b97ef0
...
...
@@ -172,7 +172,8 @@ public class RunScript extends Tool {
return
rs
;
}
private
void
process
(
Connection
conn
,
String
fileName
,
boolean
continueOnError
,
String
charsetName
)
throws
SQLException
,
IOException
{
private
void
process
(
Connection
conn
,
String
fileName
,
boolean
continueOnError
,
String
charsetName
)
throws
SQLException
,
IOException
{
InputStream
in
=
IOUtils
.
openFileInputStream
(
fileName
);
String
path
=
IOUtils
.
getParent
(
fileName
);
try
{
...
...
@@ -184,7 +185,8 @@ public class RunScript extends Tool {
}
}
private
void
process
(
Connection
conn
,
boolean
continueOnError
,
String
path
,
Reader
reader
,
String
charsetName
)
throws
SQLException
,
IOException
{
private
void
process
(
Connection
conn
,
boolean
continueOnError
,
String
path
,
Reader
reader
,
String
charsetName
)
throws
SQLException
,
IOException
{
Statement
stat
=
conn
.
createStatement
();
ScriptReader
r
=
new
ScriptReader
(
reader
);
while
(
true
)
{
...
...
@@ -256,7 +258,8 @@ public class RunScript extends Tool {
}
}
private
static
void
processRunscript
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
options
)
throws
SQLException
{
private
static
void
processRunscript
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
options
)
throws
SQLException
{
Connection
conn
=
null
;
Statement
stat
=
null
;
try
{
...
...
@@ -281,7 +284,8 @@ public class RunScript extends Tool {
* @param charsetName the character set name or null for UTF-8
* @param continueOnError if execution should be continued if an error occurs
*/
public
static
void
execute
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
charsetName
,
boolean
continueOnError
)
throws
SQLException
{
public
static
void
execute
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
charsetName
,
boolean
continueOnError
)
throws
SQLException
{
new
RunScript
().
process
(
url
,
user
,
password
,
fileName
,
charsetName
,
continueOnError
);
}
...
...
@@ -295,7 +299,9 @@ public class RunScript extends Tool {
* @param charsetName the character set name or null for UTF-8
* @param continueOnError if execution should be continued if an error occurs
*/
void
process
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
charsetName
,
boolean
continueOnError
)
throws
SQLException
{
void
process
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
charsetName
,
boolean
continueOnError
)
throws
SQLException
{
try
{
org
.
h2
.
Driver
.
load
();
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Script.java
浏览文件 @
87b97ef0
...
...
@@ -101,7 +101,8 @@ public class Script extends Tool {
}
}
private
static
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
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
87b97ef0
...
...
@@ -356,7 +356,9 @@ public class DateTimeUtils {
}
}
private
static
long
getTime
(
boolean
lenient
,
TimeZone
tz
,
int
year
,
int
month
,
int
day
,
int
hour
,
int
minute
,
int
second
,
boolean
setMillis
,
int
nano
)
{
private
static
long
getTime
(
boolean
lenient
,
TimeZone
tz
,
int
year
,
int
month
,
int
day
,
int
hour
,
int
minute
,
int
second
,
boolean
setMillis
,
int
nano
)
{
Calendar
c
;
if
(
tz
==
null
)
{
c
=
getCalendar
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/IOUtils.java
浏览文件 @
87b97ef0
...
...
@@ -481,7 +481,9 @@ public class IOUtils {
if
(
directory
.
isDirectory
())
{
return
;
}
throw
new
IOException
(
"Could not create directory, because a file with the same name already exists: "
+
directory
.
getAbsolutePath
());
throw
new
IOException
(
"Could not create directory, "
+
"because a file with the same name already exists: "
+
directory
.
getAbsolutePath
());
}
if
(
directory
.
mkdirs
())
{
return
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/Utils.java
浏览文件 @
87b97ef0
...
...
@@ -515,11 +515,17 @@ public class Utils {
* @param params the method parameters
* @return the return value from this call
*/
public
static
Object
callMethod
(
Object
instance
,
String
methodName
,
Object
...
params
)
throws
Exception
{
public
static
Object
callMethod
(
Object
instance
,
String
methodName
,
Object
...
params
)
throws
Exception
{
return
classMethodInternal
(
methodName
,
instance
.
getClass
(),
instance
,
params
);
}
private
static
Object
classMethodInternal
(
String
methodName
,
Class
<?>
clazz
,
Object
instance
,
Object
...
params
)
throws
Exception
{
private
static
Object
classMethodInternal
(
String
methodName
,
Class
<?>
clazz
,
Object
instance
,
Object
...
params
)
throws
Exception
{
Method
best
=
null
;
int
bestMatch
=
0
;
boolean
isStatic
=
instance
==
null
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/DataType.java
浏览文件 @
87b97ef0
...
...
@@ -241,44 +241,52 @@ public class DataType {
20
);
add
(
Value
.
INT
,
Types
.
INTEGER
,
"Int"
,
createDecimal
(
ValueInt
.
PRECISION
,
ValueInt
.
PRECISION
,
0
,
ValueInt
.
DISPLAY_SIZE
,
false
,
false
),
createDecimal
(
ValueInt
.
PRECISION
,
ValueInt
.
PRECISION
,
0
,
ValueInt
.
DISPLAY_SIZE
,
false
,
false
),
new
String
[]{
"INTEGER"
,
"INT"
,
"MEDIUMINT"
,
"INT4"
,
"SIGNED"
},
// in many cases the value is in the cache
20
);
add
(
Value
.
LONG
,
Types
.
BIGINT
,
"Long"
,
createDecimal
(
ValueLong
.
PRECISION
,
ValueLong
.
PRECISION
,
0
,
ValueLong
.
DISPLAY_SIZE
,
false
,
false
),
createDecimal
(
ValueLong
.
PRECISION
,
ValueLong
.
PRECISION
,
0
,
ValueLong
.
DISPLAY_SIZE
,
false
,
false
),
new
String
[]{
"BIGINT"
,
"INT8"
,
"LONG"
},
24
);
add
(
Value
.
LONG
,
Types
.
BIGINT
,
"Long"
,
createDecimal
(
ValueLong
.
PRECISION
,
ValueLong
.
PRECISION
,
0
,
ValueLong
.
DISPLAY_SIZE
,
false
,
true
),
createDecimal
(
ValueLong
.
PRECISION
,
ValueLong
.
PRECISION
,
0
,
ValueLong
.
DISPLAY_SIZE
,
false
,
true
),
new
String
[]{
"IDENTITY"
,
"SERIAL"
},
24
);
add
(
Value
.
DECIMAL
,
Types
.
DECIMAL
,
"BigDecimal"
,
createDecimal
(
Integer
.
MAX_VALUE
,
ValueDecimal
.
DEFAULT_PRECISION
,
ValueDecimal
.
DEFAULT_SCALE
,
ValueDecimal
.
DEFAULT_DISPLAY_SIZE
,
true
,
false
),
createDecimal
(
Integer
.
MAX_VALUE
,
ValueDecimal
.
DEFAULT_PRECISION
,
ValueDecimal
.
DEFAULT_SCALE
,
ValueDecimal
.
DEFAULT_DISPLAY_SIZE
,
true
,
false
),
new
String
[]{
"DECIMAL"
,
"DEC"
},
// 40 for ValueDecimal,
64
);
add
(
Value
.
DECIMAL
,
Types
.
NUMERIC
,
"BigDecimal"
,
createDecimal
(
Integer
.
MAX_VALUE
,
ValueDecimal
.
DEFAULT_PRECISION
,
ValueDecimal
.
DEFAULT_SCALE
,
ValueDecimal
.
DEFAULT_DISPLAY_SIZE
,
true
,
false
),
createDecimal
(
Integer
.
MAX_VALUE
,
ValueDecimal
.
DEFAULT_PRECISION
,
ValueDecimal
.
DEFAULT_SCALE
,
ValueDecimal
.
DEFAULT_DISPLAY_SIZE
,
true
,
false
),
new
String
[]{
"NUMERIC"
,
"NUMBER"
},
64
);
add
(
Value
.
FLOAT
,
Types
.
REAL
,
"Float"
,
createDecimal
(
ValueFloat
.
PRECISION
,
ValueFloat
.
PRECISION
,
0
,
ValueFloat
.
DISPLAY_SIZE
,
false
,
false
),
createDecimal
(
ValueFloat
.
PRECISION
,
ValueFloat
.
PRECISION
,
0
,
ValueFloat
.
DISPLAY_SIZE
,
false
,
false
),
new
String
[]
{
"REAL"
,
"FLOAT4"
},
24
);
add
(
Value
.
DOUBLE
,
Types
.
DOUBLE
,
"Double"
,
createDecimal
(
ValueDouble
.
PRECISION
,
ValueDouble
.
PRECISION
,
0
,
ValueDouble
.
DISPLAY_SIZE
,
false
,
false
),
createDecimal
(
ValueDouble
.
PRECISION
,
ValueDouble
.
PRECISION
,
0
,
ValueDouble
.
DISPLAY_SIZE
,
false
,
false
),
new
String
[]
{
"DOUBLE"
,
"DOUBLE PRECISION"
},
24
);
add
(
Value
.
DOUBLE
,
Types
.
FLOAT
,
"Double"
,
createDecimal
(
ValueDouble
.
PRECISION
,
ValueDouble
.
PRECISION
,
0
,
ValueDouble
.
DISPLAY_SIZE
,
false
,
false
),
createDecimal
(
ValueDouble
.
PRECISION
,
ValueDouble
.
PRECISION
,
0
,
ValueDouble
.
DISPLAY_SIZE
,
false
,
false
),
new
String
[]
{
"FLOAT"
,
"FLOAT8"
},
24
);
...
...
@@ -396,7 +404,9 @@ public class DataType {
}
}
private
static
DataType
createDecimal
(
int
maxPrecision
,
int
defaultPrecision
,
int
defaultScale
,
int
defaultDisplaySize
,
boolean
needsPrecisionAndScale
,
boolean
autoInc
)
{
private
static
DataType
createDecimal
(
int
maxPrecision
,
int
defaultPrecision
,
int
defaultScale
,
int
defaultDisplaySize
,
boolean
needsPrecisionAndScale
,
boolean
autoInc
)
{
DataType
dataType
=
new
DataType
();
dataType
.
maxPrecision
=
maxPrecision
;
dataType
.
defaultPrecision
=
defaultPrecision
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/Value.java
浏览文件 @
87b97ef0
...
...
@@ -789,9 +789,15 @@ public abstract class Value {
case
NULL:
return
ValueNull
.
INSTANCE
;
case
BOOLEAN:
{
if
(
s
.
equalsIgnoreCase
(
"true"
)
||
s
.
equalsIgnoreCase
(
"t"
)
||
s
.
equalsIgnoreCase
(
"yes"
)
||
s
.
equalsIgnoreCase
(
"y"
))
{
if
(
s
.
equalsIgnoreCase
(
"true"
)
||
s
.
equalsIgnoreCase
(
"t"
)
||
s
.
equalsIgnoreCase
(
"yes"
)
||
s
.
equalsIgnoreCase
(
"y"
))
{
return
ValueBoolean
.
get
(
true
);
}
else
if
(
s
.
equalsIgnoreCase
(
"false"
)
||
s
.
equalsIgnoreCase
(
"f"
)
||
s
.
equalsIgnoreCase
(
"no"
)
||
s
.
equalsIgnoreCase
(
"n"
))
{
}
else
if
(
s
.
equalsIgnoreCase
(
"false"
)
||
s
.
equalsIgnoreCase
(
"f"
)
||
s
.
equalsIgnoreCase
(
"no"
)
||
s
.
equalsIgnoreCase
(
"n"
))
{
return
ValueBoolean
.
get
(
false
);
}
else
{
// convert to a number, and if it is not 0 then it is true
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
87b97ef0
...
...
@@ -87,7 +87,8 @@ public class ValueLob extends Value {
}
private
static
ValueLob
copy
(
ValueLob
lob
)
{
ValueLob
copy
=
new
ValueLob
(
lob
.
type
,
lob
.
handler
,
lob
.
fileName
,
lob
.
tableId
,
lob
.
objectId
,
lob
.
linked
,
lob
.
precision
,
lob
.
compression
);
ValueLob
copy
=
new
ValueLob
(
lob
.
type
,
lob
.
handler
,
lob
.
fileName
,
lob
.
tableId
,
lob
.
objectId
,
lob
.
linked
,
lob
.
precision
,
lob
.
compression
);
copy
.
small
=
lob
.
small
;
copy
.
hash
=
lob
.
hash
;
return
copy
;
...
...
@@ -123,7 +124,8 @@ public class ValueLob extends Value {
* @param compression if compression is used
* @return the value object
*/
public
static
ValueLob
open
(
int
type
,
DataHandler
handler
,
int
tableId
,
int
objectId
,
long
precision
,
boolean
compression
)
{
public
static
ValueLob
open
(
int
type
,
DataHandler
handler
,
int
tableId
,
int
objectId
,
long
precision
,
boolean
compression
)
{
String
fileName
=
getFileName
(
handler
,
tableId
,
objectId
);
return
new
ValueLob
(
type
,
handler
,
fileName
,
tableId
,
objectId
,
true
,
precision
,
compression
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
87b97ef0
...
...
@@ -71,7 +71,8 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
* @param precision the precision (number of bytes / characters)
* @return the value
*/
public
static
ValueLobDb
create
(
int
type
,
LobStorage
lobStorage
,
String
fileName
,
int
tableId
,
long
id
,
long
precision
)
{
public
static
ValueLobDb
create
(
int
type
,
LobStorage
lobStorage
,
String
fileName
,
int
tableId
,
long
id
,
long
precision
)
{
return
new
ValueLobDb
(
type
,
lobStorage
,
fileName
,
tableId
,
id
,
precision
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/FileFunctions.java
浏览文件 @
87b97ef0
...
...
@@ -29,9 +29,12 @@ public class FileFunctions {
Class
.
forName
(
"org.h2.Driver"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:mem:"
,
"sa"
,
""
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE ALIAS READ_TEXT_FILE FOR \"org.h2.samples.FileFunctions.readTextFile\" "
);
stat
.
execute
(
"CREATE ALIAS READ_TEXT_FILE_WITH_ENCODING FOR \"org.h2.samples.FileFunctions.readTextFileWithEncoding\" "
);
stat
.
execute
(
"CREATE ALIAS READ_FILE FOR \"org.h2.samples.FileFunctions.readFile\" "
);
stat
.
execute
(
"CREATE ALIAS READ_TEXT_FILE "
+
"FOR \"org.h2.samples.FileFunctions.readTextFile\" "
);
stat
.
execute
(
"CREATE ALIAS READ_TEXT_FILE_WITH_ENCODING "
+
"FOR \"org.h2.samples.FileFunctions.readTextFileWithEncoding\" "
);
stat
.
execute
(
"CREATE ALIAS READ_FILE "
+
"FOR \"org.h2.samples.FileFunctions.readFile\" "
);
ResultSet
rs
=
stat
.
executeQuery
(
"CALL READ_FILE('test.txt')"
);
rs
.
next
();
byte
[]
data
=
rs
.
getBytes
(
1
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
87b97ef0
...
...
@@ -749,7 +749,8 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
*/
public
static
void
printSystemInfo
()
{
Properties
prop
=
System
.
getProperties
();
System
.
out
.
println
(
"H2 "
+
Constants
.
getFullVersion
()
+
" @ "
+
new
java
.
sql
.
Timestamp
(
System
.
currentTimeMillis
()).
toString
());
System
.
out
.
println
(
"H2 "
+
Constants
.
getFullVersion
()
+
" @ "
+
new
java
.
sql
.
Timestamp
(
System
.
currentTimeMillis
()).
toString
());
System
.
out
.
println
(
"Java "
+
prop
.
getProperty
(
"java.runtime.version"
)
+
", "
+
prop
.
getProperty
(
"java.vm.name"
)+
", "
+
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论