Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9ac5a876
提交
9ac5a876
authored
17 年前
作者:
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 {
...
@@ -43,7 +43,7 @@ public class ConnectionInfo {
String
[]
connectionTime
=
new
String
[]{
String
[]
connectionTime
=
new
String
[]{
"PASSWORD"
,
"USER"
,
"STORAGE"
,
"FILE_LOCK"
,
"CIPHER"
,
"DB_CLOSE_ON_EXIT"
,
"PASSWORD"
,
"USER"
,
"STORAGE"
,
"FILE_LOCK"
,
"CIPHER"
,
"DB_CLOSE_ON_EXIT"
,
"IGNORE_UNKNOWN_SETTINGS"
,
"IFEXISTS"
,
"RECOVER"
,
"CREATE"
,
"CACHE_TYPE"
,
"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
++)
{
for
(
int
i
=
0
;
i
<
connectionTime
.
length
;
i
++)
{
String
key
=
connectionTime
[
i
];
String
key
=
connectionTime
[
i
];
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
9ac5a876
...
@@ -67,8 +67,8 @@ package org.h2.engine;
...
@@ -67,8 +67,8 @@ package org.h2.engine;
*/
*/
public
class
Constants
{
public
class
Constants
{
public
static
final
int
BUILD_ID
=
4
6
;
public
static
final
int
BUILD_ID
=
4
7
;
private
static
final
String
BUILD
=
"2007-0
4-29
"
;
private
static
final
String
BUILD
=
"2007-0
6-13
"
;
public
static
final
int
VERSION_MAJOR
=
1
;
public
static
final
int
VERSION_MAJOR
=
1
;
public
static
final
int
VERSION_MINOR
=
0
;
public
static
final
int
VERSION_MINOR
=
0
;
...
@@ -244,6 +244,7 @@ public class Constants {
...
@@ -244,6 +244,7 @@ public class Constants {
public
static
final
int
OBJECT_CACHE_SIZE
=
getIntSetting
(
"h2.objectCacheSize"
,
1024
);
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
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
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
)
{
public
static
boolean
getBooleanSetting
(
String
name
,
boolean
defaultValue
)
{
String
s
=
System
.
getProperty
(
name
);
String
s
=
System
.
getProperty
(
name
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
9ac5a876
...
@@ -135,7 +135,7 @@ public class Database implements DataHandler {
...
@@ -135,7 +135,7 @@ public class Database implements DataHandler {
private
String
cacheType
;
private
String
cacheType
;
private
boolean
indexSummaryValid
=
true
;
private
boolean
indexSummaryValid
=
true
;
private
Object
lobSyncObject
=
new
Object
();
private
Object
lobSyncObject
=
new
Object
();
private
String
writeModeLog
,
write
ModeData
;
private
String
accessModeLog
,
access
ModeData
;
public
static
void
setInitialPowerOffCount
(
int
count
)
{
public
static
void
setInitialPowerOffCount
(
int
count
)
{
initialPowerOffCount
=
count
;
initialPowerOffCount
=
count
;
...
@@ -174,7 +174,7 @@ public class Database implements DataHandler {
...
@@ -174,7 +174,7 @@ public class Database implements DataHandler {
}
}
throw
Message
.
getSQLException
(
Message
.
FILE_VERSION_ERROR_1
,
fileName
);
throw
Message
.
getSQLException
(
Message
.
FILE_VERSION_ERROR_1
,
fileName
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
fileNam
e
);
}
}
}
}
...
@@ -313,11 +313,11 @@ public class Database implements DataHandler {
...
@@ -313,11 +313,11 @@ public class Database implements DataHandler {
}
}
private
void
openFileData
()
throws
SQLException
{
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
{
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
()
{
public
DataPage
getDataPage
()
{
...
@@ -349,8 +349,8 @@ public class Database implements DataHandler {
...
@@ -349,8 +349,8 @@ public class Database implements DataHandler {
this
.
databaseShortName
=
parseDatabaseShortName
();
this
.
databaseShortName
=
parseDatabaseShortName
();
this
.
cipher
=
cipher
;
this
.
cipher
=
cipher
;
String
lockMethodName
=
ci
.
removeProperty
(
"FILE_LOCK"
,
null
);
String
lockMethodName
=
ci
.
removeProperty
(
"FILE_LOCK"
,
null
);
this
.
writeModeLog
=
ci
.
removeProperty
(
"WRITE
_MODE_LOG"
,
"rw"
).
toLowerCase
();
this
.
accessModeLog
=
ci
.
removeProperty
(
"ACCESS
_MODE_LOG"
,
"rw"
).
toLowerCase
();
this
.
writeModeData
=
ci
.
removeProperty
(
"WRITE
_MODE_DATA"
,
"rw"
).
toLowerCase
();
this
.
accessModeData
=
ci
.
removeProperty
(
"ACCESS
_MODE_DATA"
,
"rw"
).
toLowerCase
();
this
.
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
this
.
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
this
.
textStorage
=
ci
.
getTextStorage
();
this
.
textStorage
=
ci
.
getTextStorage
();
this
.
databaseURL
=
ci
.
getURL
();
this
.
databaseURL
=
ci
.
getURL
();
...
@@ -426,7 +426,7 @@ public class Database implements DataHandler {
...
@@ -426,7 +426,7 @@ public class Database implements DataHandler {
lock
.
lock
(
databaseName
+
Constants
.
SUFFIX_LOCK_FILE
,
fileLockMethod
==
FileLock
.
LOCK_SOCKET
);
lock
.
lock
(
databaseName
+
Constants
.
SUFFIX_LOCK_FILE
,
fileLockMethod
==
FileLock
.
LOCK_SOCKET
);
}
}
deleteOldTempFiles
();
deleteOldTempFiles
();
log
=
new
LogSystem
(
this
,
databaseName
,
readOnly
);
log
=
new
LogSystem
(
this
,
databaseName
,
readOnly
,
accessModeLog
);
openFileData
();
openFileData
();
openFileIndex
();
openFileIndex
();
if
(!
readOnly
)
{
if
(!
readOnly
)
{
...
@@ -449,7 +449,7 @@ public class Database implements DataHandler {
...
@@ -449,7 +449,7 @@ public class Database implements DataHandler {
writer
=
WriterThread
.
create
(
this
,
writeDelay
);
writer
=
WriterThread
.
create
(
this
,
writeDelay
);
}
else
{
}
else
{
traceSystem
=
new
TraceSystem
(
null
);
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
);
systemUser
=
new
User
(
this
,
0
,
Constants
.
DBA_NAME
,
true
);
mainSchema
=
new
Schema
(
this
,
0
,
Constants
.
SCHEMA_MAIN
,
systemUser
,
true
);
mainSchema
=
new
Schema
(
this
,
0
,
Constants
.
SCHEMA_MAIN
,
systemUser
,
true
);
...
@@ -1011,7 +1011,7 @@ public class Database implements DataHandler {
...
@@ -1011,7 +1011,7 @@ public class Database implements DataHandler {
boolean
inTempDir
=
readOnly
;
boolean
inTempDir
=
readOnly
;
return
FileUtils
.
createTempFile
(
databaseName
,
Constants
.
SUFFIX_TEMP_FILE
,
true
,
inTempDir
);
return
FileUtils
.
createTempFile
(
databaseName
,
Constants
.
SUFFIX_TEMP_FILE
,
true
,
inTempDir
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
databaseNam
e
);
}
}
}
}
...
@@ -1490,8 +1490,4 @@ public class Database implements DataHandler {
...
@@ -1490,8 +1490,4 @@ public class Database implements DataHandler {
return
lobSyncObject
;
return
lobSyncObject
;
}
}
public
String
getWriteModeLog
()
{
return
writeModeLog
;
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
9ac5a876
...
@@ -325,7 +325,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
...
@@ -325,7 +325,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
try
{
try
{
return
FileUtils
.
createTempFile
(
databaseName
,
Constants
.
SUFFIX_TEMP_FILE
,
true
,
false
);
return
FileUtils
.
createTempFile
(
databaseName
,
Constants
.
SUFFIX_TEMP_FILE
,
true
,
false
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
databaseNam
e
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/message/Message.java
浏览文件 @
9ac5a876
...
@@ -242,7 +242,7 @@ public class Message {
...
@@ -242,7 +242,7 @@ public class Message {
public
static
final
int
IO_EXCEPTION_1
=
90028
;
public
static
final
int
IO_EXCEPTION_1
=
90028
;
public
static
final
int
NOT_ON_UPDATABLE_ROW
=
90029
;
public
static
final
int
NOT_ON_UPDATABLE_ROW
=
90029
;
public
static
final
int
FILE_CORRUPTED_1
=
90030
;
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_NOT_FOUND_1
=
90032
;
public
static
final
int
USER_ALREADY_EXISTS_1
=
90033
;
public
static
final
int
USER_ALREADY_EXISTS_1
=
90033
;
public
static
final
int
LOG_FILE_ERROR_1
=
90034
;
public
static
final
int
LOG_FILE_ERROR_1
=
90034
;
...
@@ -370,6 +370,14 @@ public class Message {
...
@@ -370,6 +370,14 @@ public class Message {
return
Message
.
getSQLException
(
Message
.
GENERAL_ERROR_1
,
new
String
[]{
e
.
toString
()},
e
);
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
()
{
public
static
Error
getInternalError
()
{
return
getInternalError
(
"unexpected code path"
);
return
getInternalError
(
"unexpected code path"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/res/messages.properties
浏览文件 @
9ac5a876
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
42000
=
Syntax error in SQL statement {0}
42000
=
Syntax error in SQL statement {0}
42001
=
Syntax error in SQL statement {0}; expected {1}
42001
=
Syntax error in SQL statement {0}; expected {1}
42S01
=
Table {0} already exists
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
42S11
=
Index {0} already exists
42S12
=
Index {0} not found
42S12
=
Index {0} not found
42S21
=
Duplicate column name {0}
42S21
=
Duplicate column name {0}
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
90017
=
Attempt to define a second primary key
90017
=
Attempt to define a second primary key
90018
=
The connection was not closed by the application and is garbage collected
90018
=
The connection was not closed by the application and is garbage collected
90019
=
Cannot drop the current user
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}
90021
=
Data conversion error converting {0}
90022
=
Function {0} not found
90022
=
Function {0} not found
90023
=
Column {0} must not be nullable
90023
=
Column {0} must not be nullable
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
90028
=
IO Exception: {0}
90028
=
IO Exception: {0}
90029
=
Currently not on an updatable row
90029
=
Currently not on an updatable row
90030
=
File corrupted while reading record: {0}. Possible solution: use the recovery tool
90030
=
File corrupted while reading record: {0}. Possible solution: use the recovery tool
90031
=
IO Exception: {0}; {1}
90032
=
User {0} not found
90032
=
User {0} not found
90033
=
User {0} already exists
90033
=
User {0} already exists
90034
=
Log file error: {0}
90034
=
Log file error: {0}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/ResultRemote.java
浏览文件 @
9ac5a876
...
@@ -120,7 +120,7 @@ public class ResultRemote implements ResultInterface {
...
@@ -120,7 +120,7 @@ public class ResultRemote implements ResultInterface {
session
.
traceOperation
(
"RESULT_RESET"
,
id
);
session
.
traceOperation
(
"RESULT_RESET"
,
id
);
transfer
.
writeInt
(
SessionRemote
.
RESULT_RESET
).
writeInt
(
id
).
flush
();
transfer
.
writeInt
(
SessionRemote
.
RESULT_RESET
).
writeInt
(
id
).
flush
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
null
);
}
}
}
}
}
}
...
@@ -236,7 +236,7 @@ public class ResultRemote implements ResultInterface {
...
@@ -236,7 +236,7 @@ public class ResultRemote implements ResultInterface {
return
null
;
return
null
;
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
null
);
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/res/admin.jsp
浏览文件 @
9ac5a876
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
9ac5a876
...
@@ -119,16 +119,12 @@ public class DiskFile implements CacheWriter {
...
@@ -119,16 +119,12 @@ public class DiskFile implements CacheWriter {
}
}
private
void
create
()
throws
SQLException
{
private
void
create
()
throws
SQLException
{
try
{
file
=
database
.
openFile
(
fileName
,
mode
,
false
);
file
=
database
.
openFile
(
fileName
,
mode
,
false
);
DataPage
header
=
DataPage
.
create
(
database
,
OFFSET
);
DataPage
header
=
DataPage
.
create
(
database
,
OFFSET
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
header
.
fill
(
OFFSET
);
header
.
fill
(
OFFSET
);
header
.
updateChecksum
();
header
.
updateChecksum
();
file
.
write
(
header
.
getBytes
(),
0
,
OFFSET
);
file
.
write
(
header
.
getBytes
(),
0
,
OFFSET
);
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
}
}
private
void
freeUnusedPages
()
throws
SQLException
{
private
void
freeUnusedPages
()
throws
SQLException
{
...
@@ -275,7 +271,6 @@ public class DiskFile implements CacheWriter {
...
@@ -275,7 +271,6 @@ public class DiskFile implements CacheWriter {
s
.
setRecordCount
(
0
);
s
.
setRecordCount
(
0
);
}
}
}
}
try
{
int
blockHeaderLen
=
Math
.
max
(
Constants
.
FILE_BLOCK_SIZE
,
2
*
rowBuff
.
getIntLen
());
int
blockHeaderLen
=
Math
.
max
(
Constants
.
FILE_BLOCK_SIZE
,
2
*
rowBuff
.
getIntLen
());
byte
[]
buff
=
new
byte
[
blockHeaderLen
];
byte
[]
buff
=
new
byte
[
blockHeaderLen
];
DataPage
s
=
DataPage
.
create
(
database
,
buff
);
DataPage
s
=
DataPage
.
create
(
database
,
buff
);
...
@@ -309,9 +304,6 @@ public class DiskFile implements CacheWriter {
...
@@ -309,9 +304,6 @@ public class DiskFile implements CacheWriter {
}
}
database
.
setProgress
(
DatabaseEventListener
.
STATE_SCAN_FILE
,
this
.
fileName
,
fileBlockCount
,
fileBlockCount
);
database
.
setProgress
(
DatabaseEventListener
.
STATE_SCAN_FILE
,
this
.
fileName
,
fileBlockCount
,
fileBlockCount
);
init
=
true
;
init
=
true
;
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
}
}
synchronized
void
flush
()
throws
SQLException
{
synchronized
void
flush
()
throws
SQLException
{
...
@@ -565,8 +557,8 @@ public class DiskFile implements CacheWriter {
...
@@ -565,8 +557,8 @@ public class DiskFile implements CacheWriter {
cache
.
clear
();
cache
.
clear
();
file
.
close
();
file
.
close
();
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
}
catch
(
Exception
e
)
{
}
catch
(
IO
Exception
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
fileNam
e
);
}
finally
{
}
finally
{
file
=
null
;
file
=
null
;
fileName
=
null
;
fileName
=
null
;
...
@@ -590,7 +582,6 @@ public class DiskFile implements CacheWriter {
...
@@ -590,7 +582,6 @@ public class DiskFile implements CacheWriter {
writeCount
++;
writeCount
++;
Record
record
=
(
Record
)
obj
;
Record
record
=
(
Record
)
obj
;
synchronized
(
this
)
{
synchronized
(
this
)
{
try
{
int
blockCount
=
record
.
getBlockCount
();
int
blockCount
=
record
.
getBlockCount
();
record
.
prepareWrite
();
record
.
prepareWrite
();
go
(
record
.
getPos
());
go
(
record
.
getPos
());
...
@@ -603,9 +594,6 @@ public class DiskFile implements CacheWriter {
...
@@ -603,9 +594,6 @@ public class DiskFile implements CacheWriter {
buff
.
fill
(
blockCount
*
BLOCK_SIZE
);
buff
.
fill
(
blockCount
*
BLOCK_SIZE
);
buff
.
updateChecksum
();
buff
.
updateChecksum
();
file
.
write
(
buff
.
getBytes
(),
0
,
buff
.
length
());
file
.
write
(
buff
.
getBytes
(),
0
,
buff
.
length
());
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
}
}
record
.
setChanged
(
false
);
record
.
setChanged
(
false
);
}
}
...
@@ -618,7 +606,6 @@ public class DiskFile implements CacheWriter {
...
@@ -618,7 +606,6 @@ public class DiskFile implements CacheWriter {
}
}
synchronized
void
updateRecord
(
Session
session
,
Record
record
)
throws
SQLException
{
synchronized
void
updateRecord
(
Session
session
,
Record
record
)
throws
SQLException
{
try
{
record
.
setChanged
(
true
);
record
.
setChanged
(
true
);
int
pos
=
record
.
getPos
();
int
pos
=
record
.
getPos
();
Record
old
=
(
Record
)
cache
.
update
(
pos
,
record
);
Record
old
=
(
Record
)
cache
.
update
(
pos
,
record
);
...
@@ -639,33 +626,22 @@ public class DiskFile implements CacheWriter {
...
@@ -639,33 +626,22 @@ public class DiskFile implements CacheWriter {
if
(
logChanges
)
{
if
(
logChanges
)
{
log
.
add
(
session
,
this
,
record
);
log
.
add
(
session
,
this
,
record
);
}
}
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
}
}
synchronized
void
writeDirectDeleted
(
int
recordId
,
int
blockCount
)
throws
SQLException
{
synchronized
void
writeDirectDeleted
(
int
recordId
,
int
blockCount
)
throws
SQLException
{
synchronized
(
this
)
{
synchronized
(
this
)
{
try
{
go
(
recordId
);
go
(
recordId
);
for
(
int
i
=
0
;
i
<
blockCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
blockCount
;
i
++)
{
file
.
write
(
freeBlock
.
getBytes
(),
0
,
freeBlock
.
length
());
file
.
write
(
freeBlock
.
getBytes
(),
0
,
freeBlock
.
length
());
}
}
free
(
recordId
,
blockCount
);
free
(
recordId
,
blockCount
);
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
}
}
}
}
synchronized
void
writeDirect
(
Storage
storage
,
int
pos
,
byte
[]
data
,
int
offset
)
throws
SQLException
{
synchronized
void
writeDirect
(
Storage
storage
,
int
pos
,
byte
[]
data
,
int
offset
)
throws
SQLException
{
try
{
go
(
pos
);
go
(
pos
);
file
.
write
(
data
,
offset
,
BLOCK_SIZE
);
file
.
write
(
data
,
offset
,
BLOCK_SIZE
);
setBlockOwner
(
storage
,
pos
,
1
,
true
);
setBlockOwner
(
storage
,
pos
,
1
,
true
);
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
}
}
public
synchronized
int
copyDirect
(
int
pos
,
OutputStream
out
)
throws
SQLException
{
public
synchronized
int
copyDirect
(
int
pos
,
OutputStream
out
)
throws
SQLException
{
...
@@ -710,8 +686,8 @@ public class DiskFile implements CacheWriter {
...
@@ -710,8 +686,8 @@ public class DiskFile implements CacheWriter {
}
}
out
.
write
(
s
.
getBytes
(),
0
,
blockCount
*
blockSize
);
out
.
write
(
s
.
getBytes
(),
0
,
blockCount
*
blockSize
);
return
pos
+
blockCount
;
return
pos
+
blockCount
;
}
catch
(
Exception
e
)
{
}
catch
(
IO
Exception
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
fileNam
e
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/FileLock.java
浏览文件 @
9ac5a876
...
@@ -157,7 +157,9 @@ public class FileLock {
...
@@ -157,7 +157,9 @@ public class FileLock {
private
void
lockFile
()
throws
SQLException
{
private
void
lockFile
()
throws
SQLException
{
method
=
FILE
;
method
=
FILE
;
properties
=
new
Properties
();
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
);
properties
.
setProperty
(
"id"
,
Long
.
toHexString
(
System
.
currentTimeMillis
())+
random
);
if
(!
FileUtils
.
createNewFile
(
fileName
))
{
if
(!
FileUtils
.
createNewFile
(
fileName
))
{
waitUntilOld
();
waitUntilOld
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/FileStore.java
浏览文件 @
9ac5a876
...
@@ -69,7 +69,7 @@ public class FileStore {
...
@@ -69,7 +69,7 @@ public class FileStore {
}
}
fileLength
=
file
.
length
();
fileLength
=
file
.
length
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
"name: "
+
name
+
" mode: "
+
mod
e
);
}
}
}
}
...
@@ -177,7 +177,7 @@ public class FileStore {
...
@@ -177,7 +177,7 @@ public class FileStore {
try
{
try
{
file
.
readFully
(
b
,
off
,
len
);
file
.
readFully
(
b
,
off
,
len
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
filePos
+=
len
;
filePos
+=
len
;
}
}
...
@@ -192,7 +192,7 @@ public class FileStore {
...
@@ -192,7 +192,7 @@ public class FileStore {
filePos
=
pos
;
filePos
=
pos
;
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
}
}
...
@@ -216,10 +216,10 @@ public class FileStore {
...
@@ -216,10 +216,10 @@ public class FileStore {
try
{
try
{
file
.
write
(
b
,
off
,
len
);
file
.
write
(
b
,
off
,
len
);
}
catch
(
IOException
e2
)
{
}
catch
(
IOException
e2
)
{
throw
Message
.
convert
(
e2
);
throw
Message
.
convert
IOException
(
e2
,
name
);
}
}
}
else
{
}
else
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
}
}
filePos
+=
len
;
filePos
+=
len
;
...
@@ -263,10 +263,10 @@ public class FileStore {
...
@@ -263,10 +263,10 @@ public class FileStore {
try
{
try
{
FileUtils
.
setLength
(
file
,
newLength
);
FileUtils
.
setLength
(
file
,
newLength
);
}
catch
(
IOException
e2
)
{
}
catch
(
IOException
e2
)
{
throw
Message
.
convert
(
e2
);
throw
Message
.
convert
IOException
(
e2
,
name
);
}
}
}
else
{
}
else
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
}
}
}
}
...
@@ -288,7 +288,7 @@ public class FileStore {
...
@@ -288,7 +288,7 @@ public class FileStore {
}
}
return
len
;
return
len
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
}
}
...
@@ -299,7 +299,7 @@ public class FileStore {
...
@@ -299,7 +299,7 @@ public class FileStore {
throw
Message
.
getInternalError
();
throw
Message
.
getInternalError
();
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
nam
e
);
}
}
}
}
return
filePos
;
return
filePos
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/FileStoreInputStream.java
浏览文件 @
9ac5a876
...
@@ -32,7 +32,7 @@ public class FileStoreInputStream extends InputStream {
...
@@ -32,7 +32,7 @@ public class FileStoreInputStream extends InputStream {
fillBuffer
();
fillBuffer
();
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
IOException
(
e
,
store
.
nam
e
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/LogFile.java
浏览文件 @
9ac5a876
...
@@ -59,7 +59,7 @@ public class LogFile {
...
@@ -59,7 +59,7 @@ public class LogFile {
this
.
id
=
id
;
this
.
id
=
id
;
this
.
fileNamePrefix
=
fileNamePrefix
;
this
.
fileNamePrefix
=
fileNamePrefix
;
fileName
=
getFileName
();
fileName
=
getFileName
();
file
=
log
.
getDatabase
().
openFile
(
fileName
,
database
.
getWriteModeLog
(),
false
);
file
=
log
.
getDatabase
().
openFile
(
fileName
,
log
.
getAccessMode
(),
false
);
rowBuff
=
log
.
getRowBuffer
();
rowBuff
=
log
.
getRowBuffer
();
buffer
=
new
byte
[
BUFFER_SIZE
];
buffer
=
new
byte
[
BUFFER_SIZE
];
unwritten
=
new
ObjectArray
();
unwritten
=
new
ObjectArray
();
...
@@ -366,7 +366,7 @@ public class LogFile {
...
@@ -366,7 +366,7 @@ public class LogFile {
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
if
(
closeException
==
null
)
{
if
(
closeException
==
null
)
{
closeException
=
Message
.
convert
(
e
);
closeException
=
Message
.
convert
IOException
(
e
,
fileNam
e
);
}
}
}
}
file
=
null
;
file
=
null
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/LogSystem.java
浏览文件 @
9ac5a876
...
@@ -39,10 +39,12 @@ public class LogSystem {
...
@@ -39,10 +39,12 @@ public class LogSystem {
private
boolean
disabled
;
private
boolean
disabled
;
private
int
keepFiles
;
private
int
keepFiles
;
private
boolean
closed
;
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
.
database
=
database
;
this
.
readOnly
=
readOnly
;
this
.
readOnly
=
readOnly
;
this
.
accessMode
=
accessMode
;
if
(
database
==
null
||
readOnly
)
{
if
(
database
==
null
||
readOnly
)
{
return
;
return
;
}
}
...
@@ -465,4 +467,8 @@ public class LogSystem {
...
@@ -465,4 +467,8 @@ public class LogSystem {
keepFiles
+=
incrementDecrement
;
keepFiles
+=
incrementDecrement
;
}
}
String
getAccessMode
()
{
return
accessMode
;
}
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论