Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a36a6634
提交
a36a6634
authored
2月 12, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use DbObject.getSQL(StringBuilder) where possible
上级
4f34f37d
显示空白字符变更
内嵌
并排
正在显示
39 个修改的文件
包含
166 行增加
和
107 行删除
+166
-107
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+3
-2
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+17
-8
Analyze.java
h2/src/main/org/h2/command/ddl/Analyze.java
+2
-1
CreateDomain.java
h2/src/main/org/h2/command/ddl/CreateDomain.java
+3
-3
Insert.java
h2/src/main/org/h2/command/dml/Insert.java
+2
-2
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+2
-2
MergeUsing.java
h2/src/main/org/h2/command/dml/MergeUsing.java
+1
-1
Replace.java
h2/src/main/org/h2/command/dml/Replace.java
+2
-2
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+5
-5
Select.java
h2/src/main/org/h2/command/dml/Select.java
+4
-3
ConstraintCheck.java
h2/src/main/org/h2/constraint/ConstraintCheck.java
+3
-4
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+20
-15
ConstraintUnique.java
h2/src/main/org/h2/constraint/ConstraintUnique.java
+3
-2
Comment.java
h2/src/main/org/h2/engine/Comment.java
+3
-1
Domain.java
h2/src/main/org/h2/engine/Domain.java
+6
-2
Right.java
h2/src/main/org/h2/engine/Right.java
+7
-4
Role.java
h2/src/main/org/h2/engine/Role.java
+1
-1
Session.java
h2/src/main/org/h2/engine/Session.java
+4
-2
Setting.java
h2/src/main/org/h2/engine/Setting.java
+1
-1
User.java
h2/src/main/org/h2/engine/User.java
+1
-1
UserAggregate.java
h2/src/main/org/h2/engine/UserAggregate.java
+6
-3
SequenceValue.java
h2/src/main/org/h2/expression/SequenceValue.java
+1
-1
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+9
-5
PageBtreeLeaf.java
h2/src/main/org/h2/index/PageBtreeLeaf.java
+1
-1
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+5
-4
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+2
-1
ScanIndex.java
h2/src/main/org/h2/index/ScanIndex.java
+1
-1
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+13
-9
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+3
-2
MVSpatialIndex.java
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
+3
-3
Constant.java
h2/src/main/org/h2/schema/Constant.java
+2
-1
Schema.java
h2/src/main/org/h2/schema/Schema.java
+4
-2
Sequence.java
h2/src/main/org/h2/schema/Sequence.java
+3
-2
TriggerObject.java
h2/src/main/org/h2/schema/TriggerObject.java
+2
-1
Column.java
h2/src/main/org/h2/table/Column.java
+2
-1
TableBase.java
h2/src/main/org/h2/table/TableBase.java
+4
-2
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+2
-2
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+4
-2
TableSynonym.java
h2/src/main/org/h2/table/TableSynonym.java
+9
-2
没有找到文件。
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
a36a6634
...
...
@@ -208,8 +208,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
session
.
getUser
().
checkRight
(
refTable
,
Right
.
ALL
);
if
(!
refTable
.
canReference
())
{
throw
DbException
.
getUnsupportedException
(
"Reference "
+
refTable
.
getSQL
());
StringBuilder
builder
=
new
StringBuilder
(
"Reference "
);
refTable
.
getSQL
(
builder
);
throw
DbException
.
getUnsupportedException
(
builder
.
toString
());
}
boolean
isOwner
=
false
;
IndexColumn
.
mapColumns
(
indexColumns
,
table
);
...
...
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
a36a6634
...
...
@@ -296,7 +296,9 @@ public class AlterTableAlterColumn extends CommandWithColumns {
// (because the column to drop is referenced or so)
checkViews
(
table
,
newTable
);
}
catch
(
DbException
e
)
{
execute
(
"DROP TABLE "
+
newTable
.
getSQL
(),
true
);
StringBuilder
builder
=
new
StringBuilder
(
"DROP TABLE "
);
newTable
.
getSQL
(
builder
);
execute
(
builder
.
toString
(),
true
);
throw
e
;
}
String
tableName
=
table
.
getName
();
...
...
@@ -304,7 +306,9 @@ public class AlterTableAlterColumn extends CommandWithColumns {
for
(
TableView
view
:
dependentViews
)
{
table
.
removeDependentView
(
view
);
}
execute
(
"DROP TABLE "
+
table
.
getSQL
()
+
" IGNORE"
,
true
);
StringBuilder
builder
=
new
StringBuilder
(
"DROP TABLE "
);
table
.
getSQL
(
builder
).
append
(
" IGNORE"
);
execute
(
builder
.
toString
(),
true
);
db
.
renameSchemaObject
(
session
,
newTable
,
tableName
);
for
(
DbObject
child
:
newTable
.
getChildren
())
{
if
(
child
instanceof
Sequence
)
{
...
...
@@ -475,7 +479,8 @@ public class AlterTableAlterColumn extends CommandWithColumns {
}
}
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
"INSERT INTO "
).
append
(
newTable
.
getSQL
());
buff
.
append
(
"INSERT INTO "
);
newTable
.
getSQL
(
buff
);
buff
.
append
(
" SELECT "
);
if
(
columnList
.
length
()
==
0
)
{
// special case: insert into test select * from
...
...
@@ -483,13 +488,16 @@ public class AlterTableAlterColumn extends CommandWithColumns {
}
else
{
buff
.
append
(
columnList
);
}
buff
.
append
(
" FROM "
).
append
(
table
.
getSQL
());
buff
.
append
(
" FROM "
);
table
.
getSQL
(
buff
);
try
{
execute
(
buff
.
toString
(),
true
);
}
catch
(
Throwable
t
)
{
// data was not inserted due to data conversion error or some
// unexpected reason
execute
(
"DROP TABLE "
+
newTable
.
getSQL
(),
true
);
StringBuilder
builder
=
new
StringBuilder
(
"DROP TABLE "
);
newTable
.
getSQL
(
builder
);
execute
(
builder
.
toString
(),
true
);
throw
t
;
}
for
(
String
sql
:
children
)
{
...
...
@@ -579,9 +587,10 @@ public class AlterTableAlterColumn extends CommandWithColumns {
}
private
void
checkNoNullValues
(
Table
table
)
{
String
sql
=
"SELECT COUNT(*) FROM "
+
table
.
getSQL
()
+
" WHERE "
+
oldColumn
.
getSQL
()
+
" IS NULL"
;
StringBuilder
builder
=
new
StringBuilder
(
"SELECT COUNT(*) FROM "
);
table
.
getSQL
(
builder
).
append
(
" WHERE "
);
builder
.
append
(
oldColumn
.
getSQL
()).
append
(
" IS NULL"
);
String
sql
=
builder
.
toString
();
Prepared
command
=
session
.
prepare
(
sql
);
ResultInterface
result
=
command
.
query
(
0
);
result
.
next
();
...
...
h2/src/main/org/h2/command/ddl/Analyze.java
浏览文件 @
a36a6634
...
...
@@ -113,7 +113,8 @@ public class Analyze extends DefineCommand {
buff
.
append
(
"SELECTIVITY("
).
append
(
col
.
getSQL
()).
append
(
')'
);
}
}
buff
.
append
(
" FROM "
).
append
(
table
.
getSQL
());
buff
.
append
(
" FROM "
);
table
.
getSQL
(
buff
.
builder
());
if
(
sample
>
0
)
{
buff
.
append
(
" FETCH FIRST ROW ONLY SAMPLE_SIZE ? "
);
}
...
...
h2/src/main/org/h2/command/ddl/CreateDomain.java
浏览文件 @
a36a6634
...
...
@@ -64,9 +64,9 @@ public class CreateDomain extends DefineCommand {
}
Table
table
=
session
.
getDatabase
().
getFirstUserTable
();
if
(
table
!=
null
)
{
throw
DbException
.
get
(
ErrorCode
.
DOMAIN_ALREADY_EXISTS_1
,
typeName
+
" ("
+
table
.
getSQL
()
+
")"
);
StringBuilder
builder
=
new
StringBuilder
(
typeName
).
append
(
" ("
);
table
.
getSQL
(
builder
).
append
(
')'
);
throw
DbException
.
get
(
ErrorCode
.
DOMAIN_ALREADY_EXISTS_1
,
builder
.
toString
()
);
}
}
int
id
=
getObjectId
();
...
...
h2/src/main/org/h2/command/dml/Insert.java
浏览文件 @
a36a6634
...
...
@@ -270,7 +270,7 @@ public class Insert extends CommandWithValues implements ResultTarget {
@Override
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"INSERT INTO "
);
buff
.
append
(
table
.
getSQL
()).
append
(
'('
);
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
...
...
@@ -405,7 +405,7 @@ public class Insert extends CommandWithValues implements ResultTarget {
}
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
buff
.
append
(
table
.
getSQL
()).
append
(
" SET "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
for
(
Column
column
:
duplicateKeyAssignmentMap
.
keySet
())
{
buff
.
appendExceptFirst
(
", "
);
Expression
ex
=
duplicateKeyAssignmentMap
.
get
(
column
);
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
a36a6634
...
...
@@ -207,7 +207,7 @@ public class Merge extends CommandWithValues {
@Override
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"MERGE INTO "
);
buff
.
append
(
targetTable
.
getSQL
()).
append
(
'('
);
targetTable
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
...
...
@@ -276,7 +276,7 @@ public class Merge extends CommandWithValues {
keys
=
idx
.
getColumns
();
}
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
buff
.
append
(
targetTable
.
getSQL
()).
append
(
" SET "
);
targetTable
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
()).
append
(
"=?"
);
...
...
h2/src/main/org/h2/command/dml/MergeUsing.java
浏览文件 @
a36a6634
...
...
@@ -390,7 +390,7 @@ public class MergeUsing extends Prepared {
@Override
public
String
getPlanSQL
()
{
StringBuilder
builder
=
new
StringBuilder
(
"MERGE INTO "
);
builder
.
append
(
targetTable
.
getSQL
()
).
append
(
'\n'
).
append
(
"USING "
).
append
(
query
.
getPlanSQL
());
targetTable
.
getSQL
(
builder
).
append
(
'\n'
).
append
(
"USING "
).
append
(
query
.
getPlanSQL
());
// TODO add aliases and WHEN clauses to make plan SQL more like original SQL
return
builder
.
toString
();
}
...
...
h2/src/main/org/h2/command/dml/Replace.java
浏览文件 @
a36a6634
...
...
@@ -196,7 +196,7 @@ public class Replace extends CommandWithValues {
@Override
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"REPLACE INTO "
);
buff
.
append
(
table
.
getSQL
()).
append
(
'('
);
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
...
...
@@ -270,7 +270,7 @@ public class Replace extends CommandWithValues {
}
}
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
buff
.
append
(
table
.
getSQL
()).
append
(
" SET "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
()).
append
(
"=?"
);
...
...
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
a36a6634
...
...
@@ -291,10 +291,10 @@ public class ScriptCommand extends ScriptBase {
}
if
(
TableType
.
TABLE
==
tableType
)
{
if
(
table
.
canGetRowCount
())
{
String
rowcount
=
"-- "
+
table
.
getRowCountApproximation
()
+
" +/- SELECT COUNT(*) FROM "
+
table
.
getSQL
(
);
add
(
rowcount
,
false
);
String
Builder
builder
=
new
StringBuilder
(
"-- "
).
append
(
table
.
getRowCountApproximation
())
.
append
(
" +/- SELECT COUNT(*) FROM "
);
table
.
getSQL
(
builder
);
add
(
builder
.
toString
()
,
false
);
}
if
(
data
)
{
count
=
generateInsertValues
(
count
,
table
);
...
...
@@ -389,7 +389,7 @@ public class ScriptCommand extends ScriptBase {
Cursor
cursor
=
index
.
find
(
session
,
null
,
null
);
Column
[]
columns
=
table
.
getColumns
();
StatementBuilder
buff
=
new
StatementBuilder
(
"INSERT INTO "
);
buff
.
append
(
table
.
getSQL
()).
append
(
'('
);
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
col
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
Parser
.
quoteIdentifier
(
buff
.
builder
(),
col
.
getName
());
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
a36a6634
...
...
@@ -1474,8 +1474,8 @@ public class Select extends Query {
// since using a with statement will re-create the common table expression
// views.
}
else
{
buff
.
append
(
"WITH RECURSIVE "
)
.
append
(
t
.
getSchema
().
getSQL
()).
append
(
'.'
);
buff
.
append
(
"WITH RECURSIVE "
)
;
t
.
getSchema
().
getSQL
(
buff
.
builder
()).
append
(
'.'
);
Parser
.
quoteIdentifier
(
buff
.
builder
(),
t
.
getName
())
.
append
(
'('
);
buff
.
resetCount
();
...
...
@@ -1483,7 +1483,8 @@ public class Select extends Query {
buff
.
appendExceptFirst
(
","
);
buff
.
append
(
c
.
getName
());
}
buff
.
append
(
") AS "
).
append
(
t
.
getSQL
()).
append
(
'\n'
);
buff
.
append
(
") AS "
);
t
.
getSQL
(
buff
.
builder
()).
append
(
'\n'
);
}
}
}
...
...
h2/src/main/org/h2/constraint/ConstraintCheck.java
浏览文件 @
a36a6634
...
...
@@ -50,7 +50,7 @@ public class ConstraintCheck extends Constraint {
@Override
public
String
getCreateSQLForCopy
(
Table
forTable
,
String
quotedName
)
{
StringBuilder
buff
=
new
StringBuilder
(
"ALTER TABLE "
);
buff
.
append
(
forTable
.
getSQL
()
).
append
(
" ADD CONSTRAINT "
);
forTable
.
getSQL
(
buff
).
append
(
" ADD CONSTRAINT "
);
if
(
forTable
.
isHidden
())
{
buff
.
append
(
"IF NOT EXISTS "
);
}
...
...
@@ -143,9 +143,8 @@ public class ConstraintCheck extends Constraint {
// don't check at startup
return
;
}
StringBuilder
builder
=
new
StringBuilder
().
append
(
"SELECT 1 FROM "
)
.
append
(
filter
.
getTable
().
getSQL
())
.
append
(
" WHERE NOT("
);
StringBuilder
builder
=
new
StringBuilder
().
append
(
"SELECT 1 FROM "
);
filter
.
getTable
().
getSQL
(
builder
).
append
(
" WHERE NOT("
);
expr
.
getSQL
(
builder
).
append
(
')'
);
String
sql
=
builder
.
toString
();
ResultInterface
r
=
session
.
prepare
(
sql
).
query
(
1
);
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
a36a6634
...
...
@@ -80,8 +80,7 @@ public class ConstraintReferential extends Constraint {
public
String
getCreateSQLForCopy
(
Table
forTable
,
Table
forRefTable
,
String
quotedName
,
boolean
internalIndex
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
"ALTER TABLE "
);
String
mainTable
=
forTable
.
getSQL
();
buff
.
append
(
mainTable
).
append
(
" ADD CONSTRAINT "
);
forTable
.
getSQL
(
buff
.
builder
()).
append
(
" ADD CONSTRAINT "
);
if
(
forTable
.
isHidden
())
{
buff
.
append
(
"IF NOT EXISTS "
);
}
...
...
@@ -99,17 +98,17 @@ public class ConstraintReferential extends Constraint {
}
buff
.
append
(
')'
);
if
(
internalIndex
&&
indexOwner
&&
forTable
==
this
.
table
)
{
buff
.
append
(
" INDEX "
).
append
(
index
.
getSQL
());
buff
.
append
(
" INDEX "
);
index
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
" REFERENCES "
);
String
quotedRefTable
;
if
(
this
.
table
==
this
.
refTable
)
{
// self-referencing constraints: need to use new table
quotedRefTable
=
forTable
.
getSQL
(
);
forTable
.
getSQL
(
buff
.
builder
()
);
}
else
{
quotedRefTable
=
forRefTable
.
getSQL
(
);
forRefTable
.
getSQL
(
buff
.
builder
()
);
}
buff
.
append
(
quotedRefTable
).
append
(
'('
);
buff
.
append
(
'('
);
buff
.
resetCount
();
for
(
IndexColumn
r
:
refCols
)
{
buff
.
appendExceptFirst
(
", "
);
...
...
@@ -117,7 +116,8 @@ public class ConstraintReferential extends Constraint {
}
buff
.
append
(
')'
);
if
(
internalIndex
&&
refIndexOwner
&&
forTable
==
this
.
table
)
{
buff
.
append
(
" INDEX "
).
append
(
refIndex
.
getSQL
());
buff
.
append
(
" INDEX "
);
refIndex
.
getSQL
(
buff
.
builder
());
}
if
(
deleteAction
!=
ConstraintActionType
.
RESTRICT
)
{
buff
.
append
(
" ON DELETE "
).
append
(
deleteAction
.
getSqlName
());
...
...
@@ -139,12 +139,14 @@ public class ConstraintReferential extends Constraint {
*/
private
String
getShortDescription
(
Index
searchIndex
,
SearchRow
check
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
getName
());
buff
.
append
(
": "
).
append
(
table
.
getSQL
()).
append
(
" FOREIGN KEY("
);
buff
.
append
(
": "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
" FOREIGN KEY("
);
for
(
IndexColumn
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
}
buff
.
append
(
") REFERENCES "
).
append
(
refTable
.
getSQL
()).
append
(
'('
);
buff
.
append
(
") REFERENCES "
);
refTable
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
buff
.
resetCount
();
for
(
IndexColumn
r
:
refColumns
)
{
buff
.
appendExceptFirst
(
", "
);
...
...
@@ -491,7 +493,8 @@ public class ConstraintReferential extends Constraint {
}
StatementBuilder
buff
=
new
StatementBuilder
();
if
(
deleteAction
==
ConstraintActionType
.
CASCADE
)
{
buff
.
append
(
"DELETE FROM "
).
append
(
table
.
getSQL
());
buff
.
append
(
"DELETE FROM "
);
table
.
getSQL
(
buff
.
builder
());
}
else
{
appendUpdate
(
buff
);
}
...
...
@@ -567,7 +570,8 @@ public class ConstraintReferential extends Constraint {
}
private
void
appendUpdate
(
StatementBuilder
buff
)
{
buff
.
append
(
"UPDATE "
).
append
(
table
.
getSQL
()).
append
(
" SET "
);
buff
.
append
(
"UPDATE "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
buff
.
resetCount
();
for
(
IndexColumn
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
...
...
@@ -622,7 +626,8 @@ public class ConstraintReferential extends Constraint {
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
}
buff
.
append
(
" FROM "
).
append
(
table
.
getSQL
()).
append
(
" WHERE "
);
buff
.
append
(
" FROM "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
" WHERE "
);
buff
.
resetCount
();
for
(
IndexColumn
c
:
columns
)
{
buff
.
appendExceptFirst
(
" AND "
);
...
...
@@ -634,8 +639,8 @@ public class ConstraintReferential extends Constraint {
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
}
buff
.
append
(
") C WHERE NOT EXISTS(SELECT 1 FROM "
)
.
append
(
refTable
.
getSQL
()).
append
(
" P WHERE "
);
buff
.
append
(
") C WHERE NOT EXISTS(SELECT 1 FROM "
)
;
refTable
.
getSQL
(
buff
.
builder
()).
append
(
" P WHERE "
);
buff
.
resetCount
();
int
i
=
0
;
for
(
IndexColumn
c
:
columns
)
{
...
...
h2/src/main/org/h2/constraint/ConstraintUnique.java
浏览文件 @
a36a6634
...
...
@@ -46,7 +46,7 @@ public class ConstraintUnique extends Constraint {
private
String
getCreateSQLForCopy
(
Table
forTable
,
String
quotedName
,
boolean
internalIndex
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
"ALTER TABLE "
);
buff
.
append
(
forTable
.
getSQL
()).
append
(
" ADD CONSTRAINT "
);
forTable
.
getSQL
(
buff
.
builder
()).
append
(
" ADD CONSTRAINT "
);
if
(
forTable
.
isHidden
())
{
buff
.
append
(
"IF NOT EXISTS "
);
}
...
...
@@ -62,7 +62,8 @@ public class ConstraintUnique extends Constraint {
}
buff
.
append
(
')'
);
if
(
internalIndex
&&
indexOwner
&&
forTable
==
this
.
table
)
{
buff
.
append
(
" INDEX "
).
append
(
index
.
getSQL
());
buff
.
append
(
" INDEX "
);
index
.
getSQL
(
buff
.
builder
());
}
return
buff
.
toString
();
}
...
...
h2/src/main/org/h2/engine/Comment.java
浏览文件 @
a36a6634
...
...
@@ -102,7 +102,9 @@ public class Comment extends DbObjectBase {
* @return the key name
*/
static
String
getKey
(
DbObject
obj
)
{
return
getTypeName
(
obj
.
getType
())
+
" "
+
obj
.
getSQL
();
StringBuilder
builder
=
new
StringBuilder
(
getTypeName
(
obj
.
getType
())).
append
(
' '
);
obj
.
getSQL
(
builder
);
return
builder
.
toString
();
}
/**
...
...
h2/src/main/org/h2/engine/Domain.java
浏览文件 @
a36a6634
...
...
@@ -28,12 +28,16 @@ public class Domain extends DbObjectBase {
@Override
public
String
getDropSQL
()
{
return
"DROP DOMAIN IF EXISTS "
+
getSQL
();
StringBuilder
builder
=
new
StringBuilder
(
"DROP DOMAIN IF EXISTS "
);
return
getSQL
(
builder
).
toString
();
}
@Override
public
String
getCreateSQL
()
{
return
"CREATE DOMAIN "
+
getSQL
()
+
" AS "
+
column
.
getCreateSQL
();
StringBuilder
builder
=
new
StringBuilder
(
"CREATE DOMAIN "
);
getSQL
(
builder
).
append
(
" AS "
);
builder
.
append
(
column
.
getCreateSQL
());
return
builder
.
toString
();
}
public
Column
getColumn
()
{
...
...
h2/src/main/org/h2/engine/Right.java
浏览文件 @
a36a6634
...
...
@@ -135,18 +135,21 @@ public class Right extends DbObjectBase {
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
"GRANT "
);
if
(
grantedRole
!=
null
)
{
buff
.
append
(
grantedRole
.
getSQL
()
);
grantedRole
.
getSQL
(
buff
);
}
else
{
buff
.
append
(
getRights
());
if
(
object
!=
null
)
{
if
(
object
instanceof
Schema
)
{
buff
.
append
(
" ON SCHEMA "
).
append
(
object
.
getSQL
());
buff
.
append
(
" ON SCHEMA "
);
object
.
getSQL
(
buff
);
}
else
if
(
object
instanceof
Table
)
{
buff
.
append
(
" ON "
).
append
(
object
.
getSQL
());
buff
.
append
(
" ON "
);
object
.
getSQL
(
buff
);
}
}
}
buff
.
append
(
" TO "
).
append
(
grantee
.
getSQL
());
buff
.
append
(
" TO "
);
grantee
.
getSQL
(
buff
);
return
buff
.
toString
();
}
...
...
h2/src/main/org/h2/engine/Role.java
浏览文件 @
a36a6634
...
...
@@ -45,7 +45,7 @@ public class Role extends RightOwner {
if
(
ifNotExists
)
{
buff
.
append
(
"IF NOT EXISTS "
);
}
buff
.
append
(
getSQL
()
);
getSQL
(
buff
);
return
buff
.
toString
();
}
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
a36a6634
...
...
@@ -393,8 +393,10 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
localTempTables
=
database
.
newStringMap
();
}
if
(
localTempTables
.
get
(
table
.
getName
())
!=
null
)
{
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_ALREADY_EXISTS_1
,
table
.
getSQL
()+
" AS "
+
table
.
getName
());
StringBuilder
builder
=
new
StringBuilder
();
table
.
getSQL
(
builder
).
append
(
" AS "
);
Parser
.
quoteIdentifier
(
table
.
getName
());
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_ALREADY_EXISTS_1
,
builder
.
toString
());
}
modificationId
++;
localTempTables
.
put
(
table
.
getName
(),
table
);
...
...
h2/src/main/org/h2/engine/Setting.java
浏览文件 @
a36a6634
...
...
@@ -50,7 +50,7 @@ public class Setting extends DbObjectBase {
@Override
public
String
getCreateSQL
()
{
StringBuilder
buff
=
new
StringBuilder
(
"SET "
);
buff
.
append
(
getSQL
()
).
append
(
' '
);
getSQL
(
buff
).
append
(
' '
);
if
(
stringValue
!=
null
)
{
buff
.
append
(
stringValue
);
}
else
{
...
...
h2/src/main/org/h2/engine/User.java
浏览文件 @
a36a6634
...
...
@@ -157,7 +157,7 @@ public class User extends RightOwner {
*/
public
String
getCreateSQL
(
boolean
password
)
{
StringBuilder
buff
=
new
StringBuilder
(
"CREATE USER IF NOT EXISTS "
);
buff
.
append
(
getSQL
()
);
getSQL
(
buff
);
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
,
comment
);
...
...
h2/src/main/org/h2/engine/UserAggregate.java
浏览文件 @
a36a6634
...
...
@@ -59,13 +59,16 @@ public class UserAggregate extends DbObjectBase {
@Override
public
String
getDropSQL
()
{
return
"DROP AGGREGATE IF EXISTS "
+
getSQL
();
StringBuilder
builder
=
new
StringBuilder
(
"DROP AGGREGATE IF EXISTS "
);
return
getSQL
(
builder
).
toString
();
}
@Override
public
String
getCreateSQL
()
{
return
"CREATE FORCE AGGREGATE "
+
getSQL
()
+
" FOR "
+
Parser
.
quoteIdentifier
(
className
);
StringBuilder
builder
=
new
StringBuilder
(
"CREATE FORCE AGGREGATE "
);
getSQL
(
builder
).
append
(
" FOR "
);
Parser
.
quoteIdentifier
(
builder
,
className
);
return
builder
.
toString
();
}
@Override
...
...
h2/src/main/org/h2/expression/SequenceValue.java
浏览文件 @
a36a6634
...
...
@@ -55,7 +55,7 @@ public class SequenceValue extends Expression {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
"(NEXT VALUE FOR "
);
return
builder
.
append
(
sequence
.
getSQL
()
).
append
(
')'
);
return
sequence
.
getSQL
(
builder
).
append
(
')'
);
}
@Override
...
...
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
a36a6634
...
...
@@ -93,12 +93,15 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
* @return the exception
*/
protected
DbException
getDuplicateKeyException
(
String
key
)
{
String
sql
=
getName
()
+
" ON "
+
table
.
getSQL
()
+
"("
+
getColumnListSQL
()
+
")"
;
StringBuilder
builder
=
new
StringBuilder
();
getSQL
(
builder
).
append
(
" ON "
);
table
.
getSQL
(
builder
).
append
(
'('
);
builder
.
append
(
getColumnListSQL
());
builder
.
append
(
')'
);
if
(
key
!=
null
)
{
sql
+=
" VALUES "
+
key
;
builder
.
append
(
" VALUES "
).
append
(
key
)
;
}
DbException
e
=
DbException
.
get
(
ErrorCode
.
DUPLICATE_KEY_1
,
sql
);
DbException
e
=
DbException
.
get
(
ErrorCode
.
DUPLICATE_KEY_1
,
builder
.
toString
()
);
e
.
setSource
(
this
);
return
e
;
}
...
...
@@ -426,7 +429,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
buff
.
append
(
"IF NOT EXISTS "
);
}
buff
.
append
(
quotedName
);
buff
.
append
(
" ON "
).
append
(
targetTable
.
getSQL
());
buff
.
append
(
" ON "
);
targetTable
.
getSQL
(
buff
);
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
,
comment
);
...
...
h2/src/main/org/h2/index/PageBtreeLeaf.java
浏览文件 @
a36a6634
...
...
@@ -229,7 +229,7 @@ public class PageBtreeLeaf extends PageBtree {
SearchRow
delete
=
getRow
(
at
);
if
(
index
.
compareRows
(
row
,
delete
)
!=
0
||
delete
.
getKey
()
!=
row
.
getKey
())
{
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
index
.
getSQL
(
)
+
": "
+
row
);
index
.
getSQL
(
new
StringBuilder
()).
append
(
": "
).
append
(
row
).
toString
()
);
}
index
.
getPageStore
().
logUndo
(
this
,
data
);
if
(
entryCount
==
1
)
{
...
...
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
a36a6634
...
...
@@ -139,11 +139,12 @@ public class PageDataIndex extends PageIndex {
}
public
DbException
getNewDuplicateKeyException
()
{
String
sql
=
"PRIMARY KEY ON "
+
table
.
getSQL
();
StringBuilder
builder
=
new
StringBuilder
(
"PRIMARY KEY ON "
);
table
.
getSQL
(
builder
);
if
(
mainIndexColumn
>=
0
&&
mainIndexColumn
<
indexColumns
.
length
)
{
sql
+=
"("
+
indexColumns
[
mainIndexColumn
].
getSQL
()
+
")"
;
builder
.
append
(
'('
).
append
(
indexColumns
[
mainIndexColumn
].
getSQL
()).
append
(
')'
)
;
}
DbException
e
=
DbException
.
get
(
ErrorCode
.
DUPLICATE_KEY_1
,
sql
);
DbException
e
=
DbException
.
get
(
ErrorCode
.
DUPLICATE_KEY_1
,
builder
.
toString
()
);
e
.
setSource
(
this
);
return
e
;
}
...
...
@@ -478,7 +479,7 @@ public class PageDataIndex extends PageIndex {
@Override
public
String
getPlanSQL
()
{
return
table
.
getSQL
(
)
+
".tableScan"
;
return
table
.
getSQL
(
new
StringBuilder
()).
append
(
".tableScan"
).
toString
()
;
}
int
getMemoryPerPage
()
{
...
...
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
a36a6634
...
...
@@ -416,7 +416,8 @@ public class PageDataLeaf extends PageData {
int
i
=
find
(
key
);
if
(
keys
==
null
||
keys
[
i
]
!=
key
)
{
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
index
.
getSQL
()
+
": "
+
key
+
" "
+
(
keys
==
null
?
-
1
:
keys
[
i
]));
index
.
getSQL
(
new
StringBuilder
()).
append
(
": "
).
append
(
key
).
append
(
' '
)
.
append
(
keys
==
null
?
-
1
:
keys
[
i
]).
toString
());
}
index
.
getPageStore
().
logUndo
(
this
,
data
);
if
(
entryCount
==
1
)
{
...
...
h2/src/main/org/h2/index/ScanIndex.java
浏览文件 @
a36a6634
...
...
@@ -193,7 +193,7 @@ public class ScanIndex extends BaseIndex {
@Override
public
String
getPlanSQL
()
{
return
table
.
getSQL
(
)
+
".tableScan"
;
return
table
.
getSQL
(
new
StringBuilder
()).
append
(
".tableScan"
).
toString
()
;
}
}
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
a36a6634
...
...
@@ -70,7 +70,7 @@ public class MVPrimaryIndex extends BaseIndex {
@Override
public
String
getPlanSQL
()
{
return
table
.
getSQL
(
)
+
".tableScan"
;
return
table
.
getSQL
(
new
StringBuilder
()).
append
(
".tableScan"
).
toString
()
;
}
public
void
setMainIndexColumn
(
int
mainIndexColumn
)
{
...
...
@@ -116,16 +116,18 @@ public class MVPrimaryIndex extends BaseIndex {
try
{
Value
oldValue
=
map
.
putIfAbsent
(
key
,
ValueArray
.
get
(
row
.
getValueList
()));
if
(
oldValue
!=
null
)
{
String
sql
=
"PRIMARY KEY ON "
+
table
.
getSQL
();
StringBuilder
builder
=
new
StringBuilder
(
"PRIMARY KEY ON "
);
table
.
getSQL
(
builder
);
if
(
mainIndexColumn
>=
0
&&
mainIndexColumn
<
indexColumns
.
length
)
{
sql
+=
"("
+
indexColumns
[
mainIndexColumn
].
getSQL
()
+
")"
;
builder
.
append
(
'('
).
append
(
indexColumns
[
mainIndexColumn
].
getSQL
()).
append
(
')'
)
;
}
int
errorCode
=
ErrorCode
.
CONCURRENT_UPDATE_1
;
if
(
map
.
get
(
key
)
!=
null
)
{
// committed
errorCode
=
ErrorCode
.
DUPLICATE_KEY_1
;
}
DbException
e
=
DbException
.
get
(
errorCode
,
sql
+
" "
+
oldValue
);
builder
.
append
(
' '
).
append
(
oldValue
);
DbException
e
=
DbException
.
get
(
errorCode
,
builder
.
toString
());
e
.
setSource
(
this
);
throw
e
;
}
...
...
@@ -154,8 +156,9 @@ public class MVPrimaryIndex extends BaseIndex {
try
{
Value
old
=
map
.
remove
(
ValueLong
.
get
(
row
.
getKey
()));
if
(
old
==
null
)
{
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
getSQL
()
+
": "
+
row
.
getKey
());
StringBuilder
builder
=
new
StringBuilder
();
getSQL
(
builder
).
append
(
": "
).
append
(
row
.
getKey
());
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
builder
.
toString
());
}
}
catch
(
IllegalStateException
e
)
{
throw
mvTable
.
convertException
(
e
);
...
...
@@ -194,8 +197,9 @@ public class MVPrimaryIndex extends BaseIndex {
try
{
Value
existing
=
map
.
put
(
ValueLong
.
get
(
key
),
ValueArray
.
get
(
newRow
.
getValueList
()));
if
(
existing
==
null
)
{
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
getSQL
()
+
": "
+
key
);
StringBuilder
builder
=
new
StringBuilder
();
getSQL
(
builder
).
append
(
": "
).
append
(
key
);
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
builder
.
toString
());
}
}
catch
(
IllegalStateException
e
)
{
throw
mvTable
.
convertException
(
e
);
...
...
@@ -286,7 +290,7 @@ public class MVPrimaryIndex extends BaseIndex {
return
getRow
(
session
,
key
,
(
ValueArray
)
v
);
}
private
Row
getRow
(
Session
session
,
long
key
,
ValueArray
array
)
{
private
static
Row
getRow
(
Session
session
,
long
key
,
ValueArray
array
)
{
Row
row
=
session
.
createRow
(
array
.
getList
(),
0
);
row
.
setKey
(
key
);
return
row
;
...
...
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
a36a6634
...
...
@@ -231,8 +231,9 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
try
{
Value
old
=
map
.
remove
(
array
);
if
(
old
==
null
)
{
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
getSQL
()
+
": "
+
row
.
getKey
());
StringBuilder
builder
=
new
StringBuilder
();
getSQL
(
builder
).
append
(
": "
).
append
(
row
.
getKey
());
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
builder
.
toString
());
}
}
catch
(
IllegalStateException
e
)
{
throw
mvTable
.
convertException
(
e
);
...
...
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
浏览文件 @
a36a6634
...
...
@@ -183,9 +183,9 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
try
{
Value
old
=
map
.
remove
(
key
);
if
(
old
==
null
)
{
old
=
map
.
remove
(
key
);
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
getSQL
()
+
": "
+
row
.
getKey
());
StringBuilder
builder
=
new
StringBuilder
(
);
getSQL
(
builder
).
append
(
": "
).
append
(
row
.
getKey
());
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
builder
.
toString
());
}
}
catch
(
IllegalStateException
e
)
{
throw
mvTable
.
convertException
(
e
);
...
...
h2/src/main/org/h2/schema/Constant.java
浏览文件 @
a36a6634
...
...
@@ -38,7 +38,8 @@ public class Constant extends SchemaObjectBase {
@Override
public
String
getCreateSQL
()
{
StringBuilder
builder
=
new
StringBuilder
().
append
(
"CREATE CONSTANT "
).
append
(
getSQL
()).
append
(
" VALUE "
);
StringBuilder
builder
=
new
StringBuilder
(
"CREATE CONSTANT "
);
getSQL
(
builder
).
append
(
" VALUE "
);
return
value
.
getSQL
(
builder
).
toString
();
}
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
a36a6634
...
...
@@ -110,8 +110,10 @@ public class Schema extends DbObjectBase {
if
(
system
)
{
return
null
;
}
return
"CREATE SCHEMA IF NOT EXISTS "
+
getSQL
()
+
" AUTHORIZATION "
+
owner
.
getSQL
();
StringBuilder
builder
=
new
StringBuilder
(
"CREATE SCHEMA IF NOT EXISTS "
);
getSQL
(
builder
).
append
(
" AUTHORIZATION "
);
owner
.
getSQL
(
builder
);
return
builder
.
toString
();
}
@Override
...
...
h2/src/main/org/h2/schema/Sequence.java
浏览文件 @
a36a6634
...
...
@@ -211,7 +211,8 @@ public class Sequence extends SchemaObjectBase {
if
(
getBelongsToTable
())
{
return
null
;
}
return
"DROP SEQUENCE IF EXISTS "
+
getSQL
();
StringBuilder
builder
=
new
StringBuilder
(
"DROP SEQUENCE IF EXISTS "
);
return
getSQL
(
builder
).
toString
();
}
@Override
...
...
@@ -223,7 +224,7 @@ public class Sequence extends SchemaObjectBase {
public
synchronized
String
getCreateSQL
()
{
long
v
=
writeWithMargin
?
valueWithMargin
:
value
;
StringBuilder
buff
=
new
StringBuilder
(
"CREATE SEQUENCE "
);
buff
.
append
(
getSQL
()
).
append
(
" START WITH "
).
append
(
v
);
getSQL
(
buff
).
append
(
" START WITH "
).
append
(
v
);
if
(
increment
!=
1
)
{
buff
.
append
(
" INCREMENT BY "
).
append
(
increment
);
}
...
...
h2/src/main/org/h2/schema/TriggerObject.java
浏览文件 @
a36a6634
...
...
@@ -335,7 +335,8 @@ public class TriggerObject extends SchemaObjectBase {
buff
.
append
(
" AFTER "
);
}
buff
.
append
(
getTypeNameList
());
buff
.
append
(
" ON "
).
append
(
targetTable
.
getSQL
());
buff
.
append
(
" ON "
);
targetTable
.
getSQL
(
buff
);
if
(
rowBased
)
{
buff
.
append
(
" FOR EACH ROW"
);
}
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
a36a6634
...
...
@@ -490,7 +490,8 @@ public class Column {
buff
.
append
(
" NULL_TO_DEFAULT"
);
}
if
(
sequence
!=
null
)
{
buff
.
append
(
" SEQUENCE "
).
append
(
sequence
.
getSQL
());
buff
.
append
(
" SEQUENCE "
);
sequence
.
getSQL
(
buff
);
}
if
(
selectivity
!=
0
)
{
buff
.
append
(
" SELECTIVITY "
).
append
(
selectivity
);
...
...
h2/src/main/org/h2/table/TableBase.java
浏览文件 @
a36a6634
...
...
@@ -79,7 +79,9 @@ public abstract class TableBase extends Table {
@Override
public
String
getDropSQL
()
{
return
"DROP TABLE IF EXISTS "
+
getSQL
()
+
" CASCADE"
;
StringBuilder
builder
=
new
StringBuilder
(
"DROP TABLE IF EXISTS "
);
getSQL
(
builder
).
append
(
" CASCADE"
);
return
builder
.
toString
();
}
@Override
...
...
@@ -106,7 +108,7 @@ public abstract class TableBase extends Table {
if
(
isHidden
)
{
buff
.
append
(
"IF NOT EXISTS "
);
}
buff
.
append
(
getSQL
());
getSQL
(
buff
.
builder
());
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
.
builder
(),
comment
);
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
a36a6634
...
...
@@ -791,10 +791,10 @@ public class TableFilter implements ColumnResolver {
return
builder
;
}
if
(
table
.
isView
()
&&
((
TableView
)
table
).
isRecursive
())
{
builder
.
append
(
table
.
getSchema
().
getSQL
()
).
append
(
'.'
);
table
.
getSchema
().
getSQL
(
builder
).
append
(
'.'
);
Parser
.
quoteIdentifier
(
builder
,
table
.
getName
());
}
else
{
builder
.
append
(
table
.
getSQL
()
);
table
.
getSQL
(
builder
);
}
if
(
table
.
isView
()
&&
((
TableView
)
table
).
isInvalid
())
{
throw
DbException
.
get
(
ErrorCode
.
VIEW_IS_INVALID_2
,
table
.
getName
(),
"not compiled"
);
...
...
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
a36a6634
...
...
@@ -354,7 +354,8 @@ public class TableLink extends Table {
@Override
public
String
getDropSQL
()
{
return
"DROP TABLE IF EXISTS "
+
getSQL
();
StringBuilder
builder
=
new
StringBuilder
(
"DROP TABLE IF EXISTS "
);
return
getSQL
(
builder
).
toString
();
}
@Override
...
...
@@ -368,7 +369,8 @@ public class TableLink extends Table {
}
buff
.
append
(
"TEMPORARY "
);
}
buff
.
append
(
"LINKED TABLE "
).
append
(
getSQL
());
buff
.
append
(
"LINKED TABLE "
);
getSQL
(
buff
);
if
(
comment
!=
null
)
{
buff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
buff
,
comment
);
...
...
h2/src/main/org/h2/table/TableSynonym.java
浏览文件 @
a36a6634
...
...
@@ -5,6 +5,7 @@
*/
package
org
.
h2
.
table
;
import
org.h2.command.Parser
;
import
org.h2.command.ddl.CreateSynonymData
;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
...
...
@@ -67,12 +68,18 @@ public class TableSynonym extends SchemaObjectBase {
@Override
public
String
getCreateSQL
()
{
return
"CREATE SYNONYM "
+
getSQL
()
+
" FOR "
+
data
.
synonymForSchema
.
getName
()
+
"."
+
data
.
synonymFor
;
StringBuilder
builder
=
new
StringBuilder
(
"CREATE SYNONYM "
);
getSQL
(
builder
).
append
(
" FOR "
);
Parser
.
quoteIdentifier
(
data
.
synonymForSchema
.
getName
());
builder
.
append
(
'.'
);
Parser
.
quoteIdentifier
(
data
.
synonymFor
);
return
builder
.
toString
();
}
@Override
public
String
getDropSQL
()
{
return
"DROP SYNONYM "
+
getSQL
();
StringBuilder
builder
=
new
StringBuilder
(
"DROP SYNONYM "
);
return
getSQL
(
builder
).
toString
();
}
@Override
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论