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