Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
95cd3025
提交
95cd3025
authored
11月 07, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add quoteIdentifier() variants with StringBuilder argument
上级
ace8433a
隐藏空白字符变更
内嵌
并排
正在显示
23 个修改的文件
包含
129 行增加
和
82 行删除
+129
-82
Parser.java
h2/src/main/org/h2/command/Parser.java
+18
-0
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+1
-1
Select.java
h2/src/main/org/h2/command/dml/Select.java
+2
-1
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+2
-2
ConstraintUnique.java
h2/src/main/org/h2/constraint/ConstraintUnique.java
+1
-1
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+2
-2
Alias.java
h2/src/main/org/h2/expression/Alias.java
+2
-1
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+15
-5
JavaFunction.java
h2/src/main/org/h2/expression/JavaFunction.java
+2
-4
Variable.java
h2/src/main/org/h2/expression/Variable.java
+2
-1
Wildcard.java
h2/src/main/org/h2/expression/Wildcard.java
+1
-1
JavaAggregate.java
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
+1
-1
FullText.java
h2/src/main/org/h2/fulltext/FullText.java
+6
-6
FullTextLucene.java
h2/src/main/org/h2/fulltext/FullTextLucene.java
+19
-16
UpdatableRow.java
h2/src/main/org/h2/result/UpdatableRow.java
+9
-9
TriggerObject.java
h2/src/main/org/h2/schema/TriggerObject.java
+2
-1
Column.java
h2/src/main/org/h2/table/Column.java
+1
-1
LinkSchema.java
h2/src/main/org/h2/table/LinkSchema.java
+11
-11
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+2
-2
TableBase.java
h2/src/main/org/h2/table/TableBase.java
+2
-2
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+5
-3
MultiDimension.java
h2/src/main/org/h2/tools/MultiDimension.java
+5
-4
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+18
-7
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
95cd3025
...
@@ -7718,6 +7718,24 @@ public class Parser {
...
@@ -7718,6 +7718,24 @@ public class Parser {
return
StringUtils
.
quoteIdentifier
(
s
);
return
StringUtils
.
quoteIdentifier
(
s
);
}
}
/**
* Add double quotes around an identifier if required and appends it to the
* specified string builder.
*
* @param builder string builder to append to
* @param s the identifier
* @return the specified builder
*/
public
static
StringBuilder
quoteIdentifier
(
StringBuilder
builder
,
String
s
)
{
if
(
s
==
null
)
{
return
builder
.
append
(
"\"\""
);
}
if
(
ParserUtil
.
isSimpleIdentifier
(
s
))
{
return
builder
.
append
(
s
);
}
return
StringUtils
.
quoteIdentifier
(
builder
,
s
);
}
public
void
setLiteralsChecked
(
boolean
literalsChecked
)
{
public
void
setLiteralsChecked
(
boolean
literalsChecked
)
{
this
.
literalsChecked
=
literalsChecked
;
this
.
literalsChecked
=
literalsChecked
;
}
}
...
...
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
95cd3025
...
@@ -392,7 +392,7 @@ public class ScriptCommand extends ScriptBase {
...
@@ -392,7 +392,7 @@ public class ScriptCommand extends ScriptBase {
buff
.
append
(
table
.
getSQL
()).
append
(
'('
);
buff
.
append
(
table
.
getSQL
()).
append
(
'('
);
for
(
Column
col
:
columns
)
{
for
(
Column
col
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
Parser
.
quoteIdentifier
(
col
.
getName
()
));
Parser
.
quoteIdentifier
(
buff
.
builder
(),
col
.
getName
(
));
}
}
buff
.
append
(
") VALUES"
);
buff
.
append
(
") VALUES"
);
if
(!
simple
)
{
if
(!
simple
)
{
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
95cd3025
...
@@ -1308,7 +1308,8 @@ public class Select extends Query {
...
@@ -1308,7 +1308,8 @@ public class Select extends Query {
// views.
// views.
}
else
{
}
else
{
buff
.
append
(
"WITH RECURSIVE "
)
buff
.
append
(
"WITH RECURSIVE "
)
.
append
(
t
.
getSchema
().
getSQL
()).
append
(
'.'
).
append
(
Parser
.
quoteIdentifier
(
t
.
getName
()))
.
append
(
t
.
getSchema
().
getSQL
()).
append
(
'.'
);
Parser
.
quoteIdentifier
(
buff
.
builder
(),
t
.
getName
())
.
append
(
'('
);
.
append
(
'('
);
buff
.
resetCount
();
buff
.
resetCount
();
for
(
Column
c
:
t
.
getColumns
())
{
for
(
Column
c
:
t
.
getColumns
())
{
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
95cd3025
...
@@ -568,7 +568,7 @@ public class ConstraintReferential extends Constraint {
...
@@ -568,7 +568,7 @@ public class ConstraintReferential extends Constraint {
buff
.
resetCount
();
buff
.
resetCount
();
for
(
IndexColumn
c
:
columns
)
{
for
(
IndexColumn
c
:
columns
)
{
buff
.
appendExceptFirst
(
" , "
);
buff
.
appendExceptFirst
(
" , "
);
buff
.
append
(
Parser
.
quoteIdentifier
(
c
.
column
.
getName
()
)).
append
(
"=?"
);
Parser
.
quoteIdentifier
(
buff
.
builder
(),
c
.
column
.
getName
(
)).
append
(
"=?"
);
}
}
}
}
...
@@ -577,7 +577,7 @@ public class ConstraintReferential extends Constraint {
...
@@ -577,7 +577,7 @@ public class ConstraintReferential extends Constraint {
buff
.
resetCount
();
buff
.
resetCount
();
for
(
IndexColumn
c
:
columns
)
{
for
(
IndexColumn
c
:
columns
)
{
buff
.
appendExceptFirst
(
" AND "
);
buff
.
appendExceptFirst
(
" AND "
);
buff
.
append
(
Parser
.
quoteIdentifier
(
c
.
column
.
getName
()
)).
append
(
"=?"
);
Parser
.
quoteIdentifier
(
buff
.
builder
(),
c
.
column
.
getName
(
)).
append
(
"=?"
);
}
}
}
}
...
...
h2/src/main/org/h2/constraint/ConstraintUnique.java
浏览文件 @
95cd3025
...
@@ -58,7 +58,7 @@ public class ConstraintUnique extends Constraint {
...
@@ -58,7 +58,7 @@ public class ConstraintUnique extends Constraint {
buff
.
append
(
' '
).
append
(
getConstraintType
().
getSqlName
()).
append
(
'('
);
buff
.
append
(
' '
).
append
(
getConstraintType
().
getSqlName
()).
append
(
'('
);
for
(
IndexColumn
c
:
columns
)
{
for
(
IndexColumn
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
Parser
.
quoteIdentifier
(
c
.
column
.
getName
()
));
Parser
.
quoteIdentifier
(
buff
.
builder
(),
c
.
column
.
getName
(
));
}
}
buff
.
append
(
')'
);
buff
.
append
(
')'
);
if
(
internalIndex
&&
indexOwner
&&
forTable
==
this
.
table
)
{
if
(
internalIndex
&&
indexOwner
&&
forTable
==
this
.
table
)
{
...
...
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
95cd3025
...
@@ -226,8 +226,8 @@ public class FunctionAlias extends SchemaObjectBase {
...
@@ -226,8 +226,8 @@ public class FunctionAlias extends SchemaObjectBase {
buff
.
append
(
" AS "
);
buff
.
append
(
" AS "
);
StringUtils
.
quoteStringSQL
(
buff
,
source
);
StringUtils
.
quoteStringSQL
(
buff
,
source
);
}
else
{
}
else
{
buff
.
append
(
" FOR "
)
.
append
(
Parser
.
quoteIdentifier
(
buff
.
append
(
" FOR "
)
;
className
+
"."
+
methodName
)
);
Parser
.
quoteIdentifier
(
buff
,
className
+
"."
+
methodName
);
}
}
return
buff
.
toString
();
return
buff
.
toString
();
}
}
...
...
h2/src/main/org/h2/expression/Alias.java
浏览文件 @
95cd3025
...
@@ -79,7 +79,8 @@ public class Alias extends Expression {
...
@@ -79,7 +79,8 @@ public class Alias extends Expression {
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
expr
.
getSQL
(
builder
).
append
(
" AS "
).
append
(
Parser
.
quoteIdentifier
(
alias
));
expr
.
getSQL
(
builder
).
append
(
" AS "
);
return
Parser
.
quoteIdentifier
(
builder
,
alias
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
95cd3025
...
@@ -58,17 +58,27 @@ public class ExpressionColumn extends Expression {
...
@@ -58,17 +58,27 @@ public class ExpressionColumn extends Expression {
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
boolean
quote
=
database
.
getSettings
().
databaseToUpper
;
boolean
quote
=
database
.
getSettings
().
databaseToUpper
;
if
(
schemaName
!=
null
)
{
if
(
schemaName
!=
null
)
{
String
s
=
quote
?
Parser
.
quoteIdentifier
(
schemaName
)
:
schemaName
;
if
(
quote
)
{
builder
.
append
(
s
).
append
(
'.'
);
Parser
.
quoteIdentifier
(
builder
,
schemaName
);
}
else
{
builder
.
append
(
schemaName
);
}
builder
.
append
(
'.'
);
}
}
if
(
tableAlias
!=
null
)
{
if
(
tableAlias
!=
null
)
{
String
a
=
quote
?
Parser
.
quoteIdentifier
(
tableAlias
)
:
tableAlias
;
if
(
quote
)
{
builder
.
append
(
a
).
append
(
'.'
);
Parser
.
quoteIdentifier
(
builder
,
tableAlias
);
}
else
{
builder
.
append
(
tableAlias
);
}
builder
.
append
(
'.'
);
}
}
if
(
column
!=
null
)
{
if
(
column
!=
null
)
{
builder
.
append
(
column
.
getSQL
());
builder
.
append
(
column
.
getSQL
());
}
else
if
(
quote
)
{
Parser
.
quoteIdentifier
(
builder
,
columnName
);
}
else
{
}
else
{
builder
.
append
(
quote
?
Parser
.
quoteIdentifier
(
columnName
)
:
columnName
);
builder
.
append
(
columnName
);
}
}
return
builder
;
return
builder
;
}
}
...
...
h2/src/main/org/h2/expression/JavaFunction.java
浏览文件 @
95cd3025
...
@@ -92,11 +92,9 @@ public class JavaFunction extends Expression implements FunctionCall {
...
@@ -92,11 +92,9 @@ public class JavaFunction extends Expression implements FunctionCall {
// TODO always append the schema once FUNCTIONS_IN_SCHEMA is enabled
// TODO always append the schema once FUNCTIONS_IN_SCHEMA is enabled
if
(
functionAlias
.
getDatabase
().
getSettings
().
functionsInSchema
||
if
(
functionAlias
.
getDatabase
().
getSettings
().
functionsInSchema
||
!
functionAlias
.
getSchema
().
getName
().
equals
(
Constants
.
SCHEMA_MAIN
))
{
!
functionAlias
.
getSchema
().
getName
().
equals
(
Constants
.
SCHEMA_MAIN
))
{
builder
.
append
(
Parser
.
quoteIdentifier
(
builder
,
functionAlias
.
getSchema
().
getName
()).
append
(
'.'
);
Parser
.
quoteIdentifier
(
functionAlias
.
getSchema
().
getName
()))
.
append
(
'.'
);
}
}
builder
.
append
(
Parser
.
quoteIdentifier
(
functionAlias
.
getName
()
)).
append
(
'('
);
Parser
.
quoteIdentifier
(
builder
,
functionAlias
.
getName
(
)).
append
(
'('
);
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
i
>
0
)
{
if
(
i
>
0
)
{
builder
.
append
(
", "
);
builder
.
append
(
", "
);
...
...
h2/src/main/org/h2/expression/Variable.java
浏览文件 @
95cd3025
...
@@ -42,7 +42,8 @@ public class Variable extends Expression {
...
@@ -42,7 +42,8 @@ public class Variable extends Expression {
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
'@'
).
append
(
Parser
.
quoteIdentifier
(
name
));
builder
.
append
(
'@'
);
return
Parser
.
quoteIdentifier
(
builder
,
name
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/expression/Wildcard.java
浏览文件 @
95cd3025
...
@@ -118,7 +118,7 @@ public class Wildcard extends Expression {
...
@@ -118,7 +118,7 @@ public class Wildcard extends Expression {
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
table
!=
null
)
{
if
(
table
!=
null
)
{
builder
.
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
append
(
'.'
);
StringUtils
.
quoteIdentifier
(
builder
,
table
).
append
(
'.'
);
}
}
builder
.
append
(
'*'
);
builder
.
append
(
'*'
);
if
(
exceptColumns
!=
null
)
{
if
(
exceptColumns
!=
null
)
{
...
...
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
95cd3025
...
@@ -68,7 +68,7 @@ public class JavaAggregate extends AbstractAggregate {
...
@@ -68,7 +68,7 @@ public class JavaAggregate extends AbstractAggregate {
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
Parser
.
quoteIdentifier
(
userAggregate
.
getName
()
)).
append
(
'('
);
Parser
.
quoteIdentifier
(
builder
,
userAggregate
.
getName
(
)).
append
(
'('
);
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
i
>
0
)
{
if
(
i
>
0
)
{
builder
.
append
(
", "
);
builder
.
append
(
", "
);
...
...
h2/src/main/org/h2/fulltext/FullText.java
浏览文件 @
95cd3025
...
@@ -772,13 +772,13 @@ public class FullText {
...
@@ -772,13 +772,13 @@ public class FullText {
if
(!
multiThread
)
{
if
(!
multiThread
)
{
buff
.
append
(
", ROLLBACK"
);
buff
.
append
(
", ROLLBACK"
);
}
}
buff
.
append
(
" ON "
)
.
buff
.
append
(
" ON "
)
;
append
(
StringUtils
.
quoteIdentifier
(
schema
)
).
StringUtils
.
quoteIdentifier
(
buff
,
schema
).
append
(
'.'
)
.
append
(
'.'
)
;
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
StringUtils
.
quoteIdentifier
(
buff
,
table
).
append
(
" FOR EACH ROW CALL \""
).
append
(
" FOR EACH ROW CALL \""
).
append
(
FullText
.
FullTextTrigger
.
class
.
getName
()).
append
(
FullText
.
FullTextTrigger
.
class
.
getName
()).
append
(
'
\
"'
);
append
(
'"'
);
stat
.
execute
(
buff
.
toString
());
stat
.
execute
(
buff
.
toString
());
}
}
}
}
...
@@ -1145,7 +1145,7 @@ public class FullText {
...
@@ -1145,7 +1145,7 @@ public class FullText {
StatementBuilder
buff
=
new
StatementBuilder
();
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
int
columnIndex
:
index
.
keys
)
{
for
(
int
columnIndex
:
index
.
keys
)
{
buff
.
appendExceptFirst
(
" AND "
);
buff
.
appendExceptFirst
(
" AND "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
index
.
columns
[
columnIndex
])
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
index
.
columns
[
columnIndex
]
);
Object
o
=
row
[
columnIndex
];
Object
o
=
row
[
columnIndex
];
if
(
o
==
null
)
{
if
(
o
==
null
)
{
buff
.
append
(
" IS NULL"
);
buff
.
append
(
" IS NULL"
);
...
...
h2/src/main/org/h2/fulltext/FullTextLucene.java
浏览文件 @
95cd3025
...
@@ -281,19 +281,19 @@ public class FullTextLucene extends FullText {
...
@@ -281,19 +281,19 @@ public class FullTextLucene extends FullText {
StringUtils
.
quoteIdentifier
(
TRIGGER_PREFIX
+
table
);
StringUtils
.
quoteIdentifier
(
TRIGGER_PREFIX
+
table
);
stat
.
execute
(
"DROP TRIGGER IF EXISTS "
+
trigger
);
stat
.
execute
(
"DROP TRIGGER IF EXISTS "
+
trigger
);
if
(
create
)
{
if
(
create
)
{
StringBuilder
bu
ff
=
new
StringBuilder
(
StringBuilder
bu
ilder
=
new
StringBuilder
(
"CREATE TRIGGER IF NOT EXISTS "
);
"CREATE TRIGGER IF NOT EXISTS "
);
// the trigger is also called on rollback because transaction
// the trigger is also called on rollback because transaction
// rollback will not undo the changes in the Lucene index
// rollback will not undo the changes in the Lucene index
bu
ff
.
append
(
trigger
).
bu
ilder
.
append
(
trigger
).
append
(
" AFTER INSERT, UPDATE, DELETE, ROLLBACK ON "
)
.
append
(
" AFTER INSERT, UPDATE, DELETE, ROLLBACK ON "
)
;
append
(
StringUtils
.
quoteIdentifier
(
schema
)
).
StringUtils
.
quoteIdentifier
(
builder
,
schema
).
append
(
'.'
)
.
append
(
'.'
)
;
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
StringUtils
.
quoteIdentifier
(
builder
,
table
).
append
(
" FOR EACH ROW CALL \""
).
append
(
" FOR EACH ROW CALL \""
).
append
(
FullTextLucene
.
FullTextTrigger
.
class
.
getName
()).
append
(
FullTextLucene
.
FullTextTrigger
.
class
.
getName
()).
append
(
'\"'
);
append
(
'\"'
);
stat
.
execute
(
bu
ff
.
toString
());
stat
.
execute
(
bu
ilder
.
toString
());
}
}
}
}
...
@@ -679,22 +679,25 @@ public class FullTextLucene extends FullText {
...
@@ -679,22 +679,25 @@ public class FullTextLucene extends FullText {
}
}
private
String
getQuery
(
Object
[]
row
)
throws
SQLException
{
private
String
getQuery
(
Object
[]
row
)
throws
SQLException
{
St
atementBuilder
buff
=
new
Statement
Builder
();
St
ringBuilder
builder
=
new
String
Builder
();
if
(
schema
!=
null
)
{
if
(
schema
!=
null
)
{
buff
.
append
(
StringUtils
.
quoteIdentifier
(
schema
)
).
append
(
'.'
);
StringUtils
.
quoteIdentifier
(
builder
,
schema
).
append
(
'.'
);
}
}
buff
.
append
(
StringUtils
.
quoteIdentifier
(
table
)).
append
(
" WHERE "
);
StringUtils
.
quoteIdentifier
(
builder
,
table
).
append
(
" WHERE "
);
for
(
int
columnIndex
:
keys
)
{
for
(
int
i
=
0
,
length
=
keys
.
length
;
i
<
length
;
i
++)
{
buff
.
appendExceptFirst
(
" AND "
);
if
(
i
>
0
)
{
buff
.
append
(
StringUtils
.
quoteIdentifier
(
columns
[
columnIndex
]));
builder
.
append
(
" AND "
);
}
int
columnIndex
=
keys
[
i
];
StringUtils
.
quoteIdentifier
(
builder
,
columns
[
columnIndex
]);
Object
o
=
row
[
columnIndex
];
Object
o
=
row
[
columnIndex
];
if
(
o
==
null
)
{
if
(
o
==
null
)
{
bu
ff
.
append
(
" IS NULL"
);
bu
ilder
.
append
(
" IS NULL"
);
}
else
{
}
else
{
bu
ff
.
append
(
'='
).
append
(
FullText
.
quoteSQL
(
o
,
columnTypes
[
columnIndex
]));
bu
ilder
.
append
(
'='
).
append
(
FullText
.
quoteSQL
(
o
,
columnTypes
[
columnIndex
]));
}
}
}
}
return
bu
ff
.
toString
();
return
bu
ilder
.
toString
();
}
}
}
}
...
...
h2/src/main/org/h2/result/UpdatableRow.java
浏览文件 @
95cd3025
...
@@ -161,7 +161,7 @@ public class UpdatableRow {
...
@@ -161,7 +161,7 @@ public class UpdatableRow {
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
buff
.
appendExceptFirst
(
","
);
buff
.
appendExceptFirst
(
","
);
String
col
=
result
.
getColumnName
(
i
);
String
col
=
result
.
getColumnName
(
i
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
col
)
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
col
);
if
(
set
)
{
if
(
set
)
{
buff
.
append
(
"=? "
);
buff
.
append
(
"=? "
);
}
}
...
@@ -173,7 +173,7 @@ public class UpdatableRow {
...
@@ -173,7 +173,7 @@ public class UpdatableRow {
buff
.
resetCount
();
buff
.
resetCount
();
for
(
String
k
:
key
)
{
for
(
String
k
:
key
)
{
buff
.
appendExceptFirst
(
" AND "
);
buff
.
appendExceptFirst
(
" AND "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
k
)
).
append
(
"=?"
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
k
).
append
(
"=?"
);
}
}
}
}
...
@@ -204,11 +204,11 @@ public class UpdatableRow {
...
@@ -204,11 +204,11 @@ public class UpdatableRow {
// return rs.getInt(1) == 0;
// return rs.getInt(1) == 0;
// }
// }
private
void
appendTableName
(
St
atementBuilder
buff
)
{
private
void
appendTableName
(
St
ringBuilder
builder
)
{
if
(
schemaName
!=
null
&&
schemaName
.
length
()
>
0
)
{
if
(
schemaName
!=
null
&&
schemaName
.
length
()
>
0
)
{
buff
.
append
(
StringUtils
.
quoteIdentifier
(
schemaName
)
).
append
(
'.'
);
StringUtils
.
quoteIdentifier
(
builder
,
schemaName
).
append
(
'.'
);
}
}
buff
.
append
(
StringUtils
.
quoteIdentifier
(
tableName
)
);
StringUtils
.
quoteIdentifier
(
builder
,
tableName
);
}
}
/**
/**
...
@@ -221,7 +221,7 @@ public class UpdatableRow {
...
@@ -221,7 +221,7 @@ public class UpdatableRow {
StatementBuilder
buff
=
new
StatementBuilder
(
"SELECT "
);
StatementBuilder
buff
=
new
StatementBuilder
(
"SELECT "
);
appendColumnList
(
buff
,
false
);
appendColumnList
(
buff
,
false
);
buff
.
append
(
" FROM "
);
buff
.
append
(
" FROM "
);
appendTableName
(
buff
);
appendTableName
(
buff
.
builder
()
);
appendKeyCondition
(
buff
);
appendKeyCondition
(
buff
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
buff
.
toString
());
PreparedStatement
prep
=
conn
.
prepareStatement
(
buff
.
toString
());
setKey
(
prep
,
1
,
row
);
setKey
(
prep
,
1
,
row
);
...
@@ -245,7 +245,7 @@ public class UpdatableRow {
...
@@ -245,7 +245,7 @@ public class UpdatableRow {
*/
*/
public
void
deleteRow
(
Value
[]
current
)
throws
SQLException
{
public
void
deleteRow
(
Value
[]
current
)
throws
SQLException
{
StatementBuilder
buff
=
new
StatementBuilder
(
"DELETE FROM "
);
StatementBuilder
buff
=
new
StatementBuilder
(
"DELETE FROM "
);
appendTableName
(
buff
);
appendTableName
(
buff
.
builder
()
);
appendKeyCondition
(
buff
);
appendKeyCondition
(
buff
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
buff
.
toString
());
PreparedStatement
prep
=
conn
.
prepareStatement
(
buff
.
toString
());
setKey
(
prep
,
1
,
current
);
setKey
(
prep
,
1
,
current
);
...
@@ -265,7 +265,7 @@ public class UpdatableRow {
...
@@ -265,7 +265,7 @@ public class UpdatableRow {
*/
*/
public
void
updateRow
(
Value
[]
current
,
Value
[]
updateRow
)
throws
SQLException
{
public
void
updateRow
(
Value
[]
current
,
Value
[]
updateRow
)
throws
SQLException
{
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
appendTableName
(
buff
);
appendTableName
(
buff
.
builder
()
);
buff
.
append
(
" SET "
);
buff
.
append
(
" SET "
);
appendColumnList
(
buff
,
true
);
appendColumnList
(
buff
,
true
);
// TODO updatable result set: we could add all current values to the
// TODO updatable result set: we could add all current values to the
...
@@ -297,7 +297,7 @@ public class UpdatableRow {
...
@@ -297,7 +297,7 @@ public class UpdatableRow {
*/
*/
public
void
insertRow
(
Value
[]
row
)
throws
SQLException
{
public
void
insertRow
(
Value
[]
row
)
throws
SQLException
{
StatementBuilder
buff
=
new
StatementBuilder
(
"INSERT INTO "
);
StatementBuilder
buff
=
new
StatementBuilder
(
"INSERT INTO "
);
appendTableName
(
buff
);
appendTableName
(
buff
.
builder
()
);
buff
.
append
(
'('
);
buff
.
append
(
'('
);
appendColumnList
(
buff
,
false
);
appendColumnList
(
buff
,
false
);
buff
.
append
(
")VALUES("
);
buff
.
append
(
")VALUES("
);
...
...
h2/src/main/org/h2/schema/TriggerObject.java
浏览文件 @
95cd3025
...
@@ -345,7 +345,8 @@ public class TriggerObject extends SchemaObjectBase {
...
@@ -345,7 +345,8 @@ public class TriggerObject extends SchemaObjectBase {
buff
.
append
(
" QUEUE "
).
append
(
queueSize
);
buff
.
append
(
" QUEUE "
).
append
(
queueSize
);
}
}
if
(
triggerClassName
!=
null
)
{
if
(
triggerClassName
!=
null
)
{
buff
.
append
(
" CALL "
).
append
(
Parser
.
quoteIdentifier
(
triggerClassName
));
buff
.
append
(
" CALL "
);
Parser
.
quoteIdentifier
(
buff
,
triggerClassName
);
}
else
{
}
else
{
buff
.
append
(
" AS "
);
buff
.
append
(
" AS "
);
StringUtils
.
quoteStringSQL
(
buff
,
triggerSource
);
StringUtils
.
quoteStringSQL
(
buff
,
triggerSource
);
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
95cd3025
...
@@ -496,7 +496,7 @@ public class Column {
...
@@ -496,7 +496,7 @@ public class Column {
private
String
getCreateSQL
(
boolean
includeName
)
{
private
String
getCreateSQL
(
boolean
includeName
)
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
if
(
includeName
&&
name
!=
null
)
{
if
(
includeName
&&
name
!=
null
)
{
buff
.
append
(
Parser
.
quoteIdentifier
(
name
)
).
append
(
' '
);
Parser
.
quoteIdentifier
(
buff
,
name
).
append
(
' '
);
}
}
if
(
originalSQL
!=
null
)
{
if
(
originalSQL
!=
null
)
{
buff
.
append
(
originalSQL
);
buff
.
append
(
originalSQL
);
...
...
h2/src/main/org/h2/table/LinkSchema.java
浏览文件 @
95cd3025
...
@@ -49,8 +49,8 @@ public class LinkSchema {
...
@@ -49,8 +49,8 @@ public class LinkSchema {
try
{
try
{
c2
=
JdbcUtils
.
getConnection
(
driver
,
url
,
user
,
password
);
c2
=
JdbcUtils
.
getConnection
(
driver
,
url
,
user
,
password
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE SCHEMA IF NOT EXISTS "
+
stat
.
execute
(
StringUtils
.
quoteIdentifier
(
new
StringBuilder
(
"CREATE SCHEMA IF NOT EXISTS "
),
targetSchema
)
StringUtils
.
quoteIdentifier
(
targetSchema
));
.
toString
(
));
//Workaround for PostgreSQL to avoid index names
//Workaround for PostgreSQL to avoid index names
if
(
url
.
startsWith
(
"jdbc:postgresql:"
))
{
if
(
url
.
startsWith
(
"jdbc:postgresql:"
))
{
rs
=
c2
.
getMetaData
().
getTables
(
null
,
sourceSchema
,
null
,
rs
=
c2
.
getMetaData
().
getTables
(
null
,
sourceSchema
,
null
,
...
@@ -61,16 +61,16 @@ public class LinkSchema {
...
@@ -61,16 +61,16 @@ public class LinkSchema {
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
String
table
=
rs
.
getString
(
"TABLE_NAME"
);
String
table
=
rs
.
getString
(
"TABLE_NAME"
);
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
"DROP TABLE IF EXISTS "
)
.
buff
.
append
(
"DROP TABLE IF EXISTS "
)
;
append
(
StringUtils
.
quoteIdentifier
(
targetSchema
)
).
StringUtils
.
quoteIdentifier
(
buff
,
targetSchema
).
append
(
'.'
)
.
append
(
'.'
)
;
append
(
StringUtils
.
quoteIdentifier
(
table
)
);
StringUtils
.
quoteIdentifier
(
buff
,
table
);
stat
.
execute
(
buff
.
toString
());
stat
.
execute
(
buff
.
toString
());
buff
=
new
StringBuilder
(
);
buff
.
setLength
(
0
);
buff
.
append
(
"CREATE LINKED TABLE "
)
.
buff
.
append
(
"CREATE LINKED TABLE "
)
;
append
(
StringUtils
.
quoteIdentifier
(
targetSchema
)
).
StringUtils
.
quoteIdentifier
(
buff
,
targetSchema
).
append
(
'.'
)
.
append
(
'.'
)
;
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
StringUtils
.
quoteIdentifier
(
buff
,
table
).
append
(
'('
);
append
(
'('
);
StringUtils
.
quoteStringSQL
(
buff
,
driver
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
driver
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
url
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
url
).
append
(
", "
);
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
95cd3025
...
@@ -1918,7 +1918,7 @@ public class MetaTable extends Table {
...
@@ -1918,7 +1918,7 @@ public class MetaTable extends Table {
"SET SCHEMA_SEARCH_PATH "
);
"SET SCHEMA_SEARCH_PATH "
);
for
(
String
p
:
path
)
{
for
(
String
p
:
path
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
p
)
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
p
);
}
}
add
(
rows
,
add
(
rows
,
// KEY
// KEY
...
@@ -1933,7 +1933,7 @@ public class MetaTable extends Table {
...
@@ -1933,7 +1933,7 @@ public class MetaTable extends Table {
// KEY
// KEY
"SCHEMA"
,
"SCHEMA"
,
// SQL
// SQL
"SET SCHEMA "
+
StringUtils
.
quoteIdentifier
(
schema
)
StringUtils
.
quoteIdentifier
(
new
StringBuilder
(
"SET SCHEMA "
),
schema
).
toString
(
)
);
);
}
}
break
;
break
;
...
...
h2/src/main/org/h2/table/TableBase.java
浏览文件 @
95cd3025
...
@@ -125,7 +125,7 @@ public abstract class TableBase extends Table {
...
@@ -125,7 +125,7 @@ public abstract class TableBase extends Table {
}
}
if
(
d
==
null
||
!
tableEngine
.
endsWith
(
d
))
{
if
(
d
==
null
||
!
tableEngine
.
endsWith
(
d
))
{
buff
.
append
(
"\nENGINE "
);
buff
.
append
(
"\nENGINE "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
tableEngine
)
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
tableEngine
);
}
}
}
}
if
(!
tableEngineParams
.
isEmpty
())
{
if
(!
tableEngineParams
.
isEmpty
())
{
...
@@ -133,7 +133,7 @@ public abstract class TableBase extends Table {
...
@@ -133,7 +133,7 @@ public abstract class TableBase extends Table {
buff
.
resetCount
();
buff
.
resetCount
();
for
(
String
parameter
:
tableEngineParams
)
{
for
(
String
parameter
:
tableEngineParams
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
parameter
)
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
parameter
);
}
}
}
}
if
(!
isPersistIndexes
()
&&
!
isPersistData
())
{
if
(!
isPersistIndexes
()
&&
!
isPersistData
())
{
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
95cd3025
...
@@ -791,7 +791,8 @@ public class TableFilter implements ColumnResolver {
...
@@ -791,7 +791,8 @@ public class TableFilter implements ColumnResolver {
return
builder
;
return
builder
;
}
}
if
(
table
.
isView
()
&&
((
TableView
)
table
).
isRecursive
())
{
if
(
table
.
isView
()
&&
((
TableView
)
table
).
isRecursive
())
{
builder
.
append
(
table
.
getSchema
().
getSQL
()).
append
(
'.'
).
append
(
Parser
.
quoteIdentifier
(
table
.
getName
()));
builder
.
append
(
table
.
getSchema
().
getSQL
()).
append
(
'.'
);
Parser
.
quoteIdentifier
(
builder
,
table
.
getName
());
}
else
{
}
else
{
builder
.
append
(
table
.
getSQL
());
builder
.
append
(
table
.
getSQL
());
}
}
...
@@ -799,7 +800,8 @@ public class TableFilter implements ColumnResolver {
...
@@ -799,7 +800,8 @@ public class TableFilter implements ColumnResolver {
throw
DbException
.
get
(
ErrorCode
.
VIEW_IS_INVALID_2
,
table
.
getName
(),
"not compiled"
);
throw
DbException
.
get
(
ErrorCode
.
VIEW_IS_INVALID_2
,
table
.
getName
(),
"not compiled"
);
}
}
if
(
alias
!=
null
)
{
if
(
alias
!=
null
)
{
builder
.
append
(
' '
).
append
(
Parser
.
quoteIdentifier
(
alias
));
builder
.
append
(
' '
);
Parser
.
quoteIdentifier
(
builder
,
alias
);
}
}
if
(
indexHints
!=
null
)
{
if
(
indexHints
!=
null
)
{
builder
.
append
(
" USE INDEX ("
);
builder
.
append
(
" USE INDEX ("
);
...
@@ -810,7 +812,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -810,7 +812,7 @@ public class TableFilter implements ColumnResolver {
}
else
{
}
else
{
first
=
false
;
first
=
false
;
}
}
builder
.
append
(
Parser
.
quoteIdentifier
(
index
)
);
Parser
.
quoteIdentifier
(
builder
,
index
);
}
}
builder
.
append
(
")"
);
builder
.
append
(
")"
);
}
}
...
...
h2/src/main/org/h2/tools/MultiDimension.java
浏览文件 @
95cd3025
...
@@ -156,12 +156,13 @@ public class MultiDimension implements Comparator<long[]> {
...
@@ -156,12 +156,13 @@ public class MultiDimension implements Comparator<long[]> {
public
String
generatePreparedQuery
(
String
table
,
String
scalarColumn
,
public
String
generatePreparedQuery
(
String
table
,
String
scalarColumn
,
String
[]
columns
)
{
String
[]
columns
)
{
StringBuilder
buff
=
new
StringBuilder
(
"SELECT D.* FROM "
);
StringBuilder
buff
=
new
StringBuilder
(
"SELECT D.* FROM "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
StringUtils
.
quoteIdentifier
(
buff
,
table
).
append
(
" D, TABLE(_FROM_ BIGINT=?, _TO_ BIGINT=?) WHERE "
)
.
append
(
" D, TABLE(_FROM_ BIGINT=?, _TO_ BIGINT=?) WHERE "
)
;
append
(
StringUtils
.
quoteIdentifier
(
scalarColumn
)
).
StringUtils
.
quoteIdentifier
(
buff
,
scalarColumn
).
append
(
" BETWEEN _FROM_ AND _TO_"
);
append
(
" BETWEEN _FROM_ AND _TO_"
);
for
(
String
col
:
columns
)
{
for
(
String
col
:
columns
)
{
buff
.
append
(
" AND "
).
append
(
StringUtils
.
quoteIdentifier
(
col
)).
buff
.
append
(
" AND "
);
StringUtils
.
quoteIdentifier
(
buff
,
col
).
append
(
"+1 BETWEEN ?+1 AND ?+1"
);
append
(
"+1 BETWEEN ?+1 AND ?+1"
);
}
}
return
buff
.
toString
();
return
buff
.
toString
();
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
95cd3025
...
@@ -759,17 +759,28 @@ public class StringUtils {
...
@@ -759,17 +759,28 @@ public class StringUtils {
* @return the double quoted text
* @return the double quoted text
*/
*/
public
static
String
quoteIdentifier
(
String
s
)
{
public
static
String
quoteIdentifier
(
String
s
)
{
int
length
=
s
.
length
();
return
quoteIdentifier
(
new
StringBuilder
(
s
.
length
()
+
2
),
s
).
toString
();
StringBuilder
buff
=
new
StringBuilder
(
length
+
2
);
}
buff
.
append
(
'\"'
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
/**
* Enclose a string with double quotes and append it to the specified
* string builder. A double quote inside the string is escaped using a
* double quote.
*
* @param builder string builder to append to
* @param s the text
* @return the specified builder
*/
public
static
StringBuilder
quoteIdentifier
(
StringBuilder
builder
,
String
s
)
{
builder
.
append
(
'"'
);
for
(
int
i
=
0
,
length
=
s
.
length
();
i
<
length
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
char
c
=
s
.
charAt
(
i
);
if
(
c
==
'"'
)
{
if
(
c
==
'"'
)
{
bu
ff
.
append
(
c
);
bu
ilder
.
append
(
c
);
}
}
bu
ff
.
append
(
c
);
bu
ilder
.
append
(
c
);
}
}
return
bu
ff
.
append
(
'\"'
).
toString
(
);
return
bu
ilder
.
append
(
'"'
);
}
}
/**
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论