Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b056815f
提交
b056815f
authored
2月 12, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Column.writeColumns()
上级
4656131a
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
76 行增加
和
78 行删除
+76
-78
Insert.java
h2/src/main/org/h2/command/dml/Insert.java
+14
-17
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+15
-22
Replace.java
h2/src/main/org/h2/command/dml/Replace.java
+12
-15
Column.java
h2/src/main/org/h2/table/Column.java
+19
-0
TableView.java
h2/src/main/org/h2/table/TableView.java
+16
-24
没有找到文件。
h2/src/main/org/h2/command/dml/Insert.java
浏览文件 @
b056815f
...
@@ -269,37 +269,34 @@ public class Insert extends CommandWithValues implements ResultTarget {
...
@@ -269,37 +269,34 @@ public class Insert extends CommandWithValues implements ResultTarget {
@Override
@Override
public
String
getPlanSQL
()
{
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"INSERT INTO "
);
StringBuilder
builder
=
new
StringBuilder
(
"INSERT INTO "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
table
.
getSQL
(
builder
).
append
(
'('
);
for
(
Column
c
:
columns
)
{
Column
.
writeColumns
(
builder
,
columns
);
buff
.
appendExceptFirst
(
", "
);
builder
.
append
(
")\n"
);
c
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
")\n"
);
if
(
insertFromSelect
)
{
if
(
insertFromSelect
)
{
bu
ff
.
append
(
"DIRECT "
);
bu
ilder
.
append
(
"DIRECT "
);
}
}
if
(
sortedInsertMode
)
{
if
(
sortedInsertMode
)
{
bu
ff
.
append
(
"SORTED "
);
bu
ilder
.
append
(
"SORTED "
);
}
}
if
(!
valuesExpressionList
.
isEmpty
())
{
if
(!
valuesExpressionList
.
isEmpty
())
{
bu
ff
.
append
(
"VALUES "
);
bu
ilder
.
append
(
"VALUES "
);
int
row
=
0
;
int
row
=
0
;
if
(
valuesExpressionList
.
size
()
>
1
)
{
if
(
valuesExpressionList
.
size
()
>
1
)
{
bu
ff
.
append
(
'\n'
);
bu
ilder
.
append
(
'\n'
);
}
}
for
(
Expression
[]
expr
:
valuesExpressionList
)
{
for
(
Expression
[]
expr
:
valuesExpressionList
)
{
if
(
row
++
>
0
)
{
if
(
row
++
>
0
)
{
bu
ff
.
append
(
",\n"
);
bu
ilder
.
append
(
",\n"
);
}
}
bu
ff
.
append
(
'('
);
bu
ilder
.
append
(
'('
);
Expression
.
writeExpressions
(
bu
ff
.
builder
()
,
expr
);
Expression
.
writeExpressions
(
bu
ilder
,
expr
);
bu
ff
.
append
(
')'
);
bu
ilder
.
append
(
')'
);
}
}
}
else
{
}
else
{
bu
ff
.
append
(
query
.
getPlanSQL
());
bu
ilder
.
append
(
query
.
getPlanSQL
());
}
}
return
bu
ff
.
toString
();
return
bu
ilder
.
toString
();
}
}
@Override
@Override
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
b056815f
...
@@ -206,38 +206,31 @@ public class Merge extends CommandWithValues {
...
@@ -206,38 +206,31 @@ public class Merge extends CommandWithValues {
@Override
@Override
public
String
getPlanSQL
()
{
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"MERGE INTO "
);
StringBuilder
builder
=
new
StringBuilder
(
"MERGE INTO "
);
targetTable
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
targetTable
.
getSQL
(
builder
).
append
(
'('
);
for
(
Column
c
:
columns
)
{
Column
.
writeColumns
(
builder
,
columns
);
buff
.
appendExceptFirst
(
", "
);
builder
.
append
(
')'
);
c
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
')'
);
if
(
keys
!=
null
)
{
if
(
keys
!=
null
)
{
buff
.
append
(
" KEY("
);
builder
.
append
(
" KEY("
);
buff
.
resetCount
();
Column
.
writeColumns
(
builder
,
keys
);
for
(
Column
c
:
keys
)
{
builder
.
append
(
')'
);
buff
.
appendExceptFirst
(
", "
);
c
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
')'
);
}
}
bu
ff
.
append
(
'\n'
);
bu
ilder
.
append
(
'\n'
);
if
(!
valuesExpressionList
.
isEmpty
())
{
if
(!
valuesExpressionList
.
isEmpty
())
{
bu
ff
.
append
(
"VALUES "
);
bu
ilder
.
append
(
"VALUES "
);
int
row
=
0
;
int
row
=
0
;
for
(
Expression
[]
expr
:
valuesExpressionList
)
{
for
(
Expression
[]
expr
:
valuesExpressionList
)
{
if
(
row
++
>
0
)
{
if
(
row
++
>
0
)
{
bu
ff
.
append
(
", "
);
bu
ilder
.
append
(
", "
);
}
}
bu
ff
.
append
(
'('
);
bu
ilder
.
append
(
'('
);
Expression
.
writeExpressions
(
bu
ff
.
builder
()
,
expr
);
Expression
.
writeExpressions
(
bu
ilder
,
expr
);
bu
ff
.
append
(
')'
);
bu
ilder
.
append
(
')'
);
}
}
}
else
{
}
else
{
bu
ff
.
append
(
query
.
getPlanSQL
());
bu
ilder
.
append
(
query
.
getPlanSQL
());
}
}
return
bu
ff
.
toString
();
return
bu
ilder
.
toString
();
}
}
@Override
@Override
...
...
h2/src/main/org/h2/command/dml/Replace.java
浏览文件 @
b056815f
...
@@ -195,29 +195,26 @@ public class Replace extends CommandWithValues {
...
@@ -195,29 +195,26 @@ public class Replace extends CommandWithValues {
@Override
@Override
public
String
getPlanSQL
()
{
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"REPLACE INTO "
);
StringBuilder
builder
=
new
StringBuilder
(
"REPLACE INTO "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
table
.
getSQL
(
builder
).
append
(
'('
);
for
(
Column
c
:
columns
)
{
Column
.
writeColumns
(
builder
,
columns
);
buff
.
appendExceptFirst
(
", "
);
builder
.
append
(
')'
);
c
.
getSQL
(
buff
.
builder
());
builder
.
append
(
'\n'
);
}
buff
.
append
(
')'
);
buff
.
append
(
'\n'
);
if
(!
valuesExpressionList
.
isEmpty
())
{
if
(!
valuesExpressionList
.
isEmpty
())
{
bu
ff
.
append
(
"VALUES "
);
bu
ilder
.
append
(
"VALUES "
);
int
row
=
0
;
int
row
=
0
;
for
(
Expression
[]
expr
:
valuesExpressionList
)
{
for
(
Expression
[]
expr
:
valuesExpressionList
)
{
if
(
row
++
>
0
)
{
if
(
row
++
>
0
)
{
bu
ff
.
append
(
", "
);
bu
ilder
.
append
(
", "
);
}
}
bu
ff
.
append
(
'('
);
bu
ilder
.
append
(
'('
);
Expression
.
writeExpressions
(
bu
ff
.
builder
()
,
expr
);
Expression
.
writeExpressions
(
bu
ilder
,
expr
);
bu
ff
.
append
(
')'
);
bu
ilder
.
append
(
')'
);
}
}
}
else
{
}
else
{
bu
ff
.
append
(
query
.
getPlanSQL
());
bu
ilder
.
append
(
query
.
getPlanSQL
());
}
}
return
bu
ff
.
toString
();
return
bu
ilder
.
toString
();
}
}
@Override
@Override
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
b056815f
...
@@ -86,6 +86,25 @@ public class Column {
...
@@ -86,6 +86,25 @@ public class Column {
private
boolean
visible
=
true
;
private
boolean
visible
=
true
;
private
Domain
domain
;
private
Domain
domain
;
/**
* Appends the specified columns to the specified builder.
*
* @param builder
* string builder
* @param columns
* columns
* @return the specified string builder
*/
public
static
StringBuilder
writeColumns
(
StringBuilder
builder
,
Column
[]
columns
)
{
for
(
int
i
=
0
,
l
=
columns
.
length
;
i
<
l
;
i
++)
{
if
(
i
>
0
)
{
builder
.
append
(
", "
);
}
columns
[
i
].
getSQL
(
builder
);
}
return
builder
;
}
public
Column
(
String
name
,
int
valueType
)
{
public
Column
(
String
name
,
int
valueType
)
{
this
(
name
,
TypeInfo
.
getTypeInfo
(
valueType
));
this
(
name
,
TypeInfo
.
getTypeInfo
(
valueType
));
}
}
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
b056815f
...
@@ -35,7 +35,6 @@ import org.h2.result.Row;
...
@@ -35,7 +35,6 @@ import org.h2.result.Row;
import
org.h2.result.SortOrder
;
import
org.h2.result.SortOrder
;
import
org.h2.schema.Schema
;
import
org.h2.schema.Schema
;
import
org.h2.util.ColumnNamer
;
import
org.h2.util.ColumnNamer
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
import
org.h2.util.Utils
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.TypeInfo
;
...
@@ -323,40 +322,33 @@ public class TableView extends Table {
...
@@ -323,40 +322,33 @@ public class TableView extends Table {
return
getCreateSQL
(
orReplace
,
force
,
getSQL
());
return
getCreateSQL
(
orReplace
,
force
,
getSQL
());
}
}
private
String
getCreateSQL
(
boolean
orReplace
,
boolean
force
,
private
String
getCreateSQL
(
boolean
orReplace
,
boolean
force
,
String
quotedName
)
{
String
quotedName
)
{
StringBuilder
builder
=
new
StringBuilder
(
"CREATE "
);
StatementBuilder
buff
=
new
StatementBuilder
(
"CREATE "
);
if
(
orReplace
)
{
if
(
orReplace
)
{
bu
ff
.
append
(
"OR REPLACE "
);
bu
ilder
.
append
(
"OR REPLACE "
);
}
}
if
(
force
)
{
if
(
force
)
{
bu
ff
.
append
(
"FORCE "
);
bu
ilder
.
append
(
"FORCE "
);
}
}
bu
ff
.
append
(
"VIEW "
);
bu
ilder
.
append
(
"VIEW "
);
if
(
isTableExpression
)
{
if
(
isTableExpression
)
{
bu
ff
.
append
(
"TABLE_EXPRESSION "
);
bu
ilder
.
append
(
"TABLE_EXPRESSION "
);
}
}
bu
ff
.
append
(
quotedName
);
bu
ilder
.
append
(
quotedName
);
if
(
comment
!=
null
)
{
if
(
comment
!=
null
)
{
bu
ff
.
append
(
" COMMENT "
);
bu
ilder
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
bu
ff
.
builder
()
,
comment
);
StringUtils
.
quoteStringSQL
(
bu
ilder
,
comment
);
}
}
if
(
columns
!=
null
&&
columns
.
length
>
0
)
{
if
(
columns
!=
null
&&
columns
.
length
>
0
)
{
buff
.
append
(
'('
);
builder
.
append
(
'('
);
for
(
Column
c
:
columns
)
{
Column
.
writeColumns
(
builder
,
columns
);
buff
.
appendExceptFirst
(
", "
);
builder
.
append
(
')'
);
c
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
')'
);
}
else
if
(
columnTemplates
!=
null
)
{
}
else
if
(
columnTemplates
!=
null
)
{
buff
.
append
(
'('
);
builder
.
append
(
'('
);
for
(
Column
c
:
columnTemplates
)
{
Column
.
writeColumns
(
builder
,
columnTemplates
);
buff
.
appendExceptFirst
(
", "
);
builder
.
append
(
')'
);
buff
.
append
(
c
.
getName
());
}
buff
.
append
(
')'
);
}
}
return
bu
ff
.
append
(
" AS\n"
).
append
(
querySQL
).
toString
();
return
bu
ilder
.
append
(
" AS\n"
).
append
(
querySQL
).
toString
();
}
}
@Override
@Override
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论