Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a674f921
提交
a674f921
authored
2月 11, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into generated_keys
上级
74ecb62b
77b6e4b1
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
187 行增加
和
217 行删除
+187
-217
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+1
-1
DropIndex.java
h2/src/main/org/h2/command/ddl/DropIndex.java
+1
-1
BackupCommand.java
h2/src/main/org/h2/command/dml/BackupCommand.java
+30
-30
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+2
-3
Constraint.java
h2/src/main/org/h2/constraint/Constraint.java
+20
-38
ConstraintCheck.java
h2/src/main/org/h2/constraint/ConstraintCheck.java
+2
-2
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+2
-2
ConstraintUnique.java
h2/src/main/org/h2/constraint/ConstraintUnique.java
+2
-2
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+1
-1
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+8
-9
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+1
-1
Backup.java
h2/src/main/org/h2/tools/Backup.java
+38
-38
ChangeFileEncryption.java
h2/src/main/org/h2/tools/ChangeFileEncryption.java
+26
-32
Restore.java
h2/src/main/org/h2/tools/Restore.java
+31
-31
Profiler.java
h2/src/main/org/h2/util/Profiler.java
+13
-17
SortedProperties.java
h2/src/main/org/h2/util/SortedProperties.java
+9
-9
没有找到文件。
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
a674f921
...
@@ -120,7 +120,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
...
@@ -120,7 +120,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
ArrayList
<
Constraint
>
constraints
=
table
.
getConstraints
();
ArrayList
<
Constraint
>
constraints
=
table
.
getConstraints
();
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
c
=
constraints
.
get
(
i
);
Constraint
c
=
constraints
.
get
(
i
);
if
(
Constraint
.
PRIMARY_KEY
.
equals
(
c
.
getConstraintType
()
))
{
if
(
Constraint
.
Type
.
PRIMARY_KEY
==
c
.
getConstraintType
(
))
{
throw
DbException
.
get
(
ErrorCode
.
SECOND_PRIMARY_KEY
);
throw
DbException
.
get
(
ErrorCode
.
SECOND_PRIMARY_KEY
);
}
}
}
}
...
...
h2/src/main/org/h2/command/ddl/DropIndex.java
浏览文件 @
a674f921
...
@@ -57,7 +57,7 @@ public class DropIndex extends SchemaCommand {
...
@@ -57,7 +57,7 @@ public class DropIndex extends SchemaCommand {
Constraint
cons
=
constraints
.
get
(
i
);
Constraint
cons
=
constraints
.
get
(
i
);
if
(
cons
.
usesIndex
(
index
))
{
if
(
cons
.
usesIndex
(
index
))
{
// can drop primary key index (for compatibility)
// can drop primary key index (for compatibility)
if
(
Constraint
.
PRIMARY_KEY
.
equals
(
cons
.
getConstraintType
()
))
{
if
(
Constraint
.
Type
.
PRIMARY_KEY
==
cons
.
getConstraintType
(
))
{
pkConstraint
=
cons
;
pkConstraint
=
cons
;
}
else
{
}
else
{
throw
DbException
.
get
(
throw
DbException
.
get
(
...
...
h2/src/main/org/h2/command/dml/BackupCommand.java
浏览文件 @
a674f921
...
@@ -64,40 +64,40 @@ public class BackupCommand extends Prepared {
...
@@ -64,40 +64,40 @@ public class BackupCommand extends Prepared {
}
}
String
name
=
db
.
getName
();
String
name
=
db
.
getName
();
name
=
FileUtils
.
getName
(
name
);
name
=
FileUtils
.
getName
(
name
);
OutputStream
zip
=
FileUtils
.
newOutputStream
(
fileName
,
false
);
try
(
OutputStream
zip
=
FileUtils
.
newOutputStream
(
fileName
,
false
))
{
ZipOutputStream
out
=
new
ZipOutputStream
(
zip
);
ZipOutputStream
out
=
new
ZipOutputStream
(
zip
);
db
.
flush
();
db
.
flush
();
if
(
db
.
getPageStore
()
!=
null
)
{
if
(
db
.
getPageStore
()
!=
null
)
{
String
fn
=
db
.
getName
()
+
Constants
.
SUFFIX_PAGE_FILE
;
String
fn
=
db
.
getName
()
+
Constants
.
SUFFIX_PAGE_FILE
;
backupPageStore
(
out
,
fn
,
db
.
getPageStore
());
backupPageStore
(
out
,
fn
,
db
.
getPageStore
());
}
}
// synchronize on the database, to avoid concurrent temp file
// synchronize on the database, to avoid concurrent temp file
// creation / deletion / backup
// creation / deletion / backup
String
base
=
FileUtils
.
getParent
(
db
.
getName
());
String
base
=
FileUtils
.
getParent
(
db
.
getName
());
synchronized
(
db
.
getLobSyncObject
())
{
synchronized
(
db
.
getLobSyncObject
())
{
String
prefix
=
db
.
getDatabasePath
();
String
prefix
=
db
.
getDatabasePath
();
String
dir
=
FileUtils
.
getParent
(
prefix
);
String
dir
=
FileUtils
.
getParent
(
prefix
);
dir
=
FileLister
.
getDir
(
dir
);
dir
=
FileLister
.
getDir
(
dir
);
ArrayList
<
String
>
fileList
=
FileLister
.
getDatabaseFiles
(
dir
,
name
,
true
);
ArrayList
<
String
>
fileList
=
FileLister
.
getDatabaseFiles
(
dir
,
name
,
true
);
for
(
String
n
:
fileList
)
{
for
(
String
n
:
fileList
)
{
if
(
n
.
endsWith
(
Constants
.
SUFFIX_LOB_FILE
))
{
if
(
n
.
endsWith
(
Constants
.
SUFFIX_LOB_FILE
))
{
backupFile
(
out
,
base
,
n
);
backupFile
(
out
,
base
,
n
);
}
}
if
(
n
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
)
&&
mvStore
!=
null
)
{
if
(
n
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
)
&&
mvStore
!=
null
)
{
MVStore
s
=
mvStore
.
getStore
();
MVStore
s
=
mvStore
.
getStore
();
boolean
before
=
s
.
getReuseSpace
();
boolean
before
=
s
.
getReuseSpace
();
s
.
setReuseSpace
(
false
);
s
.
setReuseSpace
(
false
);
try
{
try
{
InputStream
in
=
mvStore
.
getInputStream
();
InputStream
in
=
mvStore
.
getInputStream
();
backupFile
(
out
,
base
,
n
,
in
);
backupFile
(
out
,
base
,
n
,
in
);
}
finally
{
}
finally
{
s
.
setReuseSpace
(
before
);
s
.
setReuseSpace
(
before
);
}
}
}
}
}
}
}
out
.
close
();
}
}
out
.
close
();
zip
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
fileName
);
throw
DbException
.
convertIOException
(
e
,
fileName
);
}
}
...
...
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
a674f921
...
@@ -284,8 +284,7 @@ public class ScriptCommand extends ScriptBase {
...
@@ -284,8 +284,7 @@ public class ScriptCommand extends ScriptBase {
final
ArrayList
<
Constraint
>
constraints
=
table
.
getConstraints
();
final
ArrayList
<
Constraint
>
constraints
=
table
.
getConstraints
();
if
(
constraints
!=
null
)
{
if
(
constraints
!=
null
)
{
for
(
Constraint
constraint
:
constraints
)
{
for
(
Constraint
constraint
:
constraints
)
{
if
(
Constraint
.
PRIMARY_KEY
.
equals
(
if
(
Constraint
.
Type
.
PRIMARY_KEY
==
constraint
.
getConstraintType
())
{
constraint
.
getConstraintType
()))
{
add
(
constraint
.
getCreateSQLWithoutIndexes
(),
false
);
add
(
constraint
.
getCreateSQLWithoutIndexes
(),
false
);
}
}
}
}
...
@@ -336,7 +335,7 @@ public class ScriptCommand extends ScriptBase {
...
@@ -336,7 +335,7 @@ public class ScriptCommand extends ScriptBase {
if
(
constraint
.
getTable
().
isHidden
())
{
if
(
constraint
.
getTable
().
isHidden
())
{
continue
;
continue
;
}
}
if
(
!
Constraint
.
PRIMARY_KEY
.
equals
(
constraint
.
getConstraintType
()
))
{
if
(
Constraint
.
Type
.
PRIMARY_KEY
!=
constraint
.
getConstraintType
(
))
{
add
(
constraint
.
getCreateSQLWithoutIndexes
(),
false
);
add
(
constraint
.
getCreateSQLWithoutIndexes
(),
false
);
}
}
}
}
...
...
h2/src/main/org/h2/constraint/Constraint.java
浏览文件 @
a674f921
...
@@ -24,25 +24,24 @@ import org.h2.table.Table;
...
@@ -24,25 +24,24 @@ import org.h2.table.Table;
public
abstract
class
Constraint
extends
SchemaObjectBase
implements
public
abstract
class
Constraint
extends
SchemaObjectBase
implements
Comparable
<
Constraint
>
{
Comparable
<
Constraint
>
{
/**
public
enum
Type
{
* The constraint type name for check constraints.
/**
*/
* The constraint type for check constraints.
public
static
final
String
CHECK
=
"CHECK"
;
*/
CHECK
,
/**
/**
* The constraint type name for referential constraints.
* The constraint type for primary key constraints.
*/
*/
public
static
final
String
REFERENTIAL
=
"REFERENTIAL"
;
PRIMARY_KEY
,
/**
/**
* The constraint type for unique constraints.
* The constraint type name for unique constraints.
*/
*/
UNIQUE
,
public
static
final
String
UNIQUE
=
"UNIQUE"
;
/**
* The constraint type for referential constraints.
/**
*/
* The constraint type name for primary key constraints.
REFERENTIAL
*/
}
public
static
final
String
PRIMARY_KEY
=
"PRIMARY KEY"
;
/**
/**
* The table for which this constraint is defined.
* The table for which this constraint is defined.
...
@@ -60,7 +59,7 @@ public abstract class Constraint extends SchemaObjectBase implements
...
@@ -60,7 +59,7 @@ public abstract class Constraint extends SchemaObjectBase implements
*
*
* @return the name
* @return the name
*/
*/
public
abstract
String
getConstraintType
();
public
abstract
Type
getConstraintType
();
/**
/**
* Check if this row fulfils the constraint.
* Check if this row fulfils the constraint.
...
@@ -155,29 +154,12 @@ public abstract class Constraint extends SchemaObjectBase implements
...
@@ -155,29 +154,12 @@ public abstract class Constraint extends SchemaObjectBase implements
return
null
;
return
null
;
}
}
private
int
getConstraintTypeOrder
()
{
String
constraintType
=
getConstraintType
();
if
(
CHECK
.
equals
(
constraintType
))
{
return
0
;
}
else
if
(
PRIMARY_KEY
.
equals
(
constraintType
))
{
return
1
;
}
else
if
(
UNIQUE
.
equals
(
constraintType
))
{
return
2
;
}
else
if
(
REFERENTIAL
.
equals
(
constraintType
))
{
return
3
;
}
else
{
throw
DbException
.
throwInternalError
(
"type: "
+
constraintType
);
}
}
@Override
@Override
public
int
compareTo
(
Constraint
other
)
{
public
int
compareTo
(
Constraint
other
)
{
if
(
this
==
other
)
{
if
(
this
==
other
)
{
return
0
;
return
0
;
}
}
int
thisType
=
getConstraintTypeOrder
();
return
Integer
.
compare
(
getConstraintType
().
ordinal
(),
other
.
getConstraintType
().
ordinal
());
int
otherType
=
other
.
getConstraintTypeOrder
();
return
thisType
-
otherType
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/constraint/ConstraintCheck.java
浏览文件 @
a674f921
...
@@ -36,8 +36,8 @@ public class ConstraintCheck extends Constraint {
...
@@ -36,8 +36,8 @@ public class ConstraintCheck extends Constraint {
}
}
@Override
@Override
public
String
getConstraintType
()
{
public
Type
getConstraintType
()
{
return
Constraint
.
CHECK
;
return
Constraint
.
Type
.
CHECK
;
}
}
public
void
setTableFilter
(
TableFilter
filter
)
{
public
void
setTableFilter
(
TableFilter
filter
)
{
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
a674f921
...
@@ -50,8 +50,8 @@ public class ConstraintReferential extends Constraint {
...
@@ -50,8 +50,8 @@ public class ConstraintReferential extends Constraint {
}
}
@Override
@Override
public
String
getConstraintType
()
{
public
Type
getConstraintType
()
{
return
Constraint
.
REFERENTIAL
;
return
Constraint
.
Type
.
REFERENTIAL
;
}
}
private
static
void
appendAction
(
StatementBuilder
buff
,
ConstraintActionType
action
)
{
private
static
void
appendAction
(
StatementBuilder
buff
,
ConstraintActionType
action
)
{
...
...
h2/src/main/org/h2/constraint/ConstraintUnique.java
浏览文件 @
a674f921
...
@@ -34,8 +34,8 @@ public class ConstraintUnique extends Constraint {
...
@@ -34,8 +34,8 @@ public class ConstraintUnique extends Constraint {
}
}
@Override
@Override
public
String
getConstraintType
()
{
public
Type
getConstraintType
()
{
return
primaryKey
?
Constraint
.
PRIMARY_KEY
:
Constraint
.
UNIQUE
;
return
primaryKey
?
Constraint
.
Type
.
PRIMARY_KEY
:
Constraint
.
Type
.
UNIQUE
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
a674f921
...
@@ -467,7 +467,7 @@ public class MVTable extends TableBase {
...
@@ -467,7 +467,7 @@ public class MVTable extends TableBase {
if
(
constraints
!=
null
)
{
if
(
constraints
!=
null
)
{
for
(
int
i
=
0
,
size
=
constraints
.
size
();
i
<
size
;
i
++)
{
for
(
int
i
=
0
,
size
=
constraints
.
size
();
i
<
size
;
i
++)
{
Constraint
c
=
constraints
.
get
(
i
);
Constraint
c
=
constraints
.
get
(
i
);
if
(
!(
c
.
getConstraintType
().
equals
(
Constraint
.
REFERENTIAL
))
)
{
if
(
c
.
getConstraintType
()
!=
Constraint
.
Type
.
REFERENTIAL
)
{
continue
;
continue
;
}
}
ConstraintReferential
ref
=
(
ConstraintReferential
)
c
;
ConstraintReferential
ref
=
(
ConstraintReferential
)
c
;
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
a674f921
...
@@ -868,8 +868,7 @@ public class MetaTable extends Table {
...
@@ -868,8 +868,7 @@ public class MetaTable extends Table {
Constraint
constraint
=
constraints
.
get
(
k
);
Constraint
constraint
=
constraints
.
get
(
k
);
if
(
constraint
.
usesIndex
(
index
))
{
if
(
constraint
.
usesIndex
(
index
))
{
if
(
index
.
getIndexType
().
isPrimaryKey
())
{
if
(
index
.
getIndexType
().
isPrimaryKey
())
{
if
(
constraint
.
getConstraintType
().
equals
(
if
(
constraint
.
getConstraintType
()
==
Constraint
.
Type
.
PRIMARY_KEY
)
{
Constraint
.
PRIMARY_KEY
))
{
constraintName
=
constraint
.
getName
();
constraintName
=
constraint
.
getName
();
}
}
}
else
{
}
else
{
...
@@ -1544,7 +1543,7 @@ public class MetaTable extends Table {
...
@@ -1544,7 +1543,7 @@ public class MetaTable extends Table {
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
))
{
DbObject
.
CONSTRAINT
))
{
Constraint
constraint
=
(
Constraint
)
obj
;
Constraint
constraint
=
(
Constraint
)
obj
;
if
(
!(
constraint
.
getConstraintType
().
equals
(
Constraint
.
REFERENTIAL
))
)
{
if
(
constraint
.
getConstraintType
()
!=
Constraint
.
Type
.
REFERENTIAL
)
{
continue
;
continue
;
}
}
ConstraintReferential
ref
=
(
ConstraintReferential
)
constraint
;
ConstraintReferential
ref
=
(
ConstraintReferential
)
constraint
;
...
@@ -1597,7 +1596,7 @@ public class MetaTable extends Table {
...
@@ -1597,7 +1596,7 @@ public class MetaTable extends Table {
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
))
{
DbObject
.
CONSTRAINT
))
{
Constraint
constraint
=
(
Constraint
)
obj
;
Constraint
constraint
=
(
Constraint
)
obj
;
String
constraintType
=
constraint
.
getConstraintType
();
Constraint
.
Type
constraintType
=
constraint
.
getConstraintType
();
String
checkExpression
=
null
;
String
checkExpression
=
null
;
IndexColumn
[]
indexColumns
=
null
;
IndexColumn
[]
indexColumns
=
null
;
Table
table
=
constraint
.
getTable
();
Table
table
=
constraint
.
getTable
();
...
@@ -1613,12 +1612,12 @@ public class MetaTable extends Table {
...
@@ -1613,12 +1612,12 @@ public class MetaTable extends Table {
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
continue
;
}
}
if
(
constraintType
.
equals
(
Constraint
.
CHECK
)
)
{
if
(
constraintType
==
Constraint
.
Type
.
CHECK
)
{
checkExpression
=
((
ConstraintCheck
)
constraint
).
getExpression
().
getSQL
();
checkExpression
=
((
ConstraintCheck
)
constraint
).
getExpression
().
getSQL
();
}
else
if
(
constraintType
.
equals
(
Constraint
.
UNIQUE
)
||
}
else
if
(
constraintType
==
Constraint
.
Type
.
UNIQUE
||
constraintType
.
equals
(
Constraint
.
PRIMARY_KEY
)
)
{
constraintType
==
Constraint
.
Type
.
PRIMARY_KEY
)
{
indexColumns
=
((
ConstraintUnique
)
constraint
).
getColumns
();
indexColumns
=
((
ConstraintUnique
)
constraint
).
getColumns
();
}
else
if
(
constraintType
.
equals
(
Constraint
.
REFERENTIAL
)
)
{
}
else
if
(
constraintType
==
Constraint
.
Type
.
REFERENTIAL
)
{
indexColumns
=
((
ConstraintReferential
)
constraint
).
getColumns
();
indexColumns
=
((
ConstraintReferential
)
constraint
).
getColumns
();
}
}
String
columnList
=
null
;
String
columnList
=
null
;
...
@@ -1638,7 +1637,7 @@ public class MetaTable extends Table {
...
@@ -1638,7 +1637,7 @@ public class MetaTable extends Table {
// CONSTRAINT_NAME
// CONSTRAINT_NAME
identifier
(
constraint
.
getName
()),
identifier
(
constraint
.
getName
()),
// CONSTRAINT_TYPE
// CONSTRAINT_TYPE
constraintType
,
constraintType
.
toString
()
,
// TABLE_CATALOG
// TABLE_CATALOG
catalog
,
catalog
,
// TABLE_SCHEMA
// TABLE_SCHEMA
...
...
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
a674f921
...
@@ -746,7 +746,7 @@ public class RegularTable extends TableBase {
...
@@ -746,7 +746,7 @@ public class RegularTable extends TableBase {
if
(
constraints
!=
null
)
{
if
(
constraints
!=
null
)
{
for
(
int
i
=
0
,
size
=
constraints
.
size
();
i
<
size
;
i
++)
{
for
(
int
i
=
0
,
size
=
constraints
.
size
();
i
<
size
;
i
++)
{
Constraint
c
=
constraints
.
get
(
i
);
Constraint
c
=
constraints
.
get
(
i
);
if
(
!(
c
.
getConstraintType
().
equals
(
Constraint
.
REFERENTIAL
))
)
{
if
(
c
.
getConstraintType
()
!=
Constraint
.
Type
.
REFERENTIAL
)
{
continue
;
continue
;
}
}
ConstraintReferential
ref
=
(
ConstraintReferential
)
c
;
ConstraintReferential
ref
=
(
ConstraintReferential
)
c
;
...
...
h2/src/main/org/h2/tools/Backup.java
浏览文件 @
a674f921
...
@@ -128,47 +128,47 @@ public class Backup extends Tool {
...
@@ -128,47 +128,47 @@ public class Backup extends Tool {
OutputStream
fileOut
=
null
;
OutputStream
fileOut
=
null
;
try
{
try
{
fileOut
=
FileUtils
.
newOutputStream
(
zipFileName
,
false
);
fileOut
=
FileUtils
.
newOutputStream
(
zipFileName
,
false
);
ZipOutputStream
zipOut
=
new
ZipOutputStream
(
fileOut
);
try
(
ZipOutputStream
zipOut
=
new
ZipOutputStream
(
fileOut
))
{
String
base
=
""
;
String
base
=
""
;
for
(
String
fileName
:
list
)
{
for
(
String
fileName
:
list
)
{
if
(
allFiles
||
if
(
allFiles
||
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
)
||
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
)
||
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
base
=
FileUtils
.
getParent
(
fileName
);
base
=
FileUtils
.
getParent
(
fileName
);
break
;
break
;
}
}
}
}
for
(
String
fileName
:
list
)
{
for
(
String
fileName
:
list
)
{
String
f
=
FileUtils
.
toRealPath
(
fileName
);
String
f
=
FileUtils
.
toRealPath
(
fileName
);
if
(!
f
.
startsWith
(
base
))
{
if
(!
f
.
startsWith
(
base
))
{
DbException
.
throwInternalError
(
f
+
" does not start with "
+
base
);
DbException
.
throwInternalError
(
f
+
" does not start with "
+
base
);
}
}
if
(
f
.
endsWith
(
zipFileName
))
{
if
(
f
.
endsWith
(
zipFileName
))
{
continue
;
continue
;
}
}
if
(
FileUtils
.
isDirectory
(
fileName
))
{
if
(
FileUtils
.
isDirectory
(
fileName
))
{
continue
;
continue
;
}
}
f
=
f
.
substring
(
base
.
length
());
f
=
f
.
substring
(
base
.
length
()
);
f
=
BackupCommand
.
correctFileName
(
f
);
f
=
BackupCommand
.
correctFileName
(
f
);
ZipEntry
entry
=
new
ZipEntry
(
f
);
ZipEntry
entry
=
new
ZipEntry
(
f
);
zipOut
.
putNextEntry
(
entry
);
zipOut
.
putNextEntry
(
entry
)
;
InputStream
in
=
null
;
InputStream
in
=
null
;
try
{
try
{
in
=
FileUtils
.
newInputStream
(
fileName
);
in
=
FileUtils
.
newInputStream
(
fileName
);
IOUtils
.
copyAndCloseInput
(
in
,
zipOut
);
IOUtils
.
copyAndCloseInput
(
in
,
zipOut
);
}
catch
(
FileNotFoundException
e
)
{
}
catch
(
FileNotFoundException
e
)
{
// the file could have been deleted in the meantime
// the file could have been deleted in the meantime
// ignore this (in this case an empty file is created)
// ignore this (in this case an empty file is created)
}
finally
{
}
finally
{
IOUtils
.
closeSilently
(
in
);
IOUtils
.
closeSilently
(
in
);
}
}
zipOut
.
closeEntry
();
zipOut
.
closeEntry
();
if
(!
quiet
)
{
if
(!
quiet
)
{
out
.
println
(
"Processed: "
+
fileName
);
out
.
println
(
"Processed: "
+
fileName
);
}
}
}
}
}
zipOut
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
zipFileName
);
throw
DbException
.
convertIOException
(
e
,
zipFileName
);
}
finally
{
}
finally
{
...
...
h2/src/main/org/h2/tools/ChangeFileEncryption.java
浏览文件 @
a674f921
...
@@ -220,46 +220,40 @@ public class ChangeFileEncryption extends Tool {
...
@@ -220,46 +220,40 @@ public class ChangeFileEncryption extends Tool {
if
(
FileUtils
.
isDirectory
(
fileName
))
{
if
(
FileUtils
.
isDirectory
(
fileName
))
{
return
;
return
;
}
}
FileChannel
fileIn
=
FilePath
.
get
(
fileName
).
open
(
"r"
);
FileChannel
fileOut
=
null
;
String
temp
=
directory
+
"/temp.db"
;
String
temp
=
directory
+
"/temp.db"
;
try
{
try
(
FileChannel
fileIn
=
getFileChannel
(
fileName
,
"r"
,
decryptKey
)){
if
(
decryptKey
!=
null
)
{
try
(
InputStream
inStream
=
new
FileChannelInputStream
(
fileIn
,
true
))
{
fileIn
=
new
FilePathEncrypt
.
FileEncrypt
(
fileName
,
decryptKey
,
fileIn
);
FileUtils
.
delete
(
temp
);
}
try
(
OutputStream
outStream
=
new
FileChannelOutputStream
(
getFileChannel
(
temp
,
"rw"
,
encryptKey
),
true
))
{
InputStream
inStream
=
new
FileChannelInputStream
(
fileIn
,
true
);
byte
[]
buffer
=
new
byte
[
4
*
1024
];
FileUtils
.
delete
(
temp
);
long
remaining
=
fileIn
.
size
();
fileOut
=
FilePath
.
get
(
temp
).
open
(
"rw"
);
long
total
=
remaining
;
if
(
encryptKey
!=
null
)
{
long
time
=
System
.
nanoTime
();
fileOut
=
new
FilePathEncrypt
.
FileEncrypt
(
temp
,
encryptKey
,
fileOut
);
while
(
remaining
>
0
)
{
}
if
(!
quiet
&&
System
.
nanoTime
()
-
time
>
TimeUnit
.
SECONDS
.
toNanos
(
1
))
{
OutputStream
outStream
=
new
FileChannelOutputStream
(
fileOut
,
true
);
out
.
println
(
fileName
+
": "
+
(
100
-
100
*
remaining
/
total
)
+
"%"
);
byte
[]
buffer
=
new
byte
[
4
*
1024
];
time
=
System
.
nanoTime
();
long
remaining
=
fileIn
.
size
();
}
long
total
=
remaining
;
int
len
=
(
int
)
Math
.
min
(
buffer
.
length
,
remaining
);
long
time
=
System
.
nanoTime
();
len
=
inStream
.
read
(
buffer
,
0
,
len
);
while
(
remaining
>
0
)
{
outStream
.
write
(
buffer
,
0
,
len
);
if
(!
quiet
&&
System
.
nanoTime
()
-
time
>
TimeUnit
.
SECONDS
.
toNanos
(
1
))
{
remaining
-=
len
;
out
.
println
(
fileName
+
": "
+
(
100
-
100
*
remaining
/
total
)
+
"%"
);
}
time
=
System
.
nanoTime
();
}
}
int
len
=
(
int
)
Math
.
min
(
buffer
.
length
,
remaining
);
len
=
inStream
.
read
(
buffer
,
0
,
len
);
outStream
.
write
(
buffer
,
0
,
len
);
remaining
-=
len
;
}
inStream
.
close
();
outStream
.
close
();
}
finally
{
fileIn
.
close
();
if
(
fileOut
!=
null
)
{
fileOut
.
close
();
}
}
}
}
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
FileUtils
.
move
(
temp
,
fileName
);
FileUtils
.
move
(
temp
,
fileName
);
}
}
private
FileChannel
getFileChannel
(
String
fileName
,
String
r
,
byte
[]
decryptKey
)
throws
IOException
{
FileChannel
fileIn
=
FilePath
.
get
(
fileName
).
open
(
r
);
if
(
decryptKey
!=
null
)
{
fileIn
=
new
FilePathEncrypt
.
FileEncrypt
(
fileName
,
decryptKey
,
fileIn
);
}
return
fileIn
;
}
private
void
copy
(
String
fileName
,
FileStore
in
,
byte
[]
key
,
boolean
quiet
)
{
private
void
copy
(
String
fileName
,
FileStore
in
,
byte
[]
key
,
boolean
quiet
)
{
if
(
FileUtils
.
isDirectory
(
fileName
))
{
if
(
FileUtils
.
isDirectory
(
fileName
))
{
return
;
return
;
...
...
h2/src/main/org/h2/tools/Restore.java
浏览文件 @
a674f921
...
@@ -155,41 +155,41 @@ public class Restore extends Tool {
...
@@ -155,41 +155,41 @@ public class Restore extends Tool {
originalDbLen
=
originalDbName
.
length
();
originalDbLen
=
originalDbName
.
length
();
}
}
in
=
FileUtils
.
newInputStream
(
zipFileName
);
in
=
FileUtils
.
newInputStream
(
zipFileName
);
ZipInputStream
zipIn
=
new
ZipInputStream
(
in
);
try
(
ZipInputStream
zipIn
=
new
ZipInputStream
(
in
))
{
while
(
true
)
{
while
(
true
)
{
ZipEntry
entry
=
zipIn
.
getNextEntry
();
ZipEntry
entry
=
zipIn
.
getNextEntry
();
if
(
entry
==
null
)
{
if
(
entry
==
null
)
{
break
;
break
;
}
}
String
fileName
=
entry
.
getName
();
String
fileName
=
entry
.
getName
();
// restoring windows backups on linux and vice versa
// restoring windows backups on linux and vice versa
fileName
=
fileName
.
replace
(
'\\'
,
SysProperties
.
FILE_SEPARATOR
.
charAt
(
0
));
fileName
=
fileName
.
replace
(
'\\'
,
SysProperties
.
FILE_SEPARATOR
.
charAt
(
0
));
fileName
=
fileName
.
replace
(
'/'
,
SysProperties
.
FILE_SEPARATOR
.
charAt
(
0
));
fileName
=
fileName
.
replace
(
'/'
,
SysProperties
.
FILE_SEPARATOR
.
charAt
(
0
));
if
(
fileName
.
startsWith
(
SysProperties
.
FILE_SEPARATOR
))
{
if
(
fileName
.
startsWith
(
SysProperties
.
FILE_SEPARATOR
))
{
fileName
=
fileName
.
substring
(
1
);
fileName
=
fileName
.
substring
(
1
);
}
boolean
copy
=
false
;
if
(
db
==
null
)
{
copy
=
true
;
}
else
if
(
fileName
.
startsWith
(
originalDbName
+
"."
))
{
fileName
=
db
+
fileName
.
substring
(
originalDbLen
);
copy
=
true
;
}
if
(
copy
)
{
OutputStream
o
=
null
;
try
{
o
=
FileUtils
.
newOutputStream
(
directory
+
SysProperties
.
FILE_SEPARATOR
+
fileName
,
false
);
IOUtils
.
copy
(
zipIn
,
o
);
o
.
close
();
}
finally
{
IOUtils
.
closeSilently
(
o
);
}
}
boolean
copy
=
false
;
if
(
db
==
null
)
{
copy
=
true
;
}
else
if
(
fileName
.
startsWith
(
originalDbName
+
"."
))
{
fileName
=
db
+
fileName
.
substring
(
originalDbLen
);
copy
=
true
;
}
if
(
copy
)
{
OutputStream
o
=
null
;
try
{
o
=
FileUtils
.
newOutputStream
(
directory
+
SysProperties
.
FILE_SEPARATOR
+
fileName
,
false
);
IOUtils
.
copy
(
zipIn
,
o
);
o
.
close
();
}
finally
{
IOUtils
.
closeSilently
(
o
);
}
}
zipIn
.
closeEntry
();
}
}
zipIn
.
closeEntry
();
zipIn
.
closeEntry
();
}
}
zipIn
.
closeEntry
();
zipIn
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
zipFileName
);
throw
DbException
.
convertIOException
(
e
,
zipFileName
);
}
finally
{
}
finally
{
...
...
h2/src/main/org/h2/util/Profiler.java
浏览文件 @
a674f921
...
@@ -167,25 +167,21 @@ public class Profiler implements Runnable {
...
@@ -167,25 +167,21 @@ public class Profiler implements Runnable {
continue
;
continue
;
}
}
String
file
=
arg
;
String
file
=
arg
;
Reader
reader
;
try
(
Reader
reader
=
new
InputStreamReader
(
new
FileInputStream
(
file
),
"CP1252"
))
{
LineNumberReader
r
;
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
reader
=
new
InputStreamReader
(
while
(
true
)
{
new
FileInputStream
(
file
),
"CP1252"
);
String
line
=
r
.
readLine
();
r
=
new
LineNumberReader
(
reader
);
if
(
line
==
null
)
{
while
(
true
)
{
break
;
String
line
=
r
.
readLine
();
}
else
if
(
line
.
startsWith
(
"Full thread dump"
))
{
if
(
line
==
null
)
{
threadDumps
++;
break
;
}
}
else
if
(
line
.
startsWith
(
"Full thread dump"
))
{
threadDumps
++;
}
}
}
}
reader
.
close
();
try
(
Reader
reader
=
new
InputStreamReader
(
new
FileInputStream
(
file
),
"CP1252"
))
{
reader
=
new
InputStreamReader
(
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
new
FileInputStream
(
file
),
"CP1252"
);
processList
(
readStackTrace
(
r
));
r
=
new
LineNumberReader
(
reader
);
}
processList
(
readStackTrace
(
r
));
reader
.
close
();
}
}
System
.
out
.
println
(
getTopTraces
(
5
));
System
.
out
.
println
(
getTopTraces
(
5
));
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
h2/src/main/org/h2/util/SortedProperties.java
浏览文件 @
a674f921
...
@@ -112,17 +112,17 @@ public class SortedProperties extends Properties {
...
@@ -112,17 +112,17 @@ public class SortedProperties extends Properties {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
IOException
(
e
.
toString
(),
e
);
throw
new
IOException
(
e
.
toString
(),
e
);
}
}
PrintWriter
writer
=
new
PrintWriter
(
new
BufferedWriter
(
w
));
try
(
PrintWriter
writer
=
new
PrintWriter
(
new
BufferedWriter
(
w
)))
{
while
(
true
)
{
while
(
true
)
{
String
line
=
r
.
readLine
();
String
line
=
r
.
readLine
();
if
(
line
==
null
)
{
if
(
line
==
null
)
{
break
;
break
;
}
}
if
(!
line
.
startsWith
(
"#"
))
{
if
(!
line
.
startsWith
(
"#"
))
{
writer
.
print
(
line
+
"\n"
);
writer
.
print
(
line
+
"\n"
);
}
}
}
}
}
writer
.
close
();
}
}
/**
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论