Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
fcd4160d
提交
fcd4160d
authored
11月 06, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add StringUtils.quoteStringSQL(StringBuilder, String)
上级
f98b8066
隐藏空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
71 行增加
和
50 行删除
+71
-50
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+1
-1
ConstraintCheck.java
h2/src/main/org/h2/constraint/ConstraintCheck.java
+2
-1
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+2
-1
ConstraintUnique.java
h2/src/main/org/h2/constraint/ConstraintUnique.java
+2
-1
Comment.java
h2/src/main/org/h2/engine/Comment.java
+1
-1
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+2
-1
User.java
h2/src/main/org/h2/engine/User.java
+2
-1
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+2
-1
TriggerObject.java
h2/src/main/org/h2/schema/TriggerObject.java
+2
-1
Column.java
h2/src/main/org/h2/table/Column.java
+2
-1
LinkSchema.java
h2/src/main/org/h2/table/LinkSchema.java
+7
-13
TableBase.java
h2/src/main/org/h2/table/TableBase.java
+2
-1
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+8
-12
TableView.java
h2/src/main/org/h2/table/TableView.java
+2
-1
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+28
-8
ValueEnumBase.java
h2/src/main/org/h2/value/ValueEnumBase.java
+1
-1
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+1
-1
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+1
-1
ValueString.java
h2/src/main/org/h2/value/ValueString.java
+1
-1
ValueStringIgnoreCase.java
h2/src/main/org/h2/value/ValueStringIgnoreCase.java
+2
-1
没有找到文件。
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
fcd4160d
...
...
@@ -490,7 +490,7 @@ public class ScriptCommand extends ScriptBase {
if
(
len
==
0
)
{
break
;
}
buff
.
append
(
StringUtils
.
quoteStringSQL
(
new
String
(
chars
,
0
,
len
)
)).
StringUtils
.
quoteStringSQL
(
buff
,
new
String
(
chars
,
0
,
len
)).
append
(
", NULL)"
);
String
sql
=
buff
.
toString
();
add
(
sql
,
true
);
...
...
h2/src/main/org/h2/constraint/ConstraintCheck.java
浏览文件 @
fcd4160d
...
...
@@ -56,7 +56,8 @@ public class ConstraintCheck extends Constraint {
}
buff
.
append
(
quotedName
);
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
).
append
(
StringUtils
.
quoteStringSQL
(
comment
));
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
,
comment
);
}
buff
.
append
(
" CHECK("
);
expr
.
getUnenclosedSQL
(
buff
).
append
(
") NOCHECK"
);
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
fcd4160d
...
...
@@ -87,7 +87,8 @@ public class ConstraintReferential extends Constraint {
}
buff
.
append
(
quotedName
);
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
).
append
(
StringUtils
.
quoteStringSQL
(
comment
));
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
.
builder
(),
comment
);
}
IndexColumn
[]
cols
=
columns
;
IndexColumn
[]
refCols
=
refColumns
;
...
...
h2/src/main/org/h2/constraint/ConstraintUnique.java
浏览文件 @
fcd4160d
...
...
@@ -52,7 +52,8 @@ public class ConstraintUnique extends Constraint {
}
buff
.
append
(
quotedName
);
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
).
append
(
StringUtils
.
quoteStringSQL
(
comment
));
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
.
builder
(),
comment
);
}
buff
.
append
(
' '
).
append
(
getConstraintType
().
getSqlName
()).
append
(
'('
);
for
(
IndexColumn
c
:
columns
)
{
...
...
h2/src/main/org/h2/engine/Comment.java
浏览文件 @
fcd4160d
...
...
@@ -74,7 +74,7 @@ public class Comment extends DbObjectBase {
if
(
commentText
==
null
)
{
buff
.
append
(
"NULL"
);
}
else
{
buff
.
append
(
StringUtils
.
quoteStringSQL
(
commentText
)
);
StringUtils
.
quoteStringSQL
(
buff
,
commentText
);
}
return
buff
.
toString
();
}
...
...
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
fcd4160d
...
...
@@ -223,7 +223,8 @@ public class FunctionAlias extends SchemaObjectBase {
buff
.
append
(
" NOBUFFER"
);
}
if
(
source
!=
null
)
{
buff
.
append
(
" AS "
).
append
(
StringUtils
.
quoteStringSQL
(
source
));
buff
.
append
(
" AS "
);
StringUtils
.
quoteStringSQL
(
buff
,
source
);
}
else
{
buff
.
append
(
" FOR "
).
append
(
Parser
.
quoteIdentifier
(
className
+
"."
+
methodName
));
...
...
h2/src/main/org/h2/engine/User.java
浏览文件 @
fcd4160d
...
...
@@ -159,7 +159,8 @@ public class User extends RightOwner {
StringBuilder
buff
=
new
StringBuilder
(
"CREATE USER IF NOT EXISTS "
);
buff
.
append
(
getSQL
());
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
).
append
(
StringUtils
.
quoteStringSQL
(
comment
));
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
,
comment
);
}
if
(
password
)
{
buff
.
append
(
" SALT '"
).
...
...
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
fcd4160d
...
...
@@ -410,7 +410,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
buff
.
append
(
quotedName
);
buff
.
append
(
" ON "
).
append
(
targetTable
.
getSQL
());
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
).
append
(
StringUtils
.
quoteStringSQL
(
comment
));
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
,
comment
);
}
buff
.
append
(
'('
).
append
(
getColumnListSQL
()).
append
(
')'
);
return
buff
.
toString
();
...
...
h2/src/main/org/h2/schema/TriggerObject.java
浏览文件 @
fcd4160d
...
...
@@ -347,7 +347,8 @@ public class TriggerObject extends SchemaObjectBase {
if
(
triggerClassName
!=
null
)
{
buff
.
append
(
" CALL "
).
append
(
Parser
.
quoteIdentifier
(
triggerClassName
));
}
else
{
buff
.
append
(
" AS "
).
append
(
StringUtils
.
quoteStringSQL
(
triggerSource
));
buff
.
append
(
" AS "
);
StringUtils
.
quoteStringSQL
(
buff
,
triggerSource
);
}
return
buff
.
toString
();
}
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
fcd4160d
...
...
@@ -573,7 +573,8 @@ public class Column {
buff
.
append
(
" SELECTIVITY "
).
append
(
selectivity
);
}
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
).
append
(
StringUtils
.
quoteStringSQL
(
comment
));
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
,
comment
);
}
if
(
checkConstraint
!=
null
)
{
buff
.
append
(
" CHECK "
).
append
(
checkConstraintSQL
);
...
...
h2/src/main/org/h2/table/LinkSchema.java
浏览文件 @
fcd4160d
...
...
@@ -71,19 +71,13 @@ public class LinkSchema {
append
(
StringUtils
.
quoteIdentifier
(
targetSchema
)).
append
(
'.'
).
append
(
StringUtils
.
quoteIdentifier
(
table
)).
append
(
'('
).
append
(
StringUtils
.
quoteStringSQL
(
driver
)).
append
(
", "
).
append
(
StringUtils
.
quoteStringSQL
(
url
)).
append
(
", "
).
append
(
StringUtils
.
quoteStringSQL
(
user
)).
append
(
", "
).
append
(
StringUtils
.
quoteStringSQL
(
password
)).
append
(
", "
).
append
(
StringUtils
.
quoteStringSQL
(
sourceSchema
)).
append
(
", "
).
append
(
StringUtils
.
quoteStringSQL
(
table
)).
append
(
')'
);
append
(
'('
);
StringUtils
.
quoteStringSQL
(
buff
,
driver
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
url
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
user
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
password
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
sourceSchema
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
table
).
append
(
')'
);
stat
.
execute
(
buff
.
toString
());
result
.
addRow
(
table
);
}
...
...
h2/src/main/org/h2/table/TableBase.java
浏览文件 @
fcd4160d
...
...
@@ -108,7 +108,8 @@ public abstract class TableBase extends Table {
}
buff
.
append
(
getSQL
());
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
).
append
(
StringUtils
.
quoteStringSQL
(
comment
));
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
.
builder
(),
comment
);
}
buff
.
append
(
"(\n "
);
for
(
Column
column
:
columns
)
{
...
...
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
fcd4160d
...
...
@@ -372,19 +372,15 @@ public class TableLink extends Table {
}
buff
.
append
(
"LINKED TABLE "
).
append
(
getSQL
());
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
).
append
(
StringUtils
.
quoteStringSQL
(
comment
));
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
,
comment
);
}
buff
.
append
(
'('
).
append
(
StringUtils
.
quoteStringSQL
(
driver
)).
append
(
", "
).
append
(
StringUtils
.
quoteStringSQL
(
url
)).
append
(
", "
).
append
(
StringUtils
.
quoteStringSQL
(
user
)).
append
(
", "
).
append
(
StringUtils
.
quoteStringSQL
(
password
)).
append
(
", "
).
append
(
StringUtils
.
quoteStringSQL
(
originalTable
)).
append
(
')'
);
buff
.
append
(
'('
);
StringUtils
.
quoteStringSQL
(
buff
,
driver
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
url
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
user
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
password
).
append
(
", "
);
StringUtils
.
quoteStringSQL
(
buff
,
originalTable
).
append
(
')'
);
if
(
emitUpdates
)
{
buff
.
append
(
" EMIT UPDATES"
);
}
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
fcd4160d
...
...
@@ -348,7 +348,8 @@ public class TableView extends Table {
}
buff
.
append
(
quotedName
);
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
).
append
(
StringUtils
.
quoteStringSQL
(
comment
));
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
.
builder
(),
comment
);
}
if
(
columns
!=
null
&&
columns
.
length
>
0
)
{
buff
.
append
(
'('
);
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
fcd4160d
...
...
@@ -121,22 +121,40 @@ public class StringUtils {
if
(
s
==
null
)
{
return
"NULL"
;
}
return
quoteStringSQL
(
new
StringBuilder
(
s
.
length
()
+
2
),
s
).
toString
();
}
/**
* Convert a string to a SQL literal. Null is converted to NULL. The text is
* enclosed in single quotes. If there are any special characters, the
* method STRINGDECODE is used.
*
* @param builder
* string builder to append result to
* @param s the text to convert.
* @return the specified string builder
*/
public
static
StringBuilder
quoteStringSQL
(
StringBuilder
builder
,
String
s
)
{
if
(
s
==
null
)
{
return
builder
.
append
(
"NULL"
);
}
int
builderLength
=
builder
.
length
();
int
length
=
s
.
length
();
StringBuilder
buff
=
new
StringBuilder
(
length
+
2
);
buff
.
append
(
'\''
);
builder
.
append
(
'\''
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
if
(
c
==
'\''
)
{
bu
ff
.
append
(
c
);
bu
ilder
.
append
(
c
);
}
else
if
(
c
<
' '
||
c
>
127
)
{
// need to start from the beginning because maybe there was a \
// that was not quoted
return
"STRINGDECODE("
+
quoteStringSQL
(
javaEncode
(
s
))
+
")"
;
builder
.
setLength
(
builderLength
);
builder
.
append
(
"STRINGDECODE("
);
return
quoteStringSQL
(
builder
,
javaEncode
(
s
)).
append
(
')'
);
}
bu
ff
.
append
(
c
);
bu
ilder
.
append
(
c
);
}
buff
.
append
(
'\''
);
return
buff
.
toString
();
return
builder
.
append
(
'\''
);
}
/**
...
...
@@ -321,7 +339,9 @@ public class StringUtils {
if
(
s
==
null
)
{
return
"null"
;
}
return
"\""
+
javaEncode
(
s
)
+
"\""
;
StringBuilder
builder
=
new
StringBuilder
(
s
.
length
()
+
2
).
append
(
'"'
);
javaEncode
(
s
,
builder
);
return
builder
.
append
(
'"'
).
toString
();
}
/**
...
...
h2/src/main/org/h2/value/ValueEnumBase.java
浏览文件 @
fcd4160d
...
...
@@ -95,7 +95,7 @@ public class ValueEnumBase extends Value {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
StringUtils
.
quoteStringSQL
(
label
)
);
return
StringUtils
.
quoteStringSQL
(
builder
,
label
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
fcd4160d
...
...
@@ -572,7 +572,7 @@ public class ValueLob extends Value {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
valueType
==
Value
.
CLOB
)
{
builder
.
append
(
StringUtils
.
quoteStringSQL
(
getString
()
));
StringUtils
.
quoteStringSQL
(
builder
,
getString
(
));
}
else
{
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytes
())).
append
(
'\''
);
}
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
fcd4160d
...
...
@@ -463,7 +463,7 @@ public class ValueLobDb extends Value {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
valueType
==
Value
.
CLOB
)
{
builder
.
append
(
StringUtils
.
quoteStringSQL
(
getString
()
));
StringUtils
.
quoteStringSQL
(
builder
,
getString
(
));
}
else
{
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytes
())).
append
(
'\''
);
}
...
...
h2/src/main/org/h2/value/ValueString.java
浏览文件 @
fcd4160d
...
...
@@ -35,7 +35,7 @@ public class ValueString extends Value {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
StringUtils
.
quoteStringSQL
(
value
)
);
return
StringUtils
.
quoteStringSQL
(
builder
,
value
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueStringIgnoreCase.java
浏览文件 @
fcd4160d
...
...
@@ -48,7 +48,8 @@ public class ValueStringIgnoreCase extends ValueString {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
"CAST("
).
append
(
StringUtils
.
quoteStringSQL
(
value
)).
append
(
" AS VARCHAR_IGNORECASE)"
);
builder
.
append
(
"CAST("
);
return
StringUtils
.
quoteStringSQL
(
builder
,
value
).
append
(
" AS VARCHAR_IGNORECASE)"
);
}
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论