Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2f6921ae
提交
2f6921ae
authored
10月 08, 2017
作者:
Owner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed debug statements
上级
920722fc
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
10 行增加
和
206 行删除
+10
-206
Parser.java
h2/src/main/org/h2/command/Parser.java
+4
-38
MergeUsing.java
h2/src/main/org/h2/command/dml/MergeUsing.java
+6
-158
Comparison.java
h2/src/main/org/h2/expression/Comparison.java
+0
-2
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+0
-2
Table.java
h2/src/main/org/h2/table/Table.java
+0
-3
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+0
-2
TestMergeUsing.java
h2/src/test/org/h2/test/db/TestMergeUsing.java
+0
-1
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
2f6921ae
...
...
@@ -1094,29 +1094,11 @@ public class Parser {
}
return
command
;
}
/*
* TODO finish writing this MergeUsing
MERGE INTO targetTableName [[AS] t_alias] USING table_reference [[AS} s_alias] ON ( condition ,...)
WHEN MATCHED THEN
[UPDATE SET column1 = value1 [, column2 = value2 ... WHERE ...]
[DELETE WHERE ...]
WHEN NOT MATCHED THEN
INSERT (column1 [, column2 ...]) VALUES (value1 [, value2 ...]);
table_reference ::= table | view | ( sub-query )
The current implementation (for comparison) uses this syntax:
MERGE INTO tablename [(columnName1,...)]
[KEY (keyColumnName1,...)]
[ VALUES (expression1,...) | SELECT ...]
*/
/* TODO: Finish coding parseMergeUsing */
private
MergeUsing
parseMergeUsing
(
Merge
oldCommand
,
int
start
)
{
/* TODO: not sure why schema name is reset to null */
if
(
schemaName
==
null
){
schemaName
=
session
.
getCurrentSchemaName
();
System
.
out
.
println
(
"schemaName="
+
schemaName
);
}
Schema
schema
=
getSchema
();
...
...
@@ -1125,29 +1107,25 @@ public class Parser {
currentPrepared
=
command
;
if
(
readIf
(
"("
))
{
System
.
out
.
println
(
"pre select schema="
+
getSchema
()+
",schemaName="
+
schemaName
);
/* a select query is supplied */
if
(
isSelect
())
{
command
.
setQuery
(
parseSelect
());
System
.
out
.
println
(
"post select schema="
+
getSchema
()+
",schemaName="
+
schemaName
);
schemaName
=
savedSchemaName
;
System
.
out
.
println
(
"post2 select schema="
+
getSchema
()+
",schemaName="
+
schemaName
);
read
(
")"
);
}
command
.
setQueryAlias
(
readFromAlias
(
null
,
Arrays
.
asList
(
"ON"
)));
String
[]
querySQLOutput
=
new
String
[]{
null
};
List
<
Column
>
columnTemplateList
=
createQueryColumnTemplateList
(
null
,
command
.
getQuery
(),
querySQLOutput
);
System
.
out
.
println
(
"pre:alias="
+
command
.
getQueryAlias
()+
",sql="
+
querySQLOutput
[
0
]+
",ctlist="
+
columnTemplateList
+
",schema="
+
getSchema
()+
",schemaName="
+
schemaName
);
TableView
temporarySourceTableView
=
createTemporarySessionView
(
command
.
getQueryAlias
(),
querySQLOutput
[
0
],
columnTemplateList
,
false
,
false
);
command
.
setTemporaryTableView
(
temporarySourceTableView
);
System
.
out
.
println
(
"sourceTableFilter with tableOrView="
+
temporarySourceTableView
);
System
.
out
.
println
(
"sourceTableFilter rightsChecked="
+
rightsChecked
);
TableFilter
sourceTableFilter
=
new
TableFilter
(
session
,
temporarySourceTableView
,
command
.
getQueryAlias
(),
rightsChecked
,
(
Select
)
command
.
getQuery
(),
0
,
null
);
command
.
setSourceTableFilter
(
sourceTableFilter
);
}
else
{
/* Its a table name, simulate a query by building a select query for the table */
List
<
String
>
excludeIdentifiers
=
Arrays
.
asList
(
"ON"
);
TableFilter
sourceTableFilter
=
readSimpleTableFilterWithAliasExcludes
(
0
,
excludeIdentifiers
);
command
.
setSourceTableFilter
(
sourceTableFilter
);
...
...
@@ -1157,9 +1135,7 @@ public class Parser {
if
(
sourceTableFilter
.
getTableAlias
()!=
null
){
buff
.
append
(
" AS "
+
sourceTableFilter
.
getTableAlias
());
}
//ArrayList<Value> paramValues = New.arrayList();
Prepared
preparedQuery
=
prepare
(
session
,
buff
.
toString
(),
null
/*paramValues*/
);
System
.
out
.
println
(
"class="
+
preparedQuery
.
getClass
());
command
.
setQuery
((
Select
)
preparedQuery
);
}
...
...
@@ -1197,14 +1173,6 @@ public class Parser {
}
}
if
(
command
.
getQueryAlias
()!=
null
){
if
(
schema
==
null
){
System
.
out
.
println
(
"Why oh why is the schema null???"
);
System
.
out
.
println
(
"schemaName="
+
schemaName
);
throw
DbException
.
getUnsupportedException
(
"unexpected null schema"
);
}
}
setSQL
(
command
,
"MERGE"
,
start
);
return
command
;
}
...
...
@@ -5198,7 +5166,6 @@ public class Parser {
withQuery
.
prepare
();
querySQLOutput
[
0
]
=
StringUtils
.
cache
(
withQuery
.
getPlanSQL
());
ArrayList
<
Expression
>
withExpressions
=
withQuery
.
getExpressions
();
System
.
out
.
println
(
"withExpressions="
+
withExpressions
);
for
(
int
i
=
0
;
i
<
withExpressions
.
size
();
++
i
)
{
Expression
columnExp
=
withExpressions
.
get
(
i
);
// use the passed in column name if supplied, otherwise use alias (if used) otherwise use column name
...
...
@@ -5225,7 +5192,6 @@ public class Parser {
// No easy way to determine if this is a recursive query up front, so we just compile
// it twice - once without the flag set, and if we didn't see a recursive term,
// then we just compile it again.
System
.
out
.
println
(
"createTemporarySessionView="
+
tempViewName
);
TableView
view
=
new
TableView
(
schema
,
id
,
tempViewName
,
querySQL
,
parameters
,
columnTemplateList
.
toArray
(
new
Column
[
0
]),
session
,
allowRecursiveQueryDetection
/* recursive */
,
false
);
...
...
h2/src/main/org/h2/command/dml/MergeUsing.java
浏览文件 @
2f6921ae
差异被折叠。
点击展开。
h2/src/main/org/h2/expression/Comparison.java
浏览文件 @
2f6921ae
...
...
@@ -492,10 +492,8 @@ public class Comparison extends Condition {
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
)
{
System
.
out
.
println
(
"Checking left:"
+
left
+
" against "
+
resolver
);
left
.
mapColumns
(
resolver
,
level
);
if
(
right
!=
null
)
{
System
.
out
.
println
(
"Checking right:"
+
right
+
" against "
+
resolver
);
right
.
mapColumns
(
resolver
,
level
);
}
}
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
2f6921ae
...
...
@@ -117,11 +117,9 @@ public class ExpressionColumn extends Expression {
queryLevel
=
level
;
column
=
col
;
this
.
columnResolver
=
resolver
;
System
.
out
.
println
(
"mapColumn: Setting resolver:"
+
col
+
"@"
+
System
.
identityHashCode
(
col
)+
" by resolver "
+
resolver
+
"-"
+
resolver
.
getClass
());
}
else
if
(
queryLevel
==
level
&&
this
.
columnResolver
!=
resolver
)
{
if
(
resolver
instanceof
SelectListColumnResolver
)
{
// ignore - already mapped, that's ok
System
.
out
.
println
(
"mapColumn: Already mapped:"
+
col
+
"@"
+
System
.
identityHashCode
(
col
)+
" by resolver "
+
resolver
+
"-"
+
resolver
.
getClass
());
}
else
{
throw
DbException
.
get
(
ErrorCode
.
AMBIGUOUS_COLUMN_NAME_1
,
columnName
);
}
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
2f6921ae
...
...
@@ -85,9 +85,6 @@ public abstract class Table extends SchemaObjectBase {
public
Table
(
Schema
schema
,
int
id
,
String
name
,
boolean
persistIndexes
,
boolean
persistData
)
{
System
.
out
.
println
(
"newTable:schema="
+
schema
);
System
.
out
.
println
(
"newTable:name="
+
name
);
System
.
out
.
println
(
"newTable:schema="
+
schema
+
",database="
+
schema
.
getDatabase
());
columnMap
=
schema
.
getDatabase
().
newStringMap
();
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
TABLE
);
this
.
persistIndexes
=
persistIndexes
;
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
2f6921ae
...
...
@@ -567,8 +567,6 @@ public class TableFilter implements ColumnResolver {
private
void
checkTimeout
()
{
session
.
checkCanceled
();
// System.out.println(this.alias+ " " + table.getName() + ": " +
// scanCount);
}
/**
...
...
h2/src/test/org/h2/test/db/TestMergeUsing.java
浏览文件 @
2f6921ae
...
...
@@ -191,7 +191,6 @@ public class TestMergeUsing extends TestBase {
while
(
rs
.
next
())
{
rowCount
++;
diffBuffer
.
append
(
"|"
);
System
.
out
.
println
(
"rs.getMetaData().getColumnCount()="
+
rs
.
getMetaData
().
getColumnCount
());
for
(
int
ndx
=
1
;
ndx
<=
rs
.
getMetaData
().
getColumnCount
();
ndx
++){
diffBuffer
.
append
(
rs
.
getObject
(
ndx
));
diffBuffer
.
append
(
"|\n"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论