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 {
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
)
{
this
.
literalsChecked
=
literalsChecked
;
}
...
...
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
95cd3025
...
...
@@ -392,7 +392,7 @@ public class ScriptCommand extends ScriptBase {
buff
.
append
(
table
.
getSQL
()).
append
(
'('
);
for
(
Column
col
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
Parser
.
quoteIdentifier
(
col
.
getName
()
));
Parser
.
quoteIdentifier
(
buff
.
builder
(),
col
.
getName
(
));
}
buff
.
append
(
") VALUES"
);
if
(!
simple
)
{
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
95cd3025
...
...
@@ -1308,7 +1308,8 @@ public class Select extends Query {
// views.
}
else
{
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
(
'('
);
buff
.
resetCount
();
for
(
Column
c
:
t
.
getColumns
())
{
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
95cd3025
...
...
@@ -568,7 +568,7 @@ public class ConstraintReferential extends Constraint {
buff
.
resetCount
();
for
(
IndexColumn
c
:
columns
)
{
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 {
buff
.
resetCount
();
for
(
IndexColumn
c
:
columns
)
{
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 {
buff
.
append
(
' '
).
append
(
getConstraintType
().
getSqlName
()).
append
(
'('
);
for
(
IndexColumn
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
Parser
.
quoteIdentifier
(
c
.
column
.
getName
()
));
Parser
.
quoteIdentifier
(
buff
.
builder
(),
c
.
column
.
getName
(
));
}
buff
.
append
(
')'
);
if
(
internalIndex
&&
indexOwner
&&
forTable
==
this
.
table
)
{
...
...
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
95cd3025
...
...
@@ -226,8 +226,8 @@ public class FunctionAlias extends SchemaObjectBase {
buff
.
append
(
" AS "
);
StringUtils
.
quoteStringSQL
(
buff
,
source
);
}
else
{
buff
.
append
(
" FOR "
)
.
append
(
Parser
.
quoteIdentifier
(
className
+
"."
+
methodName
)
);
buff
.
append
(
" FOR "
)
;
Parser
.
quoteIdentifier
(
buff
,
className
+
"."
+
methodName
);
}
return
buff
.
toString
();
}
...
...
h2/src/main/org/h2/expression/Alias.java
浏览文件 @
95cd3025
...
...
@@ -79,7 +79,8 @@ public class Alias extends Expression {
@Override
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
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
95cd3025
...
...
@@ -58,17 +58,27 @@ public class ExpressionColumn extends Expression {
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
boolean
quote
=
database
.
getSettings
().
databaseToUpper
;
if
(
schemaName
!=
null
)
{
String
s
=
quote
?
Parser
.
quoteIdentifier
(
schemaName
)
:
schemaName
;
builder
.
append
(
s
).
append
(
'.'
);
if
(
quote
)
{
Parser
.
quoteIdentifier
(
builder
,
schemaName
);
}
else
{
builder
.
append
(
schemaName
);
}
builder
.
append
(
'.'
);
}
if
(
tableAlias
!=
null
)
{
String
a
=
quote
?
Parser
.
quoteIdentifier
(
tableAlias
)
:
tableAlias
;
builder
.
append
(
a
).
append
(
'.'
);
if
(
quote
)
{
Parser
.
quoteIdentifier
(
builder
,
tableAlias
);
}
else
{
builder
.
append
(
tableAlias
);
}
builder
.
append
(
'.'
);
}
if
(
column
!=
null
)
{
builder
.
append
(
column
.
getSQL
());
}
else
if
(
quote
)
{
Parser
.
quoteIdentifier
(
builder
,
columnName
);
}
else
{
builder
.
append
(
quote
?
Parser
.
quoteIdentifier
(
columnName
)
:
columnName
);
builder
.
append
(
columnName
);
}
return
builder
;
}
...
...
h2/src/main/org/h2/expression/JavaFunction.java
浏览文件 @
95cd3025
...
...
@@ -92,11 +92,9 @@ public class JavaFunction extends Expression implements FunctionCall {
// TODO always append the schema once FUNCTIONS_IN_SCHEMA is enabled
if
(
functionAlias
.
getDatabase
().
getSettings
().
functionsInSchema
||
!
functionAlias
.
getSchema
().
getName
().
equals
(
Constants
.
SCHEMA_MAIN
))
{
builder
.
append
(
Parser
.
quoteIdentifier
(
functionAlias
.
getSchema
().
getName
()))
.
append
(
'.'
);
Parser
.
quoteIdentifier
(
builder
,
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
++)
{
if
(
i
>
0
)
{
builder
.
append
(
", "
);
...
...
h2/src/main/org/h2/expression/Variable.java
浏览文件 @
95cd3025
...
...
@@ -42,7 +42,8 @@ public class Variable extends Expression {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
'@'
).
append
(
Parser
.
quoteIdentifier
(
name
));
builder
.
append
(
'@'
);
return
Parser
.
quoteIdentifier
(
builder
,
name
);
}
@Override
...
...
h2/src/main/org/h2/expression/Wildcard.java
浏览文件 @
95cd3025
...
...
@@ -118,7 +118,7 @@ public class Wildcard extends Expression {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
table
!=
null
)
{
builder
.
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
append
(
'.'
);
StringUtils
.
quoteIdentifier
(
builder
,
table
).
append
(
'.'
);
}
builder
.
append
(
'*'
);
if
(
exceptColumns
!=
null
)
{
...
...
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
95cd3025
...
...
@@ -68,7 +68,7 @@ public class JavaAggregate extends AbstractAggregate {
@Override
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
++)
{
if
(
i
>
0
)
{
builder
.
append
(
", "
);
...
...
h2/src/main/org/h2/fulltext/FullText.java
浏览文件 @
95cd3025
...
...
@@ -772,13 +772,13 @@ public class FullText {
if
(!
multiThread
)
{
buff
.
append
(
", ROLLBACK"
);
}
buff
.
append
(
" ON "
)
.
append
(
StringUtils
.
quoteIdentifier
(
schema
)
).
append
(
'.'
)
.
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
buff
.
append
(
" ON "
)
;
StringUtils
.
quoteIdentifier
(
buff
,
schema
).
append
(
'.'
)
;
StringUtils
.
quoteIdentifier
(
buff
,
table
).
append
(
" FOR EACH ROW CALL \""
).
append
(
FullText
.
FullTextTrigger
.
class
.
getName
()).
append
(
'
\
"'
);
append
(
'"'
);
stat
.
execute
(
buff
.
toString
());
}
}
...
...
@@ -1145,7 +1145,7 @@ public class FullText {
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
int
columnIndex
:
index
.
keys
)
{
buff
.
appendExceptFirst
(
" AND "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
index
.
columns
[
columnIndex
])
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
index
.
columns
[
columnIndex
]
);
Object
o
=
row
[
columnIndex
];
if
(
o
==
null
)
{
buff
.
append
(
" IS NULL"
);
...
...
h2/src/main/org/h2/fulltext/FullTextLucene.java
浏览文件 @
95cd3025
...
...
@@ -281,19 +281,19 @@ public class FullTextLucene extends FullText {
StringUtils
.
quoteIdentifier
(
TRIGGER_PREFIX
+
table
);
stat
.
execute
(
"DROP TRIGGER IF EXISTS "
+
trigger
);
if
(
create
)
{
StringBuilder
bu
ff
=
new
StringBuilder
(
StringBuilder
bu
ilder
=
new
StringBuilder
(
"CREATE TRIGGER IF NOT EXISTS "
);
// the trigger is also called on rollback because transaction
// rollback will not undo the changes in the Lucene index
bu
ff
.
append
(
trigger
).
append
(
" AFTER INSERT, UPDATE, DELETE, ROLLBACK ON "
)
.
append
(
StringUtils
.
quoteIdentifier
(
schema
)
).
append
(
'.'
)
.
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
bu
ilder
.
append
(
trigger
).
append
(
" AFTER INSERT, UPDATE, DELETE, ROLLBACK ON "
)
;
StringUtils
.
quoteIdentifier
(
builder
,
schema
).
append
(
'.'
)
;
StringUtils
.
quoteIdentifier
(
builder
,
table
).
append
(
" FOR EACH ROW CALL \""
).
append
(
FullTextLucene
.
FullTextTrigger
.
class
.
getName
()).
append
(
'\"'
);
stat
.
execute
(
bu
ff
.
toString
());
stat
.
execute
(
bu
ilder
.
toString
());
}
}
...
...
@@ -679,22 +679,25 @@ public class FullTextLucene extends FullText {
}
private
String
getQuery
(
Object
[]
row
)
throws
SQLException
{
St
atementBuilder
buff
=
new
Statement
Builder
();
St
ringBuilder
builder
=
new
String
Builder
();
if
(
schema
!=
null
)
{
buff
.
append
(
StringUtils
.
quoteIdentifier
(
schema
)).
append
(
'.'
);
StringUtils
.
quoteIdentifier
(
builder
,
schema
).
append
(
'.'
);
}
StringUtils
.
quoteIdentifier
(
builder
,
table
).
append
(
" WHERE "
);
for
(
int
i
=
0
,
length
=
keys
.
length
;
i
<
length
;
i
++)
{
if
(
i
>
0
)
{
builder
.
append
(
" AND "
);
}
buff
.
append
(
StringUtils
.
quoteIdentifier
(
table
)).
append
(
" WHERE "
);
for
(
int
columnIndex
:
keys
)
{
buff
.
appendExceptFirst
(
" AND "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
columns
[
columnIndex
]));
int
columnIndex
=
keys
[
i
];
StringUtils
.
quoteIdentifier
(
builder
,
columns
[
columnIndex
]);
Object
o
=
row
[
columnIndex
];
if
(
o
==
null
)
{
bu
ff
.
append
(
" IS NULL"
);
bu
ilder
.
append
(
" IS NULL"
);
}
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 {
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
buff
.
appendExceptFirst
(
","
);
String
col
=
result
.
getColumnName
(
i
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
col
)
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
col
);
if
(
set
)
{
buff
.
append
(
"=? "
);
}
...
...
@@ -173,7 +173,7 @@ public class UpdatableRow {
buff
.
resetCount
();
for
(
String
k
:
key
)
{
buff
.
appendExceptFirst
(
" AND "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
k
)
).
append
(
"=?"
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
k
).
append
(
"=?"
);
}
}
...
...
@@ -204,11 +204,11 @@ public class UpdatableRow {
// return rs.getInt(1) == 0;
// }
private
void
appendTableName
(
St
atementBuilder
buff
)
{
private
void
appendTableName
(
St
ringBuilder
builder
)
{
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 {
StatementBuilder
buff
=
new
StatementBuilder
(
"SELECT "
);
appendColumnList
(
buff
,
false
);
buff
.
append
(
" FROM "
);
appendTableName
(
buff
);
appendTableName
(
buff
.
builder
()
);
appendKeyCondition
(
buff
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
buff
.
toString
());
setKey
(
prep
,
1
,
row
);
...
...
@@ -245,7 +245,7 @@ public class UpdatableRow {
*/
public
void
deleteRow
(
Value
[]
current
)
throws
SQLException
{
StatementBuilder
buff
=
new
StatementBuilder
(
"DELETE FROM "
);
appendTableName
(
buff
);
appendTableName
(
buff
.
builder
()
);
appendKeyCondition
(
buff
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
buff
.
toString
());
setKey
(
prep
,
1
,
current
);
...
...
@@ -265,7 +265,7 @@ public class UpdatableRow {
*/
public
void
updateRow
(
Value
[]
current
,
Value
[]
updateRow
)
throws
SQLException
{
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
appendTableName
(
buff
);
appendTableName
(
buff
.
builder
()
);
buff
.
append
(
" SET "
);
appendColumnList
(
buff
,
true
);
// TODO updatable result set: we could add all current values to the
...
...
@@ -297,7 +297,7 @@ public class UpdatableRow {
*/
public
void
insertRow
(
Value
[]
row
)
throws
SQLException
{
StatementBuilder
buff
=
new
StatementBuilder
(
"INSERT INTO "
);
appendTableName
(
buff
);
appendTableName
(
buff
.
builder
()
);
buff
.
append
(
'('
);
appendColumnList
(
buff
,
false
);
buff
.
append
(
")VALUES("
);
...
...
h2/src/main/org/h2/schema/TriggerObject.java
浏览文件 @
95cd3025
...
...
@@ -345,7 +345,8 @@ public class TriggerObject extends SchemaObjectBase {
buff
.
append
(
" QUEUE "
).
append
(
queueSize
);
}
if
(
triggerClassName
!=
null
)
{
buff
.
append
(
" CALL "
).
append
(
Parser
.
quoteIdentifier
(
triggerClassName
));
buff
.
append
(
" CALL "
);
Parser
.
quoteIdentifier
(
buff
,
triggerClassName
);
}
else
{
buff
.
append
(
" AS "
);
StringUtils
.
quoteStringSQL
(
buff
,
triggerSource
);
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
95cd3025
...
...
@@ -496,7 +496,7 @@ public class Column {
private
String
getCreateSQL
(
boolean
includeName
)
{
StringBuilder
buff
=
new
StringBuilder
();
if
(
includeName
&&
name
!=
null
)
{
buff
.
append
(
Parser
.
quoteIdentifier
(
name
)
).
append
(
' '
);
Parser
.
quoteIdentifier
(
buff
,
name
).
append
(
' '
);
}
if
(
originalSQL
!=
null
)
{
buff
.
append
(
originalSQL
);
...
...
h2/src/main/org/h2/table/LinkSchema.java
浏览文件 @
95cd3025
...
...
@@ -49,8 +49,8 @@ public class LinkSchema {
try
{
c2
=
JdbcUtils
.
getConnection
(
driver
,
url
,
user
,
password
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE SCHEMA IF NOT EXISTS "
+
StringUtils
.
quoteIdentifier
(
targetSchema
));
stat
.
execute
(
StringUtils
.
quoteIdentifier
(
new
StringBuilder
(
"CREATE SCHEMA IF NOT EXISTS "
),
targetSchema
)
.
toString
(
));
//Workaround for PostgreSQL to avoid index names
if
(
url
.
startsWith
(
"jdbc:postgresql:"
))
{
rs
=
c2
.
getMetaData
().
getTables
(
null
,
sourceSchema
,
null
,
...
...
@@ -61,16 +61,16 @@ public class LinkSchema {
while
(
rs
.
next
())
{
String
table
=
rs
.
getString
(
"TABLE_NAME"
);
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
"DROP TABLE IF EXISTS "
)
.
append
(
StringUtils
.
quoteIdentifier
(
targetSchema
)
).
append
(
'.'
)
.
append
(
StringUtils
.
quoteIdentifier
(
table
)
);
buff
.
append
(
"DROP TABLE IF EXISTS "
)
;
StringUtils
.
quoteIdentifier
(
buff
,
targetSchema
).
append
(
'.'
)
;
StringUtils
.
quoteIdentifier
(
buff
,
table
);
stat
.
execute
(
buff
.
toString
());
buff
=
new
StringBuilder
(
);
buff
.
append
(
"CREATE LINKED TABLE "
)
.
append
(
StringUtils
.
quoteIdentifier
(
targetSchema
)
).
append
(
'.'
)
.
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
buff
.
setLength
(
0
);
buff
.
append
(
"CREATE LINKED TABLE "
)
;
StringUtils
.
quoteIdentifier
(
buff
,
targetSchema
).
append
(
'.'
)
;
StringUtils
.
quoteIdentifier
(
buff
,
table
).
append
(
'('
);
StringUtils
.
quoteStringSQL
(
buff
,
driver
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
url
).
append
(
", "
);
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
95cd3025
...
...
@@ -1918,7 +1918,7 @@ public class MetaTable extends Table {
"SET SCHEMA_SEARCH_PATH "
);
for
(
String
p
:
path
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
p
)
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
p
);
}
add
(
rows
,
// KEY
...
...
@@ -1933,7 +1933,7 @@ public class MetaTable extends Table {
// KEY
"SCHEMA"
,
// SQL
"SET SCHEMA "
+
StringUtils
.
quoteIdentifier
(
schema
)
StringUtils
.
quoteIdentifier
(
new
StringBuilder
(
"SET SCHEMA "
),
schema
).
toString
(
)
);
}
break
;
...
...
h2/src/main/org/h2/table/TableBase.java
浏览文件 @
95cd3025
...
...
@@ -125,7 +125,7 @@ public abstract class TableBase extends Table {
}
if
(
d
==
null
||
!
tableEngine
.
endsWith
(
d
))
{
buff
.
append
(
"\nENGINE "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
tableEngine
)
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
tableEngine
);
}
}
if
(!
tableEngineParams
.
isEmpty
())
{
...
...
@@ -133,7 +133,7 @@ public abstract class TableBase extends Table {
buff
.
resetCount
();
for
(
String
parameter
:
tableEngineParams
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
parameter
)
);
StringUtils
.
quoteIdentifier
(
buff
.
builder
(),
parameter
);
}
}
if
(!
isPersistIndexes
()
&&
!
isPersistData
())
{
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
95cd3025
...
...
@@ -791,7 +791,8 @@ public class TableFilter implements ColumnResolver {
return
builder
;
}
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
{
builder
.
append
(
table
.
getSQL
());
}
...
...
@@ -799,7 +800,8 @@ public class TableFilter implements ColumnResolver {
throw
DbException
.
get
(
ErrorCode
.
VIEW_IS_INVALID_2
,
table
.
getName
(),
"not compiled"
);
}
if
(
alias
!=
null
)
{
builder
.
append
(
' '
).
append
(
Parser
.
quoteIdentifier
(
alias
));
builder
.
append
(
' '
);
Parser
.
quoteIdentifier
(
builder
,
alias
);
}
if
(
indexHints
!=
null
)
{
builder
.
append
(
" USE INDEX ("
);
...
...
@@ -810,7 +812,7 @@ public class TableFilter implements ColumnResolver {
}
else
{
first
=
false
;
}
builder
.
append
(
Parser
.
quoteIdentifier
(
index
)
);
Parser
.
quoteIdentifier
(
builder
,
index
);
}
builder
.
append
(
")"
);
}
...
...
h2/src/main/org/h2/tools/MultiDimension.java
浏览文件 @
95cd3025
...
...
@@ -156,12 +156,13 @@ public class MultiDimension implements Comparator<long[]> {
public
String
generatePreparedQuery
(
String
table
,
String
scalarColumn
,
String
[]
columns
)
{
StringBuilder
buff
=
new
StringBuilder
(
"SELECT D.* FROM "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
table
)
).
append
(
" D, TABLE(_FROM_ BIGINT=?, _TO_ BIGINT=?) WHERE "
)
.
append
(
StringUtils
.
quoteIdentifier
(
scalarColumn
)
).
StringUtils
.
quoteIdentifier
(
buff
,
table
).
append
(
" D, TABLE(_FROM_ BIGINT=?, _TO_ BIGINT=?) WHERE "
)
;
StringUtils
.
quoteIdentifier
(
buff
,
scalarColumn
).
append
(
" BETWEEN _FROM_ AND _TO_"
);
for
(
String
col
:
columns
)
{
buff
.
append
(
" AND "
).
append
(
StringUtils
.
quoteIdentifier
(
col
)).
buff
.
append
(
" AND "
);
StringUtils
.
quoteIdentifier
(
buff
,
col
).
append
(
"+1 BETWEEN ?+1 AND ?+1"
);
}
return
buff
.
toString
();
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
95cd3025
...
...
@@ -759,17 +759,28 @@ public class StringUtils {
* @return the double quoted text
*/
public
static
String
quoteIdentifier
(
String
s
)
{
int
length
=
s
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
length
+
2
);
buff
.
append
(
'\"'
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
return
quoteIdentifier
(
new
StringBuilder
(
s
.
length
()
+
2
),
s
).
toString
();
}
/**
* 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
);
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论