Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9ac5a876
提交
9ac5a876
authored
6月 13, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
4445abd7
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
127 行增加
和
138 行删除
+127
-138
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+1
-1
Constants.java
h2/src/main/org/h2/engine/Constants.java
+3
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+9
-13
SessionRemote.java
h2/src/main/org/h2/engine/SessionRemote.java
+1
-1
Message.java
h2/src/main/org/h2/message/Message.java
+9
-1
messages.properties
h2/src/main/org/h2/res/messages.properties
+3
-3
ResultRemote.java
h2/src/main/org/h2/result/ResultRemote.java
+2
-2
admin.jsp
h2/src/main/org/h2/server/web/res/admin.jsp
+3
-3
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+74
-98
FileLock.java
h2/src/main/org/h2/store/FileLock.java
+3
-1
FileStore.java
h2/src/main/org/h2/store/FileStore.java
+9
-9
FileStoreInputStream.java
h2/src/main/org/h2/store/FileStoreInputStream.java
+1
-1
LogFile.java
h2/src/main/org/h2/store/LogFile.java
+2
-2
LogSystem.java
h2/src/main/org/h2/store/LogSystem.java
+7
-1
没有找到文件。
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
9ac5a876
...
...
@@ -43,7 +43,7 @@ public class ConnectionInfo {
String
[]
connectionTime
=
new
String
[]{
"PASSWORD"
,
"USER"
,
"STORAGE"
,
"FILE_LOCK"
,
"CIPHER"
,
"DB_CLOSE_ON_EXIT"
,
"IGNORE_UNKNOWN_SETTINGS"
,
"IFEXISTS"
,
"RECOVER"
,
"CREATE"
,
"CACHE_TYPE"
,
"
WRITE_MODE_LOG"
,
"WRITE
_MODE_DATA"
"
ACCESS_MODE_LOG"
,
"ACCESS
_MODE_DATA"
};
for
(
int
i
=
0
;
i
<
connectionTime
.
length
;
i
++)
{
String
key
=
connectionTime
[
i
];
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
9ac5a876
...
...
@@ -67,8 +67,8 @@ package org.h2.engine;
*/
public
class
Constants
{
public
static
final
int
BUILD_ID
=
4
6
;
private
static
final
String
BUILD
=
"2007-0
4-29
"
;
public
static
final
int
BUILD_ID
=
4
7
;
private
static
final
String
BUILD
=
"2007-0
6-13
"
;
public
static
final
int
VERSION_MAJOR
=
1
;
public
static
final
int
VERSION_MINOR
=
0
;
...
...
@@ -244,6 +244,7 @@ public class Constants {
public
static
final
int
OBJECT_CACHE_SIZE
=
getIntSetting
(
"h2.objectCacheSize"
,
1024
);
public
static
final
int
OBJECT_CACHE_MAX_PER_ELEMENT_SIZE
=
getIntSetting
(
"h2.objectCacheMaxPerElementSize"
,
4096
);
public
static
final
String
CLIENT_TRACE_DIRECTORY
=
getStringSetting
(
"h2.clientTraceDirectory"
,
"trace.db/"
);
public
static
int
MAX_FILE_RETRY
=
Math
.
max
(
1
,
getIntSetting
(
"h2.maxFileRetry"
,
16
));
public
static
boolean
getBooleanSetting
(
String
name
,
boolean
defaultValue
)
{
String
s
=
System
.
getProperty
(
name
);
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
9ac5a876
...
...
@@ -135,7 +135,7 @@ public class Database implements DataHandler {
private
String
cacheType
;
private
boolean
indexSummaryValid
=
true
;
private
Object
lobSyncObject
=
new
Object
();
private
String
writeModeLog
,
write
ModeData
;
private
String
accessModeLog
,
access
ModeData
;
public
static
void
setInitialPowerOffCount
(
int
count
)
{
initialPowerOffCount
=
count
;
...
...
@@ -174,7 +174,7 @@ public class Database implements DataHandler {
}
throw
Message
.
getSQLException
(
Message
.
FILE_VERSION_ERROR_1
,
fileName
);
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
fileNam
e
);
}
}
...
...
@@ -313,11 +313,11 @@ public class Database implements DataHandler {
}
private
void
openFileData
()
throws
SQLException
{
fileData
=
new
DiskFile
(
this
,
databaseName
+
Constants
.
SUFFIX_DATA_FILE
,
write
ModeData
,
true
,
true
,
Constants
.
DEFAULT_CACHE_SIZE
);
fileData
=
new
DiskFile
(
this
,
databaseName
+
Constants
.
SUFFIX_DATA_FILE
,
access
ModeData
,
true
,
true
,
Constants
.
DEFAULT_CACHE_SIZE
);
}
private
void
openFileIndex
()
throws
SQLException
{
fileIndex
=
new
DiskFile
(
this
,
databaseName
+
Constants
.
SUFFIX_INDEX_FILE
,
"rw"
,
false
,
logIndexChanges
,
Constants
.
DEFAULT_CACHE_SIZE_INDEX
);
fileIndex
=
new
DiskFile
(
this
,
databaseName
+
Constants
.
SUFFIX_INDEX_FILE
,
accessModeData
,
false
,
logIndexChanges
,
Constants
.
DEFAULT_CACHE_SIZE_INDEX
);
}
public
DataPage
getDataPage
()
{
...
...
@@ -349,8 +349,8 @@ public class Database implements DataHandler {
this
.
databaseShortName
=
parseDatabaseShortName
();
this
.
cipher
=
cipher
;
String
lockMethodName
=
ci
.
removeProperty
(
"FILE_LOCK"
,
null
);
this
.
writeModeLog
=
ci
.
removeProperty
(
"WRITE
_MODE_LOG"
,
"rw"
).
toLowerCase
();
this
.
writeModeData
=
ci
.
removeProperty
(
"WRITE
_MODE_DATA"
,
"rw"
).
toLowerCase
();
this
.
accessModeLog
=
ci
.
removeProperty
(
"ACCESS
_MODE_LOG"
,
"rw"
).
toLowerCase
();
this
.
accessModeData
=
ci
.
removeProperty
(
"ACCESS
_MODE_DATA"
,
"rw"
).
toLowerCase
();
this
.
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
this
.
textStorage
=
ci
.
getTextStorage
();
this
.
databaseURL
=
ci
.
getURL
();
...
...
@@ -426,7 +426,7 @@ public class Database implements DataHandler {
lock
.
lock
(
databaseName
+
Constants
.
SUFFIX_LOCK_FILE
,
fileLockMethod
==
FileLock
.
LOCK_SOCKET
);
}
deleteOldTempFiles
();
log
=
new
LogSystem
(
this
,
databaseName
,
readOnly
);
log
=
new
LogSystem
(
this
,
databaseName
,
readOnly
,
accessModeLog
);
openFileData
();
openFileIndex
();
if
(!
readOnly
)
{
...
...
@@ -449,7 +449,7 @@ public class Database implements DataHandler {
writer
=
WriterThread
.
create
(
this
,
writeDelay
);
}
else
{
traceSystem
=
new
TraceSystem
(
null
);
log
=
new
LogSystem
(
null
,
null
,
false
);
log
=
new
LogSystem
(
null
,
null
,
false
,
null
);
}
systemUser
=
new
User
(
this
,
0
,
Constants
.
DBA_NAME
,
true
);
mainSchema
=
new
Schema
(
this
,
0
,
Constants
.
SCHEMA_MAIN
,
systemUser
,
true
);
...
...
@@ -1011,7 +1011,7 @@ public class Database implements DataHandler {
boolean
inTempDir
=
readOnly
;
return
FileUtils
.
createTempFile
(
databaseName
,
Constants
.
SUFFIX_TEMP_FILE
,
true
,
inTempDir
);
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
databaseNam
e
);
}
}
...
...
@@ -1490,8 +1490,4 @@ public class Database implements DataHandler {
return
lobSyncObject
;
}
public
String
getWriteModeLog
()
{
return
writeModeLog
;
}
}
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
9ac5a876
...
...
@@ -325,7 +325,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
try
{
return
FileUtils
.
createTempFile
(
databaseName
,
Constants
.
SUFFIX_TEMP_FILE
,
true
,
false
);
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
databaseNam
e
);
}
}
...
...
h2/src/main/org/h2/message/Message.java
浏览文件 @
9ac5a876
...
...
@@ -242,7 +242,7 @@ public class Message {
public
static
final
int
IO_EXCEPTION_1
=
90028
;
public
static
final
int
NOT_ON_UPDATABLE_ROW
=
90029
;
public
static
final
int
FILE_CORRUPTED_1
=
90030
;
public
static
final
int
IO_EXCEPTION_2
=
90031
;
public
static
final
int
USER_NOT_FOUND_1
=
90032
;
public
static
final
int
USER_ALREADY_EXISTS_1
=
90033
;
public
static
final
int
LOG_FILE_ERROR_1
=
90034
;
...
...
@@ -369,6 +369,14 @@ public class Message {
}
return
Message
.
getSQLException
(
Message
.
GENERAL_ERROR_1
,
new
String
[]{
e
.
toString
()},
e
);
}
public
static
SQLException
convertIOException
(
IOException
e
,
String
message
)
{
if
(
message
==
null
)
{
return
Message
.
getSQLException
(
Message
.
IO_EXCEPTION_1
,
new
String
[]{
e
.
toString
()},
e
);
}
else
{
return
Message
.
getSQLException
(
Message
.
IO_EXCEPTION_2
,
new
String
[]{
e
.
toString
(),
message
},
e
);
}
}
public
static
Error
getInternalError
()
{
return
getInternalError
(
"unexpected code path"
);
...
...
h2/src/main/org/h2/res/messages.properties
浏览文件 @
9ac5a876
...
...
@@ -13,7 +13,7 @@
42000
=
Syntax error in SQL statement {0}
42001
=
Syntax error in SQL statement {0}; expected {1}
42S01
=
Table {0} already exists
42S02
=
Table {0} not found.
Possible reasons: typo; the table is in another database or schema; case mismatch (use double quotes)
42S02
=
Table {0} not found.
42S11
=
Index {0} already exists
42S12
=
Index {0} not found
42S21
=
Duplicate column name {0}
...
...
@@ -40,7 +40,7 @@
90017
=
Attempt to define a second primary key
90018
=
The connection was not closed by the application and is garbage collected
90019
=
Cannot drop the current user
90020
=
Database may be already in use: {0}. Possible solution
:
use the server mode
90020
=
Database may be already in use: {0}. Possible solution
s: close all other connection(s);
use the server mode
90021
=
Data conversion error converting {0}
90022
=
Function {0} not found
90023
=
Column {0} must not be nullable
...
...
@@ -51,7 +51,7 @@
90028
=
IO Exception: {0}
90029
=
Currently not on an updatable row
90030
=
File corrupted while reading record: {0}. Possible solution: use the recovery tool
90031
=
IO Exception: {0}; {1}
90032
=
User {0} not found
90033
=
User {0} already exists
90034
=
Log file error: {0}
...
...
h2/src/main/org/h2/result/ResultRemote.java
浏览文件 @
9ac5a876
...
...
@@ -120,7 +120,7 @@ public class ResultRemote implements ResultInterface {
session
.
traceOperation
(
"RESULT_RESET"
,
id
);
transfer
.
writeInt
(
SessionRemote
.
RESULT_RESET
).
writeInt
(
id
).
flush
();
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
null
);
}
}
}
...
...
@@ -236,7 +236,7 @@ public class ResultRemote implements ResultInterface {
return
null
;
}
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
null
);
}
}
}
...
...
h2/src/main/org/h2/server/web/res/admin.jsp
浏览文件 @
9ac5a876
...
...
@@ -117,8 +117,8 @@ Initial Developer: H2 Group
</table>
</form>
<p>
<form
name=
"shutdown"
method=
"post"
action=
"/adminShutdown.do?jsessionid=${sessionId}"
>
<input
type=
"submit"
class=
"button"
value=
"${text.adminShutdown}"
/>
</form>
<form
name=
"shutdown"
method=
"post"
action=
"/adminShutdown.do?jsessionid=${sessionId}"
>
<input
type=
"submit"
class=
"button"
value=
"${text.adminShutdown}"
/>
</form>
</p>
</body></html>
\ No newline at end of file
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
9ac5a876
...
...
@@ -119,16 +119,12 @@ public class DiskFile implements CacheWriter {
}
private
void
create
()
throws
SQLException
{
try
{
file
=
database
.
openFile
(
fileName
,
mode
,
false
);
DataPage
header
=
DataPage
.
create
(
database
,
OFFSET
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
header
.
fill
(
OFFSET
);
header
.
updateChecksum
();
file
.
write
(
header
.
getBytes
(),
0
,
OFFSET
);
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
file
=
database
.
openFile
(
fileName
,
mode
,
false
);
DataPage
header
=
DataPage
.
create
(
database
,
OFFSET
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
header
.
fill
(
OFFSET
);
header
.
updateChecksum
();
file
.
write
(
header
.
getBytes
(),
0
,
OFFSET
);
}
private
void
freeUnusedPages
()
throws
SQLException
{
...
...
@@ -275,43 +271,39 @@ public class DiskFile implements CacheWriter {
s
.
setRecordCount
(
0
);
}
}
try
{
int
blockHeaderLen
=
Math
.
max
(
Constants
.
FILE_BLOCK_SIZE
,
2
*
rowBuff
.
getIntLen
());
byte
[]
buff
=
new
byte
[
blockHeaderLen
];
DataPage
s
=
DataPage
.
create
(
database
,
buff
);
long
time
=
0
;
for
(
int
i
=
0
;
i
<
fileBlockCount
;)
{
long
t2
=
System
.
currentTimeMillis
();
if
(
t2
>
time
+
10
)
{
time
=
t2
;
database
.
setProgress
(
DatabaseEventListener
.
STATE_SCAN_FILE
,
this
.
fileName
,
i
,
fileBlockCount
);
}
go
(
i
);
file
.
readFully
(
buff
,
0
,
blockHeaderLen
);
s
.
reset
();
int
blockCount
=
s
.
readInt
();
if
(
Constants
.
CHECK
&&
blockCount
<
0
)
{
int
blockHeaderLen
=
Math
.
max
(
Constants
.
FILE_BLOCK_SIZE
,
2
*
rowBuff
.
getIntLen
());
byte
[]
buff
=
new
byte
[
blockHeaderLen
];
DataPage
s
=
DataPage
.
create
(
database
,
buff
);
long
time
=
0
;
for
(
int
i
=
0
;
i
<
fileBlockCount
;)
{
long
t2
=
System
.
currentTimeMillis
();
if
(
t2
>
time
+
10
)
{
time
=
t2
;
database
.
setProgress
(
DatabaseEventListener
.
STATE_SCAN_FILE
,
this
.
fileName
,
i
,
fileBlockCount
);
}
go
(
i
);
file
.
readFully
(
buff
,
0
,
blockHeaderLen
);
s
.
reset
();
int
blockCount
=
s
.
readInt
();
if
(
Constants
.
CHECK
&&
blockCount
<
0
)
{
throw
Message
.
getInternalError
();
}
if
(
blockCount
==
0
)
{
setUnused
(
i
,
1
);
i
++;
}
else
{
int
id
=
s
.
readInt
();
if
(
Constants
.
CHECK
&&
id
<
0
)
{
throw
Message
.
getInternalError
();
}
if
(
blockCount
==
0
)
{
setUnused
(
i
,
1
);
i
++;
}
else
{
int
id
=
s
.
readInt
();
if
(
Constants
.
CHECK
&&
id
<
0
)
{
throw
Message
.
getInternalError
();
}
Storage
storage
=
database
.
getStorage
(
id
,
this
);
setBlockOwner
(
storage
,
i
,
blockCount
,
true
);
storage
.
incrementRecordCount
();
i
+=
blockCount
;
}
Storage
storage
=
database
.
getStorage
(
id
,
this
);
setBlockOwner
(
storage
,
i
,
blockCount
,
true
);
storage
.
incrementRecordCount
();
i
+=
blockCount
;
}
database
.
setProgress
(
DatabaseEventListener
.
STATE_SCAN_FILE
,
this
.
fileName
,
fileBlockCount
,
fileBlockCount
);
init
=
true
;
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
database
.
setProgress
(
DatabaseEventListener
.
STATE_SCAN_FILE
,
this
.
fileName
,
fileBlockCount
,
fileBlockCount
);
init
=
true
;
}
synchronized
void
flush
()
throws
SQLException
{
...
...
@@ -565,8 +557,8 @@ public class DiskFile implements CacheWriter {
cache
.
clear
();
file
.
close
();
FileUtils
.
delete
(
fileName
);
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
catch
(
IO
Exception
e
)
{
throw
Message
.
convert
IOException
(
e
,
fileNam
e
);
}
finally
{
file
=
null
;
fileName
=
null
;
...
...
@@ -590,22 +582,18 @@ public class DiskFile implements CacheWriter {
writeCount
++;
Record
record
=
(
Record
)
obj
;
synchronized
(
this
)
{
try
{
int
blockCount
=
record
.
getBlockCount
();
record
.
prepareWrite
();
go
(
record
.
getPos
());
DataPage
buff
=
rowBuff
;
buff
.
reset
();
buff
.
checkCapacity
(
blockCount
*
BLOCK_SIZE
);
buff
.
writeInt
(
blockCount
);
buff
.
writeInt
(
record
.
getStorageId
());
record
.
write
(
buff
);
buff
.
fill
(
blockCount
*
BLOCK_SIZE
);
buff
.
updateChecksum
();
file
.
write
(
buff
.
getBytes
(),
0
,
buff
.
length
());
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
int
blockCount
=
record
.
getBlockCount
();
record
.
prepareWrite
();
go
(
record
.
getPos
());
DataPage
buff
=
rowBuff
;
buff
.
reset
();
buff
.
checkCapacity
(
blockCount
*
BLOCK_SIZE
);
buff
.
writeInt
(
blockCount
);
buff
.
writeInt
(
record
.
getStorageId
());
record
.
write
(
buff
);
buff
.
fill
(
blockCount
*
BLOCK_SIZE
);
buff
.
updateChecksum
();
file
.
write
(
buff
.
getBytes
(),
0
,
buff
.
length
());
}
record
.
setChanged
(
false
);
}
...
...
@@ -618,54 +606,42 @@ public class DiskFile implements CacheWriter {
}
synchronized
void
updateRecord
(
Session
session
,
Record
record
)
throws
SQLException
{
try
{
record
.
setChanged
(
true
);
int
pos
=
record
.
getPos
();
Record
old
=
(
Record
)
cache
.
update
(
pos
,
record
);
if
(
Constants
.
CHECK
)
{
if
(
old
!=
null
)
{
if
(
old
!=
record
)
{
database
.
checkPowerOff
();
throw
Message
.
getInternalError
(
"old != record old="
+
old
+
" new="
+
record
);
}
int
blockCount
=
record
.
getBlockCount
();
for
(
int
i
=
0
;
i
<
blockCount
;
i
++)
{
if
(
deleted
.
get
(
i
+
pos
))
{
throw
Message
.
getInternalError
(
"update marked as deleted: "
+
(
i
+
pos
));
}
record
.
setChanged
(
true
);
int
pos
=
record
.
getPos
();
Record
old
=
(
Record
)
cache
.
update
(
pos
,
record
);
if
(
Constants
.
CHECK
)
{
if
(
old
!=
null
)
{
if
(
old
!=
record
)
{
database
.
checkPowerOff
();
throw
Message
.
getInternalError
(
"old != record old="
+
old
+
" new="
+
record
);
}
int
blockCount
=
record
.
getBlockCount
();
for
(
int
i
=
0
;
i
<
blockCount
;
i
++)
{
if
(
deleted
.
get
(
i
+
pos
))
{
throw
Message
.
getInternalError
(
"update marked as deleted: "
+
(
i
+
pos
));
}
}
}
if
(
logChanges
)
{
log
.
add
(
session
,
this
,
record
);
}
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
if
(
logChanges
)
{
log
.
add
(
session
,
this
,
record
);
}
}
synchronized
void
writeDirectDeleted
(
int
recordId
,
int
blockCount
)
throws
SQLException
{
synchronized
(
this
)
{
try
{
go
(
recordId
);
for
(
int
i
=
0
;
i
<
blockCount
;
i
++)
{
file
.
write
(
freeBlock
.
getBytes
(),
0
,
freeBlock
.
length
());
}
free
(
recordId
,
blockCount
);
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
go
(
recordId
);
for
(
int
i
=
0
;
i
<
blockCount
;
i
++)
{
file
.
write
(
freeBlock
.
getBytes
(),
0
,
freeBlock
.
length
());
}
free
(
recordId
,
blockCount
);
}
}
synchronized
void
writeDirect
(
Storage
storage
,
int
pos
,
byte
[]
data
,
int
offset
)
throws
SQLException
{
try
{
go
(
pos
);
file
.
write
(
data
,
offset
,
BLOCK_SIZE
);
setBlockOwner
(
storage
,
pos
,
1
,
true
);
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
go
(
pos
);
file
.
write
(
data
,
offset
,
BLOCK_SIZE
);
setBlockOwner
(
storage
,
pos
,
1
,
true
);
}
public
synchronized
int
copyDirect
(
int
pos
,
OutputStream
out
)
throws
SQLException
{
...
...
@@ -710,8 +686,8 @@ public class DiskFile implements CacheWriter {
}
out
.
write
(
s
.
getBytes
(),
0
,
blockCount
*
blockSize
);
return
pos
+
blockCount
;
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
catch
(
IO
Exception
e
)
{
throw
Message
.
convert
IOException
(
e
,
fileNam
e
);
}
}
...
...
h2/src/main/org/h2/store/FileLock.java
浏览文件 @
9ac5a876
...
...
@@ -157,7 +157,9 @@ public class FileLock {
private
void
lockFile
()
throws
SQLException
{
method
=
FILE
;
properties
=
new
Properties
();
String
random
=
ByteUtils
.
convertBytesToString
(
RandomUtils
.
getSecureBytes
(
RANDOM_BYTES
));
byte
[]
bytes
=
RandomUtils
.
getSecureBytes
(
RANDOM_BYTES
);
System
.
out
.
println
(
"lockFile 2b"
+
fileName
);
String
random
=
ByteUtils
.
convertBytesToString
(
bytes
);
properties
.
setProperty
(
"id"
,
Long
.
toHexString
(
System
.
currentTimeMillis
())+
random
);
if
(!
FileUtils
.
createNewFile
(
fileName
))
{
waitUntilOld
();
...
...
h2/src/main/org/h2/store/FileStore.java
浏览文件 @
9ac5a876
...
...
@@ -69,7 +69,7 @@ public class FileStore {
}
fileLength
=
file
.
length
();
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
"name: "
+
name
+
" mode: "
+
mod
e
);
}
}
...
...
@@ -177,7 +177,7 @@ public class FileStore {
try
{
file
.
readFully
(
b
,
off
,
len
);
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
filePos
+=
len
;
}
...
...
@@ -192,7 +192,7 @@ public class FileStore {
filePos
=
pos
;
}
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
...
...
@@ -216,10 +216,10 @@ public class FileStore {
try
{
file
.
write
(
b
,
off
,
len
);
}
catch
(
IOException
e2
)
{
throw
Message
.
convert
(
e2
);
throw
Message
.
convert
IOException
(
e2
,
name
);
}
}
else
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
filePos
+=
len
;
...
...
@@ -263,10 +263,10 @@ public class FileStore {
try
{
FileUtils
.
setLength
(
file
,
newLength
);
}
catch
(
IOException
e2
)
{
throw
Message
.
convert
(
e2
);
throw
Message
.
convert
IOException
(
e2
,
name
);
}
}
else
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
}
...
...
@@ -288,7 +288,7 @@ public class FileStore {
}
return
len
;
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
...
...
@@ -299,7 +299,7 @@ public class FileStore {
throw
Message
.
getInternalError
();
}
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
return
filePos
;
...
...
h2/src/main/org/h2/store/FileStoreInputStream.java
浏览文件 @
9ac5a876
...
...
@@ -32,7 +32,7 @@ public class FileStoreInputStream extends InputStream {
fillBuffer
();
}
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
store
.
nam
e
);
}
}
...
...
h2/src/main/org/h2/store/LogFile.java
浏览文件 @
9ac5a876
...
...
@@ -59,7 +59,7 @@ public class LogFile {
this
.
id
=
id
;
this
.
fileNamePrefix
=
fileNamePrefix
;
fileName
=
getFileName
();
file
=
log
.
getDatabase
().
openFile
(
fileName
,
database
.
getWriteModeLog
(),
false
);
file
=
log
.
getDatabase
().
openFile
(
fileName
,
log
.
getAccessMode
(),
false
);
rowBuff
=
log
.
getRowBuffer
();
buffer
=
new
byte
[
BUFFER_SIZE
];
unwritten
=
new
ObjectArray
();
...
...
@@ -366,7 +366,7 @@ public class LogFile {
}
}
catch
(
IOException
e
)
{
if
(
closeException
==
null
)
{
closeException
=
Message
.
convert
(
e
);
closeException
=
Message
.
convert
IOException
(
e
,
fileNam
e
);
}
}
file
=
null
;
...
...
h2/src/main/org/h2/store/LogSystem.java
浏览文件 @
9ac5a876
...
...
@@ -39,10 +39,12 @@ public class LogSystem {
private
boolean
disabled
;
private
int
keepFiles
;
private
boolean
closed
;
private
String
accessMode
;
public
LogSystem
(
Database
database
,
String
fileNamePrefix
,
boolean
readOnly
)
throws
SQLException
{
public
LogSystem
(
Database
database
,
String
fileNamePrefix
,
boolean
readOnly
,
String
accessMode
)
throws
SQLException
{
this
.
database
=
database
;
this
.
readOnly
=
readOnly
;
this
.
accessMode
=
accessMode
;
if
(
database
==
null
||
readOnly
)
{
return
;
}
...
...
@@ -465,4 +467,8 @@ public class LogSystem {
keepFiles
+=
incrementDecrement
;
}
String
getAccessMode
()
{
return
accessMode
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论