Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4656131a
提交
4656131a
authored
2月 12, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add and use Column.getSQL(StringBuilder)
上级
a6c94ddf
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
35 行增加
和
25 行删除
+35
-25
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+7
-3
Analyze.java
h2/src/main/org/h2/command/ddl/Analyze.java
+2
-1
Insert.java
h2/src/main/org/h2/command/dml/Insert.java
+2
-2
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+4
-4
Replace.java
h2/src/main/org/h2/command/dml/Replace.java
+3
-3
Update.java
h2/src/main/org/h2/command/dml/Update.java
+1
-1
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+1
-1
IndexCondition.java
h2/src/main/org/h2/index/IndexCondition.java
+1
-1
LinkedIndex.java
h2/src/main/org/h2/index/LinkedIndex.java
+5
-5
Column.java
h2/src/main/org/h2/table/Column.java
+4
-0
IndexColumn.java
h2/src/main/org/h2/table/IndexColumn.java
+4
-3
TableView.java
h2/src/main/org/h2/table/TableView.java
+1
-1
没有找到文件。
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
4656131a
...
@@ -409,9 +409,13 @@ public class AlterTableAlterColumn extends CommandWithColumns {
...
@@ -409,9 +409,13 @@ public class AlterTableAlterColumn extends CommandWithColumns {
if
(
type
==
CommandInterface
.
ALTER_TABLE_ADD_COLUMN
&&
if
(
type
==
CommandInterface
.
ALTER_TABLE_ADD_COLUMN
&&
columnsToAdd
!=
null
&&
columnsToAdd
.
contains
(
nc
))
{
columnsToAdd
!=
null
&&
columnsToAdd
.
contains
(
nc
))
{
Expression
def
=
nc
.
getDefaultExpression
();
Expression
def
=
nc
.
getDefaultExpression
();
columnList
.
append
(
def
==
null
?
"NULL"
:
def
.
getSQL
());
if
(
def
==
null
)
{
columnList
.
append
(
"NULL"
);
}
else
{
def
.
getSQL
(
columnList
);
}
}
else
{
}
else
{
columnList
.
append
(
nc
.
getSQL
()
);
nc
.
getSQL
(
columnList
);
}
}
}
}
String
newTableName
=
newTable
.
getName
();
String
newTableName
=
newTable
.
getName
();
...
@@ -589,7 +593,7 @@ public class AlterTableAlterColumn extends CommandWithColumns {
...
@@ -589,7 +593,7 @@ public class AlterTableAlterColumn extends CommandWithColumns {
private
void
checkNoNullValues
(
Table
table
)
{
private
void
checkNoNullValues
(
Table
table
)
{
StringBuilder
builder
=
new
StringBuilder
(
"SELECT COUNT(*) FROM "
);
StringBuilder
builder
=
new
StringBuilder
(
"SELECT COUNT(*) FROM "
);
table
.
getSQL
(
builder
).
append
(
" WHERE "
);
table
.
getSQL
(
builder
).
append
(
" WHERE "
);
builder
.
append
(
oldColumn
.
getSQL
()
).
append
(
" IS NULL"
);
oldColumn
.
getSQL
(
builder
).
append
(
" IS NULL"
);
String
sql
=
builder
.
toString
();
String
sql
=
builder
.
toString
();
Prepared
command
=
session
.
prepare
(
sql
);
Prepared
command
=
session
.
prepare
(
sql
);
ResultInterface
result
=
command
.
query
(
0
);
ResultInterface
result
=
command
.
query
(
0
);
...
...
h2/src/main/org/h2/command/ddl/Analyze.java
浏览文件 @
4656131a
...
@@ -110,7 +110,8 @@ public class Analyze extends DefineCommand {
...
@@ -110,7 +110,8 @@ public class Analyze extends DefineCommand {
// the selectivity is not required
// the selectivity is not required
buff
.
append
(
"MAX(NULL)"
);
buff
.
append
(
"MAX(NULL)"
);
}
else
{
}
else
{
buff
.
append
(
"SELECTIVITY("
).
append
(
col
.
getSQL
()).
append
(
')'
);
buff
.
append
(
"SELECTIVITY("
);
col
.
getSQL
(
buff
.
builder
()).
append
(
')'
);
}
}
}
}
buff
.
append
(
" FROM "
);
buff
.
append
(
" FROM "
);
...
...
h2/src/main/org/h2/command/dml/Insert.java
浏览文件 @
4656131a
...
@@ -273,7 +273,7 @@ public class Insert extends CommandWithValues implements ResultTarget {
...
@@ -273,7 +273,7 @@ public class Insert extends CommandWithValues implements ResultTarget {
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
c
:
columns
)
{
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
c
.
getSQL
(
buff
.
builder
());
}
}
buff
.
append
(
")\n"
);
buff
.
append
(
")\n"
);
if
(
insertFromSelect
)
{
if
(
insertFromSelect
)
{
...
@@ -409,7 +409,7 @@ public class Insert extends CommandWithValues implements ResultTarget {
...
@@ -409,7 +409,7 @@ public class Insert extends CommandWithValues implements ResultTarget {
for
(
Column
column
:
duplicateKeyAssignmentMap
.
keySet
())
{
for
(
Column
column
:
duplicateKeyAssignmentMap
.
keySet
())
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
Expression
ex
=
duplicateKeyAssignmentMap
.
get
(
column
);
Expression
ex
=
duplicateKeyAssignmentMap
.
get
(
column
);
buff
.
append
(
column
.
getSQL
()).
append
(
'='
);
column
.
getSQL
(
buff
.
builder
()).
append
(
'='
);
ex
.
getSQL
(
buff
.
builder
());
ex
.
getSQL
(
buff
.
builder
());
}
}
buff
.
append
(
" WHERE "
);
buff
.
append
(
" WHERE "
);
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
4656131a
...
@@ -210,7 +210,7 @@ public class Merge extends CommandWithValues {
...
@@ -210,7 +210,7 @@ public class Merge extends CommandWithValues {
targetTable
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
targetTable
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
c
:
columns
)
{
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
c
.
getSQL
(
buff
.
builder
());
}
}
buff
.
append
(
')'
);
buff
.
append
(
')'
);
if
(
keys
!=
null
)
{
if
(
keys
!=
null
)
{
...
@@ -218,7 +218,7 @@ public class Merge extends CommandWithValues {
...
@@ -218,7 +218,7 @@ public class Merge extends CommandWithValues {
buff
.
resetCount
();
buff
.
resetCount
();
for
(
Column
c
:
keys
)
{
for
(
Column
c
:
keys
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
c
.
getSQL
(
buff
.
builder
());
}
}
buff
.
append
(
')'
);
buff
.
append
(
')'
);
}
}
...
@@ -279,13 +279,13 @@ public class Merge extends CommandWithValues {
...
@@ -279,13 +279,13 @@ public class Merge extends CommandWithValues {
targetTable
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
targetTable
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
for
(
Column
c
:
columns
)
{
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
()).
append
(
"=?"
);
c
.
getSQL
(
buff
.
builder
()).
append
(
"=?"
);
}
}
buff
.
append
(
" WHERE "
);
buff
.
append
(
" WHERE "
);
buff
.
resetCount
();
buff
.
resetCount
();
for
(
Column
c
:
keys
)
{
for
(
Column
c
:
keys
)
{
buff
.
appendExceptFirst
(
" AND "
);
buff
.
appendExceptFirst
(
" AND "
);
buff
.
append
(
c
.
getSQL
()).
append
(
"=?"
);
c
.
getSQL
(
buff
.
builder
()).
append
(
"=?"
);
}
}
String
sql
=
buff
.
toString
();
String
sql
=
buff
.
toString
();
update
=
session
.
prepare
(
sql
);
update
=
session
.
prepare
(
sql
);
...
...
h2/src/main/org/h2/command/dml/Replace.java
浏览文件 @
4656131a
...
@@ -199,7 +199,7 @@ public class Replace extends CommandWithValues {
...
@@ -199,7 +199,7 @@ public class Replace extends CommandWithValues {
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
c
:
columns
)
{
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
c
.
getSQL
(
buff
.
builder
());
}
}
buff
.
append
(
')'
);
buff
.
append
(
')'
);
buff
.
append
(
'\n'
);
buff
.
append
(
'\n'
);
...
@@ -273,13 +273,13 @@ public class Replace extends CommandWithValues {
...
@@ -273,13 +273,13 @@ public class Replace extends CommandWithValues {
table
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
for
(
Column
c
:
columns
)
{
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
()).
append
(
"=?"
);
c
.
getSQL
(
buff
.
builder
()).
append
(
"=?"
);
}
}
buff
.
append
(
" WHERE "
);
buff
.
append
(
" WHERE "
);
buff
.
resetCount
();
buff
.
resetCount
();
for
(
Column
c
:
keys
)
{
for
(
Column
c
:
keys
)
{
buff
.
appendExceptFirst
(
" AND "
);
buff
.
appendExceptFirst
(
" AND "
);
buff
.
append
(
c
.
getSQL
()).
append
(
"=?"
);
c
.
getSQL
(
buff
.
builder
()).
append
(
"=?"
);
}
}
String
sql
=
buff
.
toString
();
String
sql
=
buff
.
toString
();
update
=
session
.
prepare
(
sql
);
update
=
session
.
prepare
(
sql
);
...
...
h2/src/main/org/h2/command/dml/Update.java
浏览文件 @
4656131a
...
@@ -218,7 +218,7 @@ public class Update extends Prepared {
...
@@ -218,7 +218,7 @@ public class Update extends Prepared {
builder
.
append
(
",\n "
);
builder
.
append
(
",\n "
);
}
}
Column
c
=
columns
.
get
(
i
);
Column
c
=
columns
.
get
(
i
);
builder
.
append
(
c
.
getSQL
()
).
append
(
" = "
);
c
.
getSQL
(
builder
).
append
(
" = "
);
expressionMap
.
get
(
c
).
getSQL
(
builder
);
expressionMap
.
get
(
c
).
getSQL
(
builder
);
}
}
if
(
condition
!=
null
)
{
if
(
condition
!=
null
)
{
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
4656131a
...
@@ -69,7 +69,7 @@ public class ExpressionColumn extends Expression {
...
@@ -69,7 +69,7 @@ public class ExpressionColumn extends Expression {
if
(
derivedName
!=
null
)
{
if
(
derivedName
!=
null
)
{
Parser
.
quoteIdentifier
(
builder
,
derivedName
);
Parser
.
quoteIdentifier
(
builder
,
derivedName
);
}
else
{
}
else
{
builder
.
append
(
column
.
getSQL
()
);
column
.
getSQL
(
builder
);
}
}
}
else
{
}
else
{
Parser
.
quoteIdentifier
(
builder
,
columnName
);
Parser
.
quoteIdentifier
(
builder
,
columnName
);
...
...
h2/src/main/org/h2/index/IndexCondition.java
浏览文件 @
4656131a
...
@@ -178,7 +178,7 @@ public class IndexCondition {
...
@@ -178,7 +178,7 @@ public class IndexCondition {
return
"FALSE"
;
return
"FALSE"
;
}
}
StringBuilder
builder
=
new
StringBuilder
();
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
column
.
getSQL
()
);
column
.
getSQL
(
builder
);
switch
(
compareType
)
{
switch
(
compareType
)
{
case
Comparison
.
EQUAL
:
case
Comparison
.
EQUAL
:
builder
.
append
(
" = "
);
builder
.
append
(
" = "
);
...
...
h2/src/main/org/h2/index/LinkedIndex.java
浏览文件 @
4656131a
...
@@ -95,7 +95,7 @@ public class LinkedIndex extends BaseIndex {
...
@@ -95,7 +95,7 @@ public class LinkedIndex extends BaseIndex {
buff
.
appendOnlyFirst
(
" WHERE "
);
buff
.
appendOnlyFirst
(
" WHERE "
);
buff
.
appendExceptFirst
(
" AND "
);
buff
.
appendExceptFirst
(
" AND "
);
Column
col
=
table
.
getColumn
(
i
);
Column
col
=
table
.
getColumn
(
i
);
buff
.
append
(
col
.
getSQL
());
col
.
getSQL
(
buff
.
builder
());
if
(
v
==
ValueNull
.
INSTANCE
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
buff
.
append
(
" IS NULL"
);
buff
.
append
(
" IS NULL"
);
}
else
{
}
else
{
...
@@ -111,7 +111,7 @@ public class LinkedIndex extends BaseIndex {
...
@@ -111,7 +111,7 @@ public class LinkedIndex extends BaseIndex {
buff
.
appendOnlyFirst
(
" WHERE "
);
buff
.
appendOnlyFirst
(
" WHERE "
);
buff
.
appendExceptFirst
(
" AND "
);
buff
.
appendExceptFirst
(
" AND "
);
Column
col
=
table
.
getColumn
(
i
);
Column
col
=
table
.
getColumn
(
i
);
buff
.
append
(
col
.
getSQL
());
col
.
getSQL
(
buff
.
builder
());
if
(
v
==
ValueNull
.
INSTANCE
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
buff
.
append
(
" IS NULL"
);
buff
.
append
(
" IS NULL"
);
}
else
{
}
else
{
...
@@ -192,7 +192,7 @@ public class LinkedIndex extends BaseIndex {
...
@@ -192,7 +192,7 @@ public class LinkedIndex extends BaseIndex {
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
();
i
++)
{
buff
.
appendExceptFirst
(
"AND "
);
buff
.
appendExceptFirst
(
"AND "
);
Column
col
=
table
.
getColumn
(
i
);
Column
col
=
table
.
getColumn
(
i
);
buff
.
append
(
col
.
getSQL
());
col
.
getSQL
(
buff
.
builder
());
Value
v
=
row
.
getValue
(
i
);
Value
v
=
row
.
getValue
(
i
);
if
(
isNull
(
v
))
{
if
(
isNull
(
v
))
{
buff
.
append
(
" IS NULL "
);
buff
.
append
(
" IS NULL "
);
...
@@ -227,7 +227,7 @@ public class LinkedIndex extends BaseIndex {
...
@@ -227,7 +227,7 @@ public class LinkedIndex extends BaseIndex {
buff
.
append
(
targetTableName
).
append
(
" SET "
);
buff
.
append
(
targetTableName
).
append
(
" SET "
);
for
(
int
i
=
0
;
i
<
newRow
.
getColumnCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
newRow
.
getColumnCount
();
i
++)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
table
.
getColumn
(
i
).
getSQL
()).
append
(
'='
);
table
.
getColumn
(
i
).
getSQL
(
buff
.
builder
()).
append
(
'='
);
Value
v
=
newRow
.
getValue
(
i
);
Value
v
=
newRow
.
getValue
(
i
);
if
(
v
==
null
)
{
if
(
v
==
null
)
{
buff
.
append
(
"DEFAULT"
);
buff
.
append
(
"DEFAULT"
);
...
@@ -241,7 +241,7 @@ public class LinkedIndex extends BaseIndex {
...
@@ -241,7 +241,7 @@ public class LinkedIndex extends BaseIndex {
for
(
int
i
=
0
;
i
<
oldRow
.
getColumnCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
oldRow
.
getColumnCount
();
i
++)
{
Column
col
=
table
.
getColumn
(
i
);
Column
col
=
table
.
getColumn
(
i
);
buff
.
appendExceptFirst
(
" AND "
);
buff
.
appendExceptFirst
(
" AND "
);
buff
.
append
(
col
.
getSQL
());
col
.
getSQL
(
buff
.
builder
());
Value
v
=
oldRow
.
getValue
(
i
);
Value
v
=
oldRow
.
getValue
(
i
);
if
(
isNull
(
v
))
{
if
(
isNull
(
v
))
{
buff
.
append
(
" IS NULL"
);
buff
.
append
(
" IS NULL"
);
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
4656131a
...
@@ -248,6 +248,10 @@ public class Column {
...
@@ -248,6 +248,10 @@ public class Column {
return
Parser
.
quoteIdentifier
(
name
);
return
Parser
.
quoteIdentifier
(
name
);
}
}
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
Parser
.
quoteIdentifier
(
builder
,
name
);
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
...
...
h2/src/main/org/h2/table/IndexColumn.java
浏览文件 @
4656131a
...
@@ -35,9 +35,10 @@ public class IndexColumn {
...
@@ -35,9 +35,10 @@ public class IndexColumn {
* @return the SQL snippet
* @return the SQL snippet
*/
*/
public
String
getSQL
()
{
public
String
getSQL
()
{
StringBuilder
buff
=
new
StringBuilder
(
column
.
getSQL
());
StringBuilder
builder
=
new
StringBuilder
();
SortOrder
.
typeToString
(
buff
,
sortType
);
column
.
getSQL
(
builder
);
return
buff
.
toString
();
SortOrder
.
typeToString
(
builder
,
sortType
);
return
builder
.
toString
();
}
}
/**
/**
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
4656131a
...
@@ -345,7 +345,7 @@ public class TableView extends Table {
...
@@ -345,7 +345,7 @@ public class TableView extends Table {
buff
.
append
(
'('
);
buff
.
append
(
'('
);
for
(
Column
c
:
columns
)
{
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getSQL
());
c
.
getSQL
(
buff
.
builder
());
}
}
buff
.
append
(
')'
);
buff
.
append
(
')'
);
}
else
if
(
columnTemplates
!=
null
)
{
}
else
if
(
columnTemplates
!=
null
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论