Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6ab81676
提交
6ab81676
authored
3月 30, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Local variable declaration hides another field or variable.
上级
893cca19
显示空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
161 行增加
和
166 行删除
+161
-166
Parser.java
h2/src/main/org/h2/command/Parser.java
+4
-4
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+7
-7
BackupCommand.java
h2/src/main/org/h2/command/dml/BackupCommand.java
+3
-3
Query.java
h2/src/main/org/h2/command/dml/Query.java
+11
-11
ScriptBase.java
h2/src/main/org/h2/command/dml/ScriptBase.java
+18
-18
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+12
-12
Select.java
h2/src/main/org/h2/command/dml/Select.java
+21
-21
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+17
-17
ConstraintCheck.java
h2/src/main/org/h2/constraint/ConstraintCheck.java
+2
-2
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+15
-15
ConstraintUnique.java
h2/src/main/org/h2/constraint/ConstraintUnique.java
+5
-5
Constants.java
h2/src/main/org/h2/engine/Constants.java
+2
-7
Database.java
h2/src/main/org/h2/engine/Database.java
+10
-10
DbObjectBase.java
h2/src/main/org/h2/engine/DbObjectBase.java
+7
-7
Session.java
h2/src/main/org/h2/engine/Session.java
+9
-9
AggregateData.java
h2/src/main/org/h2/expression/AggregateData.java
+3
-3
CompareLike.java
h2/src/main/org/h2/expression/CompareLike.java
+7
-7
Comparison.java
h2/src/main/org/h2/expression/Comparison.java
+5
-5
ConditionAndOr.java
h2/src/main/org/h2/expression/ConditionAndOr.java
+3
-3
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
6ab81676
...
@@ -825,8 +825,8 @@ public class Parser {
...
@@ -825,8 +825,8 @@ public class Parser {
return
prepare
(
session
,
buff
.
toString
(),
paramValues
);
return
prepare
(
session
,
buff
.
toString
(),
paramValues
);
}
}
private
Prepared
prepare
(
Session
s
ession
,
String
sql
,
ObjectArray
paramValues
)
throws
SQLException
{
private
Prepared
prepare
(
Session
s
,
String
sql
,
ObjectArray
paramValues
)
throws
SQLException
{
Prepared
prep
=
s
ession
.
prepare
(
sql
);
Prepared
prep
=
s
.
prepare
(
sql
);
ObjectArray
params
=
prep
.
getParameters
();
ObjectArray
params
=
prep
.
getParameters
();
for
(
int
i
=
0
;
params
!=
null
&&
i
<
params
.
size
();
i
++)
{
for
(
int
i
=
0
;
params
!=
null
&&
i
<
params
.
size
();
i
++)
{
Parameter
p
=
(
Parameter
)
params
.
get
(
i
);
Parameter
p
=
(
Parameter
)
params
.
get
(
i
);
...
@@ -4177,7 +4177,7 @@ public class Parser {
...
@@ -4177,7 +4177,7 @@ public class Parser {
private
RunScriptCommand
parseRunScript
()
throws
SQLException
{
private
RunScriptCommand
parseRunScript
()
throws
SQLException
{
RunScriptCommand
command
=
new
RunScriptCommand
(
session
);
RunScriptCommand
command
=
new
RunScriptCommand
(
session
);
read
(
"FROM"
);
read
(
"FROM"
);
command
.
setFile
(
readExpression
());
command
.
setFile
NameExpr
(
readExpression
());
if
(
readIf
(
"COMPRESSION"
))
{
if
(
readIf
(
"COMPRESSION"
))
{
command
.
setCompressionAlgorithm
(
readUniqueIdentifier
());
command
.
setCompressionAlgorithm
(
readUniqueIdentifier
());
}
}
...
@@ -4221,7 +4221,7 @@ public class Parser {
...
@@ -4221,7 +4221,7 @@ public class Parser {
command
.
setDrop
(
dropTables
);
command
.
setDrop
(
dropTables
);
command
.
setSimple
(
simple
);
command
.
setSimple
(
simple
);
if
(
readIf
(
"TO"
))
{
if
(
readIf
(
"TO"
))
{
command
.
setFile
(
readExpression
());
command
.
setFile
NameExpr
(
readExpression
());
if
(
readIf
(
"COMPRESSION"
))
{
if
(
readIf
(
"COMPRESSION"
))
{
command
.
setCompressionAlgorithm
(
readUniqueIdentifier
());
command
.
setCompressionAlgorithm
(
readUniqueIdentifier
());
}
}
...
...
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
6ab81676
...
@@ -299,9 +299,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
...
@@ -299,9 +299,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
private
Index
getIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
private
Index
getIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
ObjectArray
list
=
t
.
getIndexes
();
ObjectArray
list
=
t
.
getIndexes
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Index
id
x
=
(
Index
)
list
.
get
(
i
);
Index
existingInde
x
=
(
Index
)
list
.
get
(
i
);
if
(
canUseIndex
(
id
x
,
t
,
cols
))
{
if
(
canUseIndex
(
existingInde
x
,
t
,
cols
))
{
return
id
x
;
return
existingInde
x
;
}
}
}
}
return
null
;
return
null
;
...
@@ -329,12 +329,12 @@ public class AlterTableAddConstraint extends SchemaCommand {
...
@@ -329,12 +329,12 @@ public class AlterTableAddConstraint extends SchemaCommand {
return
true
;
return
true
;
}
}
private
boolean
canUseIndex
(
Index
i
ndex
,
Table
table
,
IndexColumn
[]
cols
)
{
private
boolean
canUseIndex
(
Index
existingI
ndex
,
Table
table
,
IndexColumn
[]
cols
)
{
if
(
index
.
getTable
()
!=
table
||
i
ndex
.
getCreateSQL
()
==
null
)
{
if
(
existingIndex
.
getTable
()
!=
table
||
existingI
ndex
.
getCreateSQL
()
==
null
)
{
// can't use the scan index or index of another table
// can't use the scan index or index of another table
return
false
;
return
false
;
}
}
Column
[]
indexCols
=
i
ndex
.
getColumns
();
Column
[]
indexCols
=
existingI
ndex
.
getColumns
();
if
(
indexCols
.
length
<
cols
.
length
)
{
if
(
indexCols
.
length
<
cols
.
length
)
{
return
false
;
return
false
;
}
}
...
@@ -343,7 +343,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
...
@@ -343,7 +343,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
// but not all columns of the index need to be part of the list
// but not all columns of the index need to be part of the list
// holes are not allowed (index=a,b,c & list=a,b is ok; but list=a,c
// holes are not allowed (index=a,b,c & list=a,b is ok; but list=a,c
// is not)
// is not)
int
idx
=
i
ndex
.
getColumnIndex
(
cols
[
j
].
column
);
int
idx
=
existingI
ndex
.
getColumnIndex
(
cols
[
j
].
column
);
if
(
idx
<
0
||
idx
>=
cols
.
length
)
{
if
(
idx
<
0
||
idx
>=
cols
.
length
)
{
return
false
;
return
false
;
}
}
...
...
h2/src/main/org/h2/command/dml/BackupCommand.java
浏览文件 @
6ab81676
...
@@ -39,18 +39,18 @@ import org.h2.util.ObjectArray;
...
@@ -39,18 +39,18 @@ import org.h2.util.ObjectArray;
*/
*/
public
class
BackupCommand
extends
Prepared
{
public
class
BackupCommand
extends
Prepared
{
private
Expression
fileName
;
private
Expression
fileName
Expr
;
public
BackupCommand
(
Session
session
)
{
public
BackupCommand
(
Session
session
)
{
super
(
session
);
super
(
session
);
}
}
public
void
setFileName
(
Expression
fileName
)
{
public
void
setFileName
(
Expression
fileName
)
{
this
.
fileName
=
fileName
;
this
.
fileName
Expr
=
fileName
;
}
}
public
int
update
()
throws
SQLException
{
public
int
update
()
throws
SQLException
{
String
name
=
fileName
.
getValue
(
session
).
getString
();
String
name
=
fileName
Expr
.
getValue
(
session
).
getString
();
session
.
getUser
().
checkAdmin
();
session
.
getUser
().
checkAdmin
();
backupTo
(
name
);
backupTo
(
name
);
return
0
;
return
0
;
...
...
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
6ab81676
...
@@ -38,12 +38,12 @@ public abstract class Query extends Prepared {
...
@@ -38,12 +38,12 @@ public abstract class Query extends Prepared {
/**
/**
* The limit expression as specified in the LIMIT or TOP clause.
* The limit expression as specified in the LIMIT or TOP clause.
*/
*/
protected
Expression
limit
;
protected
Expression
limit
Expr
;
/**
/**
* The offset expression as specified in the LIMIT .. OFFSET clause.
* The offset expression as specified in the LIMIT .. OFFSET clause.
*/
*/
protected
Expression
offset
;
protected
Expression
offset
Expr
;
/**
/**
* The sample size
* The sample size
...
@@ -154,10 +154,10 @@ public abstract class Query extends Prepared {
...
@@ -154,10 +154,10 @@ public abstract class Query extends Prepared {
* Get the alias (or column name) of the first column.
* Get the alias (or column name) of the first column.
* This is used to convert IN(SELECT ...) queries to inner joins.
* This is used to convert IN(SELECT ...) queries to inner joins.
*
*
* @param s
ession
the session
* @param s the session
* @return the alias or column name
* @return the alias or column name
*/
*/
public
abstract
String
getFirstColumnAlias
(
Session
s
ession
);
public
abstract
String
getFirstColumnAlias
(
Session
s
);
/**
/**
* Check if this expression and all sub-expressions can fulfill a criteria.
* Check if this expression and all sub-expressions can fulfill a criteria.
...
@@ -171,9 +171,9 @@ public abstract class Query extends Prepared {
...
@@ -171,9 +171,9 @@ public abstract class Query extends Prepared {
/**
/**
* Update all aggregate function values.
* Update all aggregate function values.
*
*
* @param s
ession
the session
* @param s the session
*/
*/
public
abstract
void
updateAggregate
(
Session
s
ession
)
throws
SQLException
;
public
abstract
void
updateAggregate
(
Session
s
)
throws
SQLException
;
public
boolean
isQuery
()
{
public
boolean
isQuery
()
{
return
true
;
return
true
;
...
@@ -183,9 +183,9 @@ public abstract class Query extends Prepared {
...
@@ -183,9 +183,9 @@ public abstract class Query extends Prepared {
return
true
;
return
true
;
}
}
private
boolean
sameResultAsLast
(
Session
s
ession
,
Value
[]
params
,
Value
[]
lastParams
,
long
lastEvaluated
)
private
boolean
sameResultAsLast
(
Session
s
,
Value
[]
params
,
Value
[]
lastParams
,
long
lastEval
)
throws
SQLException
{
throws
SQLException
{
Database
db
=
s
ession
.
getDatabase
();
Database
db
=
s
.
getDatabase
();
for
(
int
i
=
0
;
i
<
params
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
params
.
length
;
i
++)
{
if
(!
db
.
areEqual
(
lastParams
[
i
],
params
[
i
]))
{
if
(!
db
.
areEqual
(
lastParams
[
i
],
params
[
i
]))
{
return
false
;
return
false
;
...
@@ -194,7 +194,7 @@ public abstract class Query extends Prepared {
...
@@ -194,7 +194,7 @@ public abstract class Query extends Prepared {
if
(!
isEverything
(
ExpressionVisitor
.
DETERMINISTIC
)
||
!
isEverything
(
ExpressionVisitor
.
INDEPENDENT
))
{
if
(!
isEverything
(
ExpressionVisitor
.
DETERMINISTIC
)
||
!
isEverything
(
ExpressionVisitor
.
INDEPENDENT
))
{
return
false
;
return
false
;
}
}
if
(
db
.
getModificationDataId
()
>
lastEval
uated
&&
getMaxDataModificationId
()
>
lastEvaluated
)
{
if
(
db
.
getModificationDataId
()
>
lastEval
&&
getMaxDataModificationId
()
>
lastEval
)
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -376,11 +376,11 @@ public abstract class Query extends Prepared {
...
@@ -376,11 +376,11 @@ public abstract class Query extends Prepared {
}
}
public
void
setOffset
(
Expression
offset
)
{
public
void
setOffset
(
Expression
offset
)
{
this
.
offset
=
offset
;
this
.
offset
Expr
=
offset
;
}
}
public
void
setLimit
(
Expression
limit
)
{
public
void
setLimit
(
Expression
limit
)
{
this
.
limit
=
limit
;
this
.
limit
Expr
=
limit
;
}
}
/**
/**
...
...
h2/src/main/org/h2/command/dml/ScriptBase.java
浏览文件 @
6ab81676
...
@@ -52,7 +52,7 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
...
@@ -52,7 +52,7 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
/**
/**
* The file name (if set).
* The file name (if set).
*/
*/
private
Expression
file
;
private
Expression
file
NameExpr
;
private
String
fileName
;
private
String
fileName
;
private
String
cipher
;
private
String
cipher
;
...
@@ -77,13 +77,13 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
...
@@ -77,13 +77,13 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
key
=
sha
.
getKeyPasswordHash
(
"script"
,
password
);
key
=
sha
.
getKeyPasswordHash
(
"script"
,
password
);
}
}
public
void
setFile
(
Expression
file
)
{
public
void
setFile
NameExpr
(
Expression
file
)
{
this
.
file
=
file
;
this
.
file
NameExpr
=
file
;
}
}
protected
String
getFileName
()
throws
SQLException
{
protected
String
getFileName
()
throws
SQLException
{
if
(
file
!=
null
&&
fileName
==
null
)
{
if
(
file
NameExpr
!=
null
&&
fileName
==
null
)
{
fileName
=
file
.
optimize
(
session
).
getValue
(
session
).
getString
();
fileName
=
file
NameExpr
.
optimize
(
session
).
getValue
(
session
).
getString
();
if
(
fileName
==
null
||
fileName
.
trim
().
length
()
==
0
)
{
if
(
fileName
==
null
||
fileName
.
trim
().
length
()
==
0
)
{
fileName
=
"script.sql"
;
fileName
=
"script.sql"
;
}
}
...
@@ -100,17 +100,17 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
...
@@ -100,17 +100,17 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
* Delete the target file.
* Delete the target file.
*/
*/
void
deleteStore
()
throws
SQLException
{
void
deleteStore
()
throws
SQLException
{
String
file
Name
=
getFileName
();
String
file
=
getFileName
();
if
(
file
Name
!=
null
)
{
if
(
file
!=
null
)
{
FileUtils
.
delete
(
file
Name
);
FileUtils
.
delete
(
file
);
}
}
}
}
private
void
initStore
()
throws
SQLException
{
private
void
initStore
()
throws
SQLException
{
Database
db
=
session
.
getDatabase
();
Database
db
=
session
.
getDatabase
();
// script files are always in text format
// script files are always in text format
String
file
Name
=
getFileName
();
String
file
=
getFileName
();
store
=
FileStore
.
open
(
db
,
file
Name
,
"rw"
,
cipher
,
key
);
store
=
FileStore
.
open
(
db
,
file
,
"rw"
,
cipher
,
key
);
store
.
setCheckedWriting
(
false
);
store
.
setCheckedWriting
(
false
);
store
.
init
();
store
.
init
();
}
}
...
@@ -119,8 +119,8 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
...
@@ -119,8 +119,8 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
* Open the output stream.
* Open the output stream.
*/
*/
void
openOutput
()
throws
SQLException
{
void
openOutput
()
throws
SQLException
{
String
file
Name
=
getFileName
();
String
file
=
getFileName
();
if
(
file
Name
==
null
)
{
if
(
file
==
null
)
{
return
;
return
;
}
}
if
(
isEncrypted
())
{
if
(
isEncrypted
())
{
...
@@ -129,7 +129,7 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
...
@@ -129,7 +129,7 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
// always use a big buffer, otherwise end-of-block is written a lot
// always use a big buffer, otherwise end-of-block is written a lot
out
=
new
BufferedOutputStream
(
out
,
Constants
.
IO_BUFFER_SIZE_COMPRESS
);
out
=
new
BufferedOutputStream
(
out
,
Constants
.
IO_BUFFER_SIZE_COMPRESS
);
}
else
{
}
else
{
OutputStream
o
=
FileUtils
.
openFileOutputStream
(
file
Name
,
false
);
OutputStream
o
=
FileUtils
.
openFileOutputStream
(
file
,
false
);
out
=
new
BufferedOutputStream
(
o
,
Constants
.
IO_BUFFER_SIZE
);
out
=
new
BufferedOutputStream
(
o
,
Constants
.
IO_BUFFER_SIZE
);
out
=
CompressTool
.
wrapOutputStream
(
out
,
compressionAlgorithm
,
Constants
.
SCRIPT_SQL
);
out
=
CompressTool
.
wrapOutputStream
(
out
,
compressionAlgorithm
,
Constants
.
SCRIPT_SQL
);
}
}
...
@@ -139,8 +139,8 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
...
@@ -139,8 +139,8 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
* Open the input stream.
* Open the input stream.
*/
*/
void
openInput
()
throws
SQLException
{
void
openInput
()
throws
SQLException
{
String
file
Name
=
getFileName
();
String
file
=
getFileName
();
if
(
file
Name
==
null
)
{
if
(
file
==
null
)
{
return
;
return
;
}
}
if
(
isEncrypted
())
{
if
(
isEncrypted
())
{
...
@@ -149,14 +149,14 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
...
@@ -149,14 +149,14 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
}
else
{
}
else
{
InputStream
inStream
;
InputStream
inStream
;
try
{
try
{
inStream
=
FileUtils
.
openFileInputStream
(
file
Name
);
inStream
=
FileUtils
.
openFileInputStream
(
file
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
Message
.
convertIOException
(
e
,
file
Name
);
throw
Message
.
convertIOException
(
e
,
file
);
}
}
in
=
new
BufferedInputStream
(
inStream
,
Constants
.
IO_BUFFER_SIZE
);
in
=
new
BufferedInputStream
(
inStream
,
Constants
.
IO_BUFFER_SIZE
);
in
=
CompressTool
.
wrapInputStream
(
in
,
compressionAlgorithm
,
Constants
.
SCRIPT_SQL
);
in
=
CompressTool
.
wrapInputStream
(
in
,
compressionAlgorithm
,
Constants
.
SCRIPT_SQL
);
if
(
in
==
null
)
{
if
(
in
==
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
FILE_NOT_FOUND_1
,
Constants
.
SCRIPT_SQL
+
" in "
+
file
Name
);
throw
Message
.
getSQLException
(
ErrorCode
.
FILE_NOT_FOUND_1
,
Constants
.
SCRIPT_SQL
+
" in "
+
file
);
}
}
}
}
}
}
...
...
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
6ab81676
...
@@ -102,9 +102,9 @@ public class ScriptCommand extends ScriptBase {
...
@@ -102,9 +102,9 @@ public class ScriptCommand extends ScriptBase {
}
}
public
LocalResult
queryMeta
()
throws
SQLException
{
public
LocalResult
queryMeta
()
throws
SQLException
{
LocalResult
r
esult
=
createResult
();
LocalResult
r
=
createResult
();
r
esult
.
done
();
r
.
done
();
return
r
esult
;
return
r
;
}
}
private
LocalResult
createResult
()
{
private
LocalResult
createResult
()
{
...
@@ -125,9 +125,9 @@ public class ScriptCommand extends ScriptBase {
...
@@ -125,9 +125,9 @@ public class ScriptCommand extends ScriptBase {
}
}
Database
db
=
session
.
getDatabase
();
Database
db
=
session
.
getDatabase
();
if
(
settings
)
{
if
(
settings
)
{
ObjectArray
setting
s
=
db
.
getAllSettings
();
ObjectArray
setting
List
=
db
.
getAllSettings
();
for
(
int
i
=
0
;
i
<
setting
s
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
setting
List
.
size
();
i
++)
{
Setting
setting
=
(
Setting
)
setting
s
.
get
(
i
);
Setting
setting
=
(
Setting
)
setting
List
.
get
(
i
);
if
(
setting
.
getName
().
equals
(
SetTypes
.
getTypeName
(
SetTypes
.
CREATE_BUILD
)))
{
if
(
setting
.
getName
().
equals
(
SetTypes
.
getTypeName
(
SetTypes
.
CREATE_BUILD
)))
{
// don't add CREATE_BUILD to the script
// don't add CREATE_BUILD to the script
// (it is only set when creating the database)
// (it is only set when creating the database)
...
@@ -356,12 +356,12 @@ public class ScriptCommand extends ScriptBase {
...
@@ -356,12 +356,12 @@ public class ScriptCommand extends ScriptBase {
switch
(
v
.
getType
())
{
switch
(
v
.
getType
())
{
case
Value
.
BLOB
:
{
case
Value
.
BLOB
:
{
byte
[]
bytes
=
new
byte
[
lobBlockSize
];
byte
[]
bytes
=
new
byte
[
lobBlockSize
];
InputStream
in
=
v
.
getInputStream
();
InputStream
in
put
=
v
.
getInputStream
();
try
{
try
{
for
(
int
i
=
0
;;
i
++)
{
for
(
int
i
=
0
;;
i
++)
{
StringBuffer
buff
=
new
StringBuffer
(
lobBlockSize
*
2
);
StringBuffer
buff
=
new
StringBuffer
(
lobBlockSize
*
2
);
buff
.
append
(
"INSERT INTO SYSTEM_LOB_STREAM VALUES("
+
id
+
", "
+
i
+
", NULL, '"
);
buff
.
append
(
"INSERT INTO SYSTEM_LOB_STREAM VALUES("
+
id
+
", "
+
i
+
", NULL, '"
);
int
len
=
IOUtils
.
readFully
(
in
,
bytes
,
0
,
lobBlockSize
);
int
len
=
IOUtils
.
readFully
(
in
put
,
bytes
,
0
,
lobBlockSize
);
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
break
;
break
;
}
}
...
@@ -371,18 +371,18 @@ public class ScriptCommand extends ScriptBase {
...
@@ -371,18 +371,18 @@ public class ScriptCommand extends ScriptBase {
add
(
sql
,
true
);
add
(
sql
,
true
);
}
}
}
finally
{
}
finally
{
IOUtils
.
closeSilently
(
in
);
IOUtils
.
closeSilently
(
in
put
);
}
}
break
;
break
;
}
}
case
Value
.
CLOB
:
{
case
Value
.
CLOB
:
{
char
[]
chars
=
new
char
[
lobBlockSize
];
char
[]
chars
=
new
char
[
lobBlockSize
];
Reader
in
=
v
.
getReader
();
Reader
reader
=
v
.
getReader
();
try
{
try
{
for
(
int
i
=
0
;;
i
++)
{
for
(
int
i
=
0
;;
i
++)
{
StringBuffer
buff
=
new
StringBuffer
(
lobBlockSize
*
2
);
StringBuffer
buff
=
new
StringBuffer
(
lobBlockSize
*
2
);
buff
.
append
(
"INSERT INTO SYSTEM_LOB_STREAM VALUES("
+
id
+
", "
+
i
+
", "
);
buff
.
append
(
"INSERT INTO SYSTEM_LOB_STREAM VALUES("
+
id
+
", "
+
i
+
", "
);
int
len
=
IOUtils
.
readFully
(
in
,
chars
,
lobBlockSize
);
int
len
=
IOUtils
.
readFully
(
reader
,
chars
,
lobBlockSize
);
if
(
len
<
0
)
{
if
(
len
<
0
)
{
break
;
break
;
}
}
...
@@ -392,7 +392,7 @@ public class ScriptCommand extends ScriptBase {
...
@@ -392,7 +392,7 @@ public class ScriptCommand extends ScriptBase {
add
(
sql
,
true
);
add
(
sql
,
true
);
}
}
}
finally
{
}
finally
{
IOUtils
.
closeSilently
(
in
);
IOUtils
.
closeSilently
(
reader
);
}
}
break
;
break
;
}
}
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
6ab81676
...
@@ -444,10 +444,10 @@ public class Select extends Query {
...
@@ -444,10 +444,10 @@ public class Select extends Query {
}
}
private
void
queryDistinct
(
LocalResult
result
,
long
limitRows
)
throws
SQLException
{
private
void
queryDistinct
(
LocalResult
result
,
long
limitRows
)
throws
SQLException
{
if
(
limitRows
!=
0
&&
offset
!=
null
)
{
if
(
limitRows
!=
0
&&
offset
Expr
!=
null
)
{
// limitRows must be long, otherwise we get an int overflow
// limitRows must be long, otherwise we get an int overflow
// if limitRows is at or near Integer.MAX_VALUE
// if limitRows is at or near Integer.MAX_VALUE
limitRows
+=
offset
.
getValue
(
session
).
getInt
();
limitRows
+=
offset
Expr
.
getValue
(
session
).
getInt
();
}
}
int
rowNumber
=
0
;
int
rowNumber
=
0
;
setCurrentRowNumber
(
0
);
setCurrentRowNumber
(
0
);
...
@@ -481,10 +481,10 @@ public class Select extends Query {
...
@@ -481,10 +481,10 @@ public class Select extends Query {
}
}
private
void
queryFlat
(
int
columnCount
,
LocalResult
result
,
long
limitRows
)
throws
SQLException
{
private
void
queryFlat
(
int
columnCount
,
LocalResult
result
,
long
limitRows
)
throws
SQLException
{
if
(
limitRows
!=
0
&&
offset
!=
null
)
{
if
(
limitRows
!=
0
&&
offset
Expr
!=
null
)
{
// limitRows must be long, otherwise we get an int overflow
// limitRows must be long, otherwise we get an int overflow
// if limitRows is at or near Integer.MAX_VALUE
// if limitRows is at or near Integer.MAX_VALUE
limitRows
+=
offset
.
getValue
(
session
).
getInt
();
limitRows
+=
offset
Expr
.
getValue
(
session
).
getInt
();
}
}
int
rowNumber
=
0
;
int
rowNumber
=
0
;
setCurrentRowNumber
(
0
);
setCurrentRowNumber
(
0
);
...
@@ -526,8 +526,8 @@ public class Select extends Query {
...
@@ -526,8 +526,8 @@ public class Select extends Query {
protected
LocalResult
queryWithoutCache
(
int
maxRows
)
throws
SQLException
{
protected
LocalResult
queryWithoutCache
(
int
maxRows
)
throws
SQLException
{
int
limitRows
=
maxRows
;
int
limitRows
=
maxRows
;
if
(
limit
!=
null
)
{
if
(
limit
Expr
!=
null
)
{
int
l
=
limit
.
getValue
(
session
).
getInt
();
int
l
=
limit
Expr
.
getValue
(
session
).
getInt
();
if
(
limitRows
==
0
)
{
if
(
limitRows
==
0
)
{
limitRows
=
l
;
limitRows
=
l
;
}
else
{
}
else
{
...
@@ -558,8 +558,8 @@ public class Select extends Query {
...
@@ -558,8 +558,8 @@ public class Select extends Query {
}
else
{
}
else
{
queryFlat
(
columnCount
,
result
,
limitRows
);
queryFlat
(
columnCount
,
result
,
limitRows
);
}
}
if
(
offset
!=
null
)
{
if
(
offset
Expr
!=
null
)
{
result
.
setOffset
(
offset
.
getValue
(
session
).
getInt
());
result
.
setOffset
(
offset
Expr
.
getValue
(
session
).
getInt
());
}
}
if
(
limitRows
!=
0
)
{
if
(
limitRows
!=
0
)
{
result
.
setLimit
(
limitRows
);
result
.
setLimit
(
limitRows
);
...
@@ -810,7 +810,7 @@ public class Select extends Query {
...
@@ -810,7 +810,7 @@ public class Select extends Query {
Optimizer
optimizer
=
new
Optimizer
(
topArray
,
condition
,
session
);
Optimizer
optimizer
=
new
Optimizer
(
topArray
,
condition
,
session
);
optimizer
.
optimize
();
optimizer
.
optimize
();
topTableFilter
=
optimizer
.
getTopFilter
();
topTableFilter
=
optimizer
.
getTopFilter
();
double
c
ost
=
optimizer
.
getCost
();
double
planC
ost
=
optimizer
.
getCost
();
TableFilter
f
=
topTableFilter
;
TableFilter
f
=
topTableFilter
;
while
(
f
!=
null
)
{
while
(
f
!=
null
)
{
...
@@ -849,7 +849,7 @@ public class Select extends Query {
...
@@ -849,7 +849,7 @@ public class Select extends Query {
f
=
f
.
getJoin
();
f
=
f
.
getJoin
();
}
}
topTableFilter
.
prepare
();
topTableFilter
.
prepare
();
return
c
ost
;
return
planC
ost
;
}
}
public
String
getPlanSQL
()
{
public
String
getPlanSQL
()
{
...
@@ -939,12 +939,12 @@ public class Select extends Query {
...
@@ -939,12 +939,12 @@ public class Select extends Query {
buff
.
append
(
StringUtils
.
unEnclose
(
o
.
getSQL
()));
buff
.
append
(
StringUtils
.
unEnclose
(
o
.
getSQL
()));
}
}
}
}
if
(
limit
!=
null
)
{
if
(
limit
Expr
!=
null
)
{
buff
.
append
(
"\nLIMIT "
);
buff
.
append
(
"\nLIMIT "
);
buff
.
append
(
StringUtils
.
unEnclose
(
limit
.
getSQL
()));
buff
.
append
(
StringUtils
.
unEnclose
(
limit
Expr
.
getSQL
()));
if
(
offset
!=
null
)
{
if
(
offset
Expr
!=
null
)
{
buff
.
append
(
" OFFSET "
);
buff
.
append
(
" OFFSET "
);
buff
.
append
(
StringUtils
.
unEnclose
(
offset
.
getSQL
()));
buff
.
append
(
StringUtils
.
unEnclose
(
offset
Expr
.
getSQL
()));
}
}
}
}
if
(
isForUpdate
)
{
if
(
isForUpdate
)
{
...
@@ -1057,16 +1057,16 @@ public class Select extends Query {
...
@@ -1057,16 +1057,16 @@ public class Select extends Query {
}
}
}
}
public
void
updateAggregate
(
Session
s
ession
)
throws
SQLException
{
public
void
updateAggregate
(
Session
s
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
expressions
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
expressions
.
size
();
i
++)
{
Expression
e
=
(
Expression
)
expressions
.
get
(
i
);
Expression
e
=
(
Expression
)
expressions
.
get
(
i
);
e
.
updateAggregate
(
s
ession
);
e
.
updateAggregate
(
s
);
}
}
if
(
condition
!=
null
)
{
if
(
condition
!=
null
)
{
condition
.
updateAggregate
(
s
ession
);
condition
.
updateAggregate
(
s
);
}
}
if
(
having
!=
null
)
{
if
(
having
!=
null
)
{
having
.
updateAggregate
(
s
ession
);
having
.
updateAggregate
(
s
);
}
}
}
}
...
@@ -1120,7 +1120,7 @@ public class Select extends Query {
...
@@ -1120,7 +1120,7 @@ public class Select extends Query {
return
isEverything
(
ExpressionVisitor
.
READONLY
);
return
isEverything
(
ExpressionVisitor
.
READONLY
);
}
}
public
String
getFirstColumnAlias
(
Session
s
ession
)
{
public
String
getFirstColumnAlias
(
Session
s
)
{
if
(
SysProperties
.
CHECK
)
{
if
(
SysProperties
.
CHECK
)
{
if
(
visibleColumnCount
>
1
)
{
if
(
visibleColumnCount
>
1
)
{
Message
.
throwInternalError
(
""
+
visibleColumnCount
);
Message
.
throwInternalError
(
""
+
visibleColumnCount
);
...
@@ -1130,8 +1130,8 @@ public class Select extends Query {
...
@@ -1130,8 +1130,8 @@ public class Select extends Query {
if
(
expr
instanceof
Alias
)
{
if
(
expr
instanceof
Alias
)
{
return
expr
.
getAlias
();
return
expr
.
getAlias
();
}
}
Mode
mode
=
s
ession
.
getDatabase
().
getMode
();
Mode
mode
=
s
.
getDatabase
().
getMode
();
String
name
=
s
ession
.
getNextSystemIdentifier
(
getSQL
());
String
name
=
s
.
getNextSystemIdentifier
(
getSQL
());
expr
=
new
Alias
(
expr
,
name
,
mode
.
aliasColumnName
);
expr
=
new
Alias
(
expr
,
name
,
mode
.
aliasColumnName
);
expressions
.
set
(
0
,
expr
);
expressions
.
set
(
0
,
expr
);
return
expr
.
getAlias
();
return
expr
.
getAlias
();
...
...
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
6ab81676
...
@@ -92,19 +92,19 @@ public class SelectUnion extends Query {
...
@@ -92,19 +92,19 @@ public class SelectUnion extends Query {
}
}
public
LocalResult
queryMeta
()
throws
SQLException
{
public
LocalResult
queryMeta
()
throws
SQLException
{
ObjectArray
e
xpressions
=
left
.
getExpressions
();
ObjectArray
leftE
xpressions
=
left
.
getExpressions
();
int
columnCount
=
left
.
getColumnCount
();
int
columnCount
=
left
.
getColumnCount
();
LocalResult
result
=
new
LocalResult
(
session
,
e
xpressions
,
columnCount
);
LocalResult
result
=
new
LocalResult
(
session
,
leftE
xpressions
,
columnCount
);
result
.
done
();
result
.
done
();
return
result
;
return
result
;
}
}
protected
LocalResult
queryWithoutCache
(
int
maxrows
)
throws
SQLException
{
protected
LocalResult
queryWithoutCache
(
int
maxrows
)
throws
SQLException
{
if
(
maxrows
!=
0
)
{
if
(
maxrows
!=
0
)
{
if
(
limit
!=
null
)
{
if
(
limit
Expr
!=
null
)
{
maxrows
=
Math
.
min
(
limit
.
getValue
(
session
).
getInt
(),
maxrows
);
maxrows
=
Math
.
min
(
limit
Expr
.
getValue
(
session
).
getInt
(),
maxrows
);
}
}
limit
=
ValueExpression
.
get
(
ValueInt
.
get
(
maxrows
));
limit
Expr
=
ValueExpression
.
get
(
ValueInt
.
get
(
maxrows
));
}
}
int
columnCount
=
left
.
getColumnCount
();
int
columnCount
=
left
.
getColumnCount
();
LocalResult
result
=
new
LocalResult
(
session
,
expressions
,
columnCount
);
LocalResult
result
=
new
LocalResult
(
session
,
expressions
,
columnCount
);
...
@@ -171,11 +171,11 @@ public class SelectUnion extends Query {
...
@@ -171,11 +171,11 @@ public class SelectUnion extends Query {
default
:
default
:
Message
.
throwInternalError
(
"type="
+
unionType
);
Message
.
throwInternalError
(
"type="
+
unionType
);
}
}
if
(
offset
!=
null
)
{
if
(
offset
Expr
!=
null
)
{
result
.
setOffset
(
offset
.
getValue
(
session
).
getInt
());
result
.
setOffset
(
offset
Expr
.
getValue
(
session
).
getInt
());
}
}
if
(
limit
!=
null
)
{
if
(
limit
Expr
!=
null
)
{
result
.
setLimit
(
limit
.
getValue
(
session
).
getInt
());
result
.
setLimit
(
limit
Expr
.
getValue
(
session
).
getInt
());
}
}
result
.
done
();
result
.
done
();
return
result
;
return
result
;
...
@@ -323,12 +323,12 @@ public class SelectUnion extends Query {
...
@@ -323,12 +323,12 @@ public class SelectUnion extends Query {
buff
.
append
(
" ORDER BY "
);
buff
.
append
(
" ORDER BY "
);
buff
.
append
(
sort
.
getSQL
(
exprList
,
exprList
.
length
));
buff
.
append
(
sort
.
getSQL
(
exprList
,
exprList
.
length
));
}
}
if
(
limit
!=
null
)
{
if
(
limit
Expr
!=
null
)
{
buff
.
append
(
" LIMIT "
);
buff
.
append
(
" LIMIT "
);
buff
.
append
(
StringUtils
.
unEnclose
(
limit
.
getSQL
()));
buff
.
append
(
StringUtils
.
unEnclose
(
limit
Expr
.
getSQL
()));
if
(
offset
!=
null
)
{
if
(
offset
Expr
!=
null
)
{
buff
.
append
(
" OFFSET "
);
buff
.
append
(
" OFFSET "
);
buff
.
append
(
StringUtils
.
unEnclose
(
offset
.
getSQL
()));
buff
.
append
(
StringUtils
.
unEnclose
(
offset
Expr
.
getSQL
()));
}
}
}
}
if
(
isForUpdate
)
{
if
(
isForUpdate
)
{
...
@@ -350,12 +350,12 @@ public class SelectUnion extends Query {
...
@@ -350,12 +350,12 @@ public class SelectUnion extends Query {
return
left
.
isReadOnly
()
&&
right
.
isReadOnly
();
return
left
.
isReadOnly
()
&&
right
.
isReadOnly
();
}
}
public
void
updateAggregate
(
Session
s
ession
)
throws
SQLException
{
public
void
updateAggregate
(
Session
s
)
throws
SQLException
{
left
.
updateAggregate
(
s
ession
);
left
.
updateAggregate
(
s
);
right
.
updateAggregate
(
s
ession
);
right
.
updateAggregate
(
s
);
}
}
public
String
getFirstColumnAlias
(
Session
s
ession
)
{
public
String
getFirstColumnAlias
(
Session
s
)
{
return
null
;
return
null
;
}
}
...
...
h2/src/main/org/h2/constraint/ConstraintCheck.java
浏览文件 @
6ab81676
...
@@ -45,10 +45,10 @@ public class ConstraintCheck extends Constraint {
...
@@ -45,10 +45,10 @@ public class ConstraintCheck extends Constraint {
this
.
expr
=
expr
;
this
.
expr
=
expr
;
}
}
public
String
getCreateSQLForCopy
(
Table
t
able
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
forT
able
,
String
quotedName
)
{
StringBuffer
buff
=
new
StringBuffer
();
StringBuffer
buff
=
new
StringBuffer
();
buff
.
append
(
"ALTER TABLE "
);
buff
.
append
(
"ALTER TABLE "
);
buff
.
append
(
t
able
.
getSQL
());
buff
.
append
(
forT
able
.
getSQL
());
buff
.
append
(
" ADD CONSTRAINT "
);
buff
.
append
(
" ADD CONSTRAINT "
);
buff
.
append
(
quotedName
);
buff
.
append
(
quotedName
);
if
(
comment
!=
null
)
{
if
(
comment
!=
null
)
{
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
6ab81676
...
@@ -93,27 +93,27 @@ public class ConstraintReferential extends Constraint {
...
@@ -93,27 +93,27 @@ public class ConstraintReferential extends Constraint {
/**
/**
* Create the SQL statement of this object so a copy of the table can be made.
* Create the SQL statement of this object so a copy of the table can be made.
*
*
* @param
t
able the table to create the object for
* @param
forT
able the table to create the object for
* @param quotedName the name of this object (quoted if necessary)
* @param quotedName the name of this object (quoted if necessary)
* @return the SQL statement
* @return the SQL statement
*/
*/
public
String
getCreateSQLForCopy
(
Table
t
able
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
forT
able
,
String
quotedName
)
{
return
getCreateSQLForCopy
(
t
able
,
refTable
,
quotedName
,
true
);
return
getCreateSQLForCopy
(
forT
able
,
refTable
,
quotedName
,
true
);
}
}
/**
/**
* Create the SQL statement of this object so a copy of the table can be made.
* Create the SQL statement of this object so a copy of the table can be made.
*
*
* @param
t
able the table to create the object for
* @param
forT
able the table to create the object for
* @param
r
efTable the referenced table
* @param
forR
efTable the referenced table
* @param quotedName the name of this object (quoted if necessary)
* @param quotedName the name of this object (quoted if necessary)
* @param internalIndex add the index name to the statement
* @param internalIndex add the index name to the statement
* @return the SQL statement
* @return the SQL statement
*/
*/
public
String
getCreateSQLForCopy
(
Table
table
,
Table
r
efTable
,
String
quotedName
,
boolean
internalIndex
)
{
public
String
getCreateSQLForCopy
(
Table
forTable
,
Table
forR
efTable
,
String
quotedName
,
boolean
internalIndex
)
{
StringBuffer
buff
=
new
StringBuffer
();
StringBuffer
buff
=
new
StringBuffer
();
buff
.
append
(
"ALTER TABLE "
);
buff
.
append
(
"ALTER TABLE "
);
String
mainTable
=
t
able
.
getSQL
();
String
mainTable
=
forT
able
.
getSQL
();
buff
.
append
(
mainTable
);
buff
.
append
(
mainTable
);
buff
.
append
(
" ADD CONSTRAINT "
);
buff
.
append
(
" ADD CONSTRAINT "
);
buff
.
append
(
quotedName
);
buff
.
append
(
quotedName
);
...
@@ -131,7 +131,7 @@ public class ConstraintReferential extends Constraint {
...
@@ -131,7 +131,7 @@ public class ConstraintReferential extends Constraint {
buff
.
append
(
cols
[
i
].
getSQL
());
buff
.
append
(
cols
[
i
].
getSQL
());
}
}
buff
.
append
(
")"
);
buff
.
append
(
")"
);
if
(
internalIndex
&&
indexOwner
&&
t
able
==
this
.
table
)
{
if
(
internalIndex
&&
indexOwner
&&
forT
able
==
this
.
table
)
{
buff
.
append
(
" INDEX "
);
buff
.
append
(
" INDEX "
);
buff
.
append
(
index
.
getSQL
());
buff
.
append
(
index
.
getSQL
());
}
}
...
@@ -139,9 +139,9 @@ public class ConstraintReferential extends Constraint {
...
@@ -139,9 +139,9 @@ public class ConstraintReferential extends Constraint {
String
quotedRefTable
;
String
quotedRefTable
;
if
(
this
.
table
==
this
.
refTable
)
{
if
(
this
.
table
==
this
.
refTable
)
{
// self-referencing constraints: need to use new table
// self-referencing constraints: need to use new table
quotedRefTable
=
t
able
.
getSQL
();
quotedRefTable
=
forT
able
.
getSQL
();
}
else
{
}
else
{
quotedRefTable
=
r
efTable
.
getSQL
();
quotedRefTable
=
forR
efTable
.
getSQL
();
}
}
buff
.
append
(
quotedRefTable
);
buff
.
append
(
quotedRefTable
);
buff
.
append
(
"("
);
buff
.
append
(
"("
);
...
@@ -152,7 +152,7 @@ public class ConstraintReferential extends Constraint {
...
@@ -152,7 +152,7 @@ public class ConstraintReferential extends Constraint {
buff
.
append
(
refCols
[
i
].
getSQL
());
buff
.
append
(
refCols
[
i
].
getSQL
());
}
}
buff
.
append
(
")"
);
buff
.
append
(
")"
);
if
(
internalIndex
&&
refIndexOwner
&&
t
able
==
this
.
table
)
{
if
(
internalIndex
&&
refIndexOwner
&&
forT
able
==
this
.
table
)
{
buff
.
append
(
" INDEX "
);
buff
.
append
(
" INDEX "
);
buff
.
append
(
refIndex
.
getSQL
());
buff
.
append
(
refIndex
.
getSQL
());
}
}
...
@@ -349,16 +349,16 @@ public class ConstraintReferential extends Constraint {
...
@@ -349,16 +349,16 @@ public class ConstraintReferential extends Constraint {
}
}
}
}
private
boolean
found
(
Session
session
,
Index
i
ndex
,
SearchRow
check
,
Row
excluding
)
throws
SQLException
{
private
boolean
found
(
Session
session
,
Index
searchI
ndex
,
SearchRow
check
,
Row
excluding
)
throws
SQLException
{
i
ndex
.
getTable
().
lock
(
session
,
false
,
false
);
searchI
ndex
.
getTable
().
lock
(
session
,
false
,
false
);
Cursor
cursor
=
i
ndex
.
find
(
session
,
check
,
check
);
Cursor
cursor
=
searchI
ndex
.
find
(
session
,
check
,
check
);
while
(
cursor
.
next
())
{
while
(
cursor
.
next
())
{
SearchRow
found
;
SearchRow
found
;
found
=
cursor
.
getSearchRow
();
found
=
cursor
.
getSearchRow
();
if
(
excluding
!=
null
&&
found
.
getPos
()
==
excluding
.
getPos
())
{
if
(
excluding
!=
null
&&
found
.
getPos
()
==
excluding
.
getPos
())
{
continue
;
continue
;
}
}
Column
[]
cols
=
i
ndex
.
getColumns
();
Column
[]
cols
=
searchI
ndex
.
getColumns
();
boolean
allEqual
=
true
;
boolean
allEqual
=
true
;
for
(
int
i
=
0
;
i
<
columns
.
length
&&
i
<
cols
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
columns
.
length
&&
i
<
cols
.
length
;
i
++)
{
int
idx
=
cols
[
i
].
getColumnId
();
int
idx
=
cols
[
i
].
getColumnId
();
...
...
h2/src/main/org/h2/constraint/ConstraintUnique.java
浏览文件 @
6ab81676
...
@@ -37,14 +37,14 @@ public class ConstraintUnique extends Constraint {
...
@@ -37,14 +37,14 @@ public class ConstraintUnique extends Constraint {
return
primaryKey
?
Constraint
.
PRIMARY_KEY
:
Constraint
.
UNIQUE
;
return
primaryKey
?
Constraint
.
PRIMARY_KEY
:
Constraint
.
UNIQUE
;
}
}
public
String
getCreateSQLForCopy
(
Table
t
able
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
forT
able
,
String
quotedName
)
{
return
getCreateSQLForCopy
(
t
able
,
quotedName
,
true
);
return
getCreateSQLForCopy
(
forT
able
,
quotedName
,
true
);
}
}
private
String
getCreateSQLForCopy
(
Table
t
able
,
String
quotedName
,
boolean
internalIndex
)
{
private
String
getCreateSQLForCopy
(
Table
forT
able
,
String
quotedName
,
boolean
internalIndex
)
{
StringBuffer
buff
=
new
StringBuffer
();
StringBuffer
buff
=
new
StringBuffer
();
buff
.
append
(
"ALTER TABLE "
);
buff
.
append
(
"ALTER TABLE "
);
buff
.
append
(
t
able
.
getSQL
());
buff
.
append
(
forT
able
.
getSQL
());
buff
.
append
(
" ADD CONSTRAINT "
);
buff
.
append
(
" ADD CONSTRAINT "
);
buff
.
append
(
quotedName
);
buff
.
append
(
quotedName
);
if
(
comment
!=
null
)
{
if
(
comment
!=
null
)
{
...
@@ -61,7 +61,7 @@ public class ConstraintUnique extends Constraint {
...
@@ -61,7 +61,7 @@ public class ConstraintUnique extends Constraint {
buff
.
append
(
Parser
.
quoteIdentifier
(
columns
[
i
].
column
.
getName
()));
buff
.
append
(
Parser
.
quoteIdentifier
(
columns
[
i
].
column
.
getName
()));
}
}
buff
.
append
(
')'
);
buff
.
append
(
')'
);
if
(
internalIndex
&&
indexOwner
&&
t
able
==
this
.
table
)
{
if
(
internalIndex
&&
indexOwner
&&
forT
able
==
this
.
table
)
{
buff
.
append
(
" INDEX "
);
buff
.
append
(
" INDEX "
);
buff
.
append
(
index
.
getSQL
());
buff
.
append
(
index
.
getSQL
());
}
}
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
6ab81676
...
@@ -158,11 +158,6 @@ public class Constants {
...
@@ -158,11 +158,6 @@ public class Constants {
*/
*/
public
static
final
char
DEFAULT_ESCAPE_CHAR
=
'\\'
;
public
static
final
char
DEFAULT_ESCAPE_CHAR
=
'\\'
;
/**
* The default port number of the FTP server.
*/
public
static
final
int
DEFAULT_FTP_PORT
=
8021
;
/**
/**
* If the HTTP server should allow connections from other computers by
* If the HTTP server should allow connections from other computers by
* default.
* default.
...
@@ -170,8 +165,8 @@ public class Constants {
...
@@ -170,8 +165,8 @@ public class Constants {
public
static
final
boolean
DEFAULT_HTTP_ALLOW_OTHERS
=
false
;
public
static
final
boolean
DEFAULT_HTTP_ALLOW_OTHERS
=
false
;
/**
/**
* The default port number of the HTTP server (for the H2 Console).
This
* The default port number of the HTTP server (for the H2 Console).
*
value is also in the documentation
.
*
This value is also in the documentation and in the Server javadoc
.
*/
*/
public
static
final
int
DEFAULT_HTTP_PORT
=
8082
;
public
static
final
int
DEFAULT_HTTP_PORT
=
8082
;
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
6ab81676
...
@@ -201,9 +201,9 @@ public class Database implements DataHandler {
...
@@ -201,9 +201,9 @@ public class Database implements DataHandler {
setEventListenerClass
(
listener
);
setEventListenerClass
(
listener
);
}
}
}
}
String
log
=
ci
.
getProperty
(
SetTypes
.
LOG
,
null
);
String
log
Setting
=
ci
.
getProperty
(
SetTypes
.
LOG
,
null
);
if
(
log
!=
null
)
{
if
(
log
Setting
!=
null
)
{
this
.
logIndexChanges
=
"2"
.
equals
(
log
);
this
.
logIndexChanges
=
"2"
.
equals
(
log
Setting
);
}
}
String
ignoreSummary
=
ci
.
getProperty
(
"RECOVER"
,
null
);
String
ignoreSummary
=
ci
.
getProperty
(
"RECOVER"
,
null
);
if
(
ignoreSummary
!=
null
)
{
if
(
ignoreSummary
!=
null
)
{
...
@@ -437,11 +437,11 @@ public class Database implements DataHandler {
...
@@ -437,11 +437,11 @@ public class Database implements DataHandler {
return
traceSystem
.
getTrace
(
module
);
return
traceSystem
.
getTrace
(
module
);
}
}
public
FileStore
openFile
(
String
name
,
String
m
ode
,
boolean
mustExist
)
throws
SQLException
{
public
FileStore
openFile
(
String
name
,
String
openM
ode
,
boolean
mustExist
)
throws
SQLException
{
if
(
mustExist
&&
!
FileUtils
.
exists
(
name
))
{
if
(
mustExist
&&
!
FileUtils
.
exists
(
name
))
{
throw
Message
.
getSQLException
(
ErrorCode
.
FILE_NOT_FOUND_1
,
name
);
throw
Message
.
getSQLException
(
ErrorCode
.
FILE_NOT_FOUND_1
,
name
);
}
}
FileStore
store
=
FileStore
.
open
(
this
,
name
,
m
ode
,
cipher
,
filePasswordHash
);
FileStore
store
=
FileStore
.
open
(
this
,
name
,
openM
ode
,
cipher
,
filePasswordHash
);
try
{
try
{
store
.
init
();
store
.
init
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
...
@@ -454,15 +454,15 @@ public class Database implements DataHandler {
...
@@ -454,15 +454,15 @@ public class Database implements DataHandler {
/**
/**
* Check if the file password hash is correct.
* Check if the file password hash is correct.
*
*
* @param
c
ipher the cipher algorithm
* @param
testC
ipher the cipher algorithm
* @param
h
ash the hash code
* @param
testH
ash the hash code
* @return true if the cipher algorithm and the password match
* @return true if the cipher algorithm and the password match
*/
*/
public
boolean
validateFilePasswordHash
(
String
cipher
,
byte
[]
h
ash
)
throws
SQLException
{
public
boolean
validateFilePasswordHash
(
String
testCipher
,
byte
[]
testH
ash
)
throws
SQLException
{
if
(!
StringUtils
.
equals
(
c
ipher
,
this
.
cipher
))
{
if
(!
StringUtils
.
equals
(
testC
ipher
,
this
.
cipher
))
{
return
false
;
return
false
;
}
}
return
ByteUtils
.
compareSecure
(
h
ash
,
filePasswordHash
);
return
ByteUtils
.
compareSecure
(
testH
ash
,
filePasswordHash
);
}
}
private
void
openFileData
()
throws
SQLException
{
private
void
openFileData
()
throws
SQLException
{
...
...
h2/src/main/org/h2/engine/DbObjectBase.java
浏览文件 @
6ab81676
...
@@ -42,17 +42,17 @@ public abstract class DbObjectBase implements DbObject {
...
@@ -42,17 +42,17 @@ public abstract class DbObjectBase implements DbObject {
/**
/**
* Initialize some attributes of this object.
* Initialize some attributes of this object.
*
*
* @param d
atabase
the database
* @param d
b
the database
* @param
i
d the object id
* @param
objectI
d the object id
* @param name the name
* @param name the name
* @param traceModule the trace module name
* @param traceModule the trace module name
*/
*/
protected
void
initDbObjectBase
(
Database
d
atabase
,
int
i
d
,
String
name
,
String
traceModule
)
{
protected
void
initDbObjectBase
(
Database
d
b
,
int
objectI
d
,
String
name
,
String
traceModule
)
{
this
.
database
=
d
atabase
;
this
.
database
=
d
b
;
this
.
trace
=
d
atabase
.
getTrace
(
traceModule
);
this
.
trace
=
d
b
.
getTrace
(
traceModule
);
this
.
id
=
i
d
;
this
.
id
=
objectI
d
;
this
.
objectName
=
name
;
this
.
objectName
=
name
;
this
.
modificationId
=
d
atabase
.
getModificationMetaId
();
this
.
modificationId
=
d
b
.
getModificationMetaId
();
}
}
/**
/**
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
6ab81676
...
@@ -531,8 +531,8 @@ public class Session extends SessionWithState {
...
@@ -531,8 +531,8 @@ public class Session extends SessionWithState {
savepoints
.
keySet
().
toArray
(
names
);
savepoints
.
keySet
().
toArray
(
names
);
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
String
name
=
names
[
i
];
String
name
=
names
[
i
];
Integer
id
=
(
Integer
)
savepoints
.
get
(
names
[
i
]);
Integer
savepointIndex
=
(
Integer
)
savepoints
.
get
(
names
[
i
]);
if
(
id
.
intValue
()
>
index
)
{
if
(
savepointIndex
.
intValue
()
>
index
)
{
savepoints
.
remove
(
name
);
savepoints
.
remove
(
name
);
}
}
}
}
...
@@ -749,11 +749,11 @@ public class Session extends SessionWithState {
...
@@ -749,11 +749,11 @@ public class Session extends SessionWithState {
if
(
savepoints
==
null
)
{
if
(
savepoints
==
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
SAVEPOINT_IS_INVALID_1
,
name
);
throw
Message
.
getSQLException
(
ErrorCode
.
SAVEPOINT_IS_INVALID_1
,
name
);
}
}
Integer
id
=
(
Integer
)
savepoints
.
get
(
name
);
Integer
savepointIndex
=
(
Integer
)
savepoints
.
get
(
name
);
if
(
id
==
null
)
{
if
(
savepointIndex
==
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
SAVEPOINT_IS_INVALID_1
,
name
);
throw
Message
.
getSQLException
(
ErrorCode
.
SAVEPOINT_IS_INVALID_1
,
name
);
}
}
int
i
=
id
.
intValue
();
int
i
=
savepointIndex
.
intValue
();
rollbackTo
(
i
,
false
);
rollbackTo
(
i
,
false
);
}
}
...
@@ -943,11 +943,11 @@ public class Session extends SessionWithState {
...
@@ -943,11 +943,11 @@ public class Session extends SessionWithState {
* @return the new identifier
* @return the new identifier
*/
*/
public
String
getNextSystemIdentifier
(
String
sql
)
{
public
String
getNextSystemIdentifier
(
String
sql
)
{
String
id
;
String
id
entifier
;
do
{
do
{
id
=
SYSTEM_IDENTIFIER_PREFIX
+
systemIdentifier
++;
id
entifier
=
SYSTEM_IDENTIFIER_PREFIX
+
systemIdentifier
++;
}
while
(
sql
.
indexOf
(
id
)
>=
0
);
}
while
(
sql
.
indexOf
(
id
entifier
)
>=
0
);
return
id
;
return
id
entifier
;
}
}
/**
/**
...
...
h2/src/main/org/h2/expression/AggregateData.java
浏览文件 @
6ab81676
...
@@ -229,12 +229,12 @@ class AggregateData {
...
@@ -229,12 +229,12 @@ class AggregateData {
return
v
==
null
?
ValueNull
.
INSTANCE
:
v
.
convertTo
(
dataType
);
return
v
==
null
?
ValueNull
.
INSTANCE
:
v
.
convertTo
(
dataType
);
}
}
private
Value
divide
(
Value
a
,
long
count
)
throws
SQLException
{
private
Value
divide
(
Value
a
,
long
by
)
throws
SQLException
{
if
(
count
==
0
)
{
if
(
by
==
0
)
{
return
ValueNull
.
INSTANCE
;
return
ValueNull
.
INSTANCE
;
}
}
int
type
=
Value
.
getHigherOrder
(
a
.
getType
(),
Value
.
LONG
);
int
type
=
Value
.
getHigherOrder
(
a
.
getType
(),
Value
.
LONG
);
Value
b
=
ValueLong
.
get
(
count
).
convertTo
(
type
);
Value
b
=
ValueLong
.
get
(
by
).
convertTo
(
type
);
a
=
a
.
convertTo
(
type
).
divide
(
b
);
a
=
a
.
convertTo
(
type
).
divide
(
b
);
return
a
;
return
a
;
}
}
...
...
h2/src/main/org/h2/expression/CompareLike.java
浏览文件 @
6ab81676
...
@@ -264,17 +264,17 @@ public class CompareLike extends Condition {
...
@@ -264,17 +264,17 @@ public class CompareLike extends Condition {
/**
/**
* Test if the value matches the pattern.
* Test if the value matches the pattern.
*
*
* @param
p
attern the pattern
* @param
testP
attern the pattern
* @param value the value
* @param value the value
* @param escape the escape character
* @param escape
Char
the escape character
* @return true if the value matches
* @return true if the value matches
*/
*/
public
boolean
test
(
String
pattern
,
String
value
,
char
escape
)
throws
SQLException
{
public
boolean
test
(
String
testPattern
,
String
value
,
char
escapeChar
)
throws
SQLException
{
initPattern
(
pattern
,
escape
);
initPattern
(
testPattern
,
escapeChar
);
return
compareAt
(
value
,
0
,
0
,
value
.
length
());
return
compareAt
(
value
,
0
,
0
,
value
.
length
());
}
}
private
void
initPattern
(
String
p
,
char
escape
)
throws
SQLException
{
private
void
initPattern
(
String
p
,
char
escape
Char
)
throws
SQLException
{
if
(
regexp
)
{
if
(
regexp
)
{
patternString
=
p
;
patternString
=
p
;
try
{
try
{
...
@@ -301,12 +301,12 @@ public class CompareLike extends Condition {
...
@@ -301,12 +301,12 @@ public class CompareLike extends Condition {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
c
=
p
.
charAt
(
i
);
char
c
=
p
.
charAt
(
i
);
int
type
;
int
type
;
if
(
escape
==
c
)
{
if
(
escape
Char
==
c
)
{
if
(
i
>=
len
-
1
)
{
if
(
i
>=
len
-
1
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
LIKE_ESCAPE_ERROR_1
,
StringUtils
.
addAsterisk
(
p
,
i
));
throw
Message
.
getSQLException
(
ErrorCode
.
LIKE_ESCAPE_ERROR_1
,
StringUtils
.
addAsterisk
(
p
,
i
));
}
}
c
=
p
.
charAt
(++
i
);
c
=
p
.
charAt
(++
i
);
if
(
c
!=
'_'
&&
c
!=
'%'
&&
c
!=
escape
)
{
if
(
c
!=
'_'
&&
c
!=
'%'
&&
c
!=
escape
Char
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
LIKE_ESCAPE_ERROR_1
,
StringUtils
.
addAsterisk
(
p
,
i
));
throw
Message
.
getSQLException
(
ErrorCode
.
LIKE_ESCAPE_ERROR_1
,
StringUtils
.
addAsterisk
(
p
,
i
));
}
}
type
=
MATCH
;
type
=
MATCH
;
...
...
h2/src/main/org/h2/expression/Comparison.java
浏览文件 @
6ab81676
...
@@ -117,14 +117,14 @@ public class Comparison extends Condition {
...
@@ -117,14 +117,14 @@ public class Comparison extends Condition {
return
"("
+
sql
+
")"
;
return
"("
+
sql
+
")"
;
}
}
private
Expression
getCast
(
Expression
expr
,
int
d
ataType
,
long
precision
,
int
scale
,
int
displaySize
,
Session
session
)
private
Expression
getCast
(
Expression
expr
,
int
targetD
ataType
,
long
precision
,
int
scale
,
int
displaySize
,
Session
session
)
throws
SQLException
{
throws
SQLException
{
if
(
expr
==
ValueExpression
.
getNull
())
{
if
(
expr
==
ValueExpression
.
getNull
())
{
return
expr
;
return
expr
;
}
}
Function
function
=
Function
.
getFunction
(
session
.
getDatabase
(),
"CAST"
);
Function
function
=
Function
.
getFunction
(
session
.
getDatabase
(),
"CAST"
);
function
.
setParameter
(
0
,
expr
);
function
.
setParameter
(
0
,
expr
);
function
.
setDataType
(
d
ataType
,
precision
,
scale
,
displaySize
);
function
.
setDataType
(
targetD
ataType
,
precision
,
scale
,
displaySize
);
function
.
doneWithParameters
();
function
.
doneWithParameters
();
return
function
.
optimize
(
session
);
return
function
.
optimize
(
session
);
}
}
...
@@ -448,12 +448,12 @@ public class Comparison extends Condition {
...
@@ -448,12 +448,12 @@ public class Comparison extends Condition {
/**
/**
* Get the left or the right sub-expression of this condition.
* Get the left or the right sub-expression of this condition.
*
*
* @param
l
eft true to get the left sub-expression, false to get the right
* @param
getL
eft true to get the left sub-expression, false to get the right
* sub-expression.
* sub-expression.
* @return the sub-expression
* @return the sub-expression
*/
*/
public
Expression
getExpression
(
boolean
l
eft
)
{
public
Expression
getExpression
(
boolean
getL
eft
)
{
return
l
eft
?
this
.
left
:
right
;
return
getL
eft
?
this
.
left
:
right
;
}
}
}
}
h2/src/main/org/h2/expression/ConditionAndOr.java
浏览文件 @
6ab81676
...
@@ -253,12 +253,12 @@ public class ConditionAndOr extends Condition {
...
@@ -253,12 +253,12 @@ public class ConditionAndOr extends Condition {
/**
/**
* Get the left or the right sub-expression of this condition.
* Get the left or the right sub-expression of this condition.
*
*
* @param
l
eft true to get the left sub-expression, false to get the right
* @param
getL
eft true to get the left sub-expression, false to get the right
* sub-expression.
* sub-expression.
* @return the sub-expression
* @return the sub-expression
*/
*/
public
Expression
getExpression
(
boolean
l
eft
)
{
public
Expression
getExpression
(
boolean
getL
eft
)
{
return
l
eft
?
this
.
left
:
right
;
return
getL
eft
?
this
.
left
:
right
;
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论