Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
83e4f3bd
Unverified
提交
83e4f3bd
authored
3月 22, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
3月 22, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1011 from katzyn/mergeUsing
Handle tables with specified schema in Parser.parseMergeUsing()
上级
ca7eaa69
7fa5c7da
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
60 行增加
和
12 行删除
+60
-12
changelog.html
h2/src/docsrc/html/changelog.html
+4
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+13
-10
mergeUsing.sql
h2/src/test/org/h2/test/scripts/dml/mergeUsing.sql
+42
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
83e4f3bd
...
@@ -21,6 +21,10 @@ Change Log
...
@@ -21,6 +21,10 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Issue #1010: MERGE USING table not found with qualified table
</li>
<li>
PR #1009: Fix ARRAY_AGG with ORDER BY and refactor aggregates
</li>
<li>
Issue #1006: "Empty enums are not allowed" in 1.4.197 (mode=MYSQL)
<li>
Issue #1006: "Empty enums are not allowed" in 1.4.197 (mode=MYSQL)
</li>
</li>
<li>
PR #1007: Copy also SRID in ValueGeometry.getGeometry()
<li>
PR #1007: Copy also SRID in ValueGeometry.getGeometry()
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
83e4f3bd
...
@@ -1150,11 +1150,8 @@ public class Parser {
...
@@ -1150,11 +1150,8 @@ public class Parser {
TableFilter
sourceTableFilter
=
readSimpleTableFilter
(
0
,
excludeIdentifiers
);
TableFilter
sourceTableFilter
=
readSimpleTableFilter
(
0
,
excludeIdentifiers
);
command
.
setSourceTableFilter
(
sourceTableFilter
);
command
.
setSourceTableFilter
(
sourceTableFilter
);
StringBuilder
buff
=
new
StringBuilder
(
"SELECT * FROM "
)
StringBuilder
buff
=
new
StringBuilder
(
"SELECT * FROM "
);
.
append
(
sourceTableFilter
.
getTable
().
getName
());
appendTableWithSchemaAndAlias
(
buff
,
sourceTableFilter
.
getTable
(),
sourceTableFilter
.
getTableAlias
());
if
(
sourceTableFilter
.
getTableAlias
()
!=
null
)
{
buff
.
append
(
" AS "
).
append
(
sourceTableFilter
.
getTableAlias
());
}
Prepared
preparedQuery
=
prepare
(
session
,
buff
.
toString
(),
null
/*paramValues*/
);
Prepared
preparedQuery
=
prepare
(
session
,
buff
.
toString
(),
null
/*paramValues*/
);
command
.
setQuery
((
Select
)
preparedQuery
);
command
.
setQuery
((
Select
)
preparedQuery
);
...
@@ -1197,11 +1194,9 @@ public class Parser {
...
@@ -1197,11 +1194,9 @@ public class Parser {
// build and prepare the targetMatchQuery ready to test each rows
// build and prepare the targetMatchQuery ready to test each rows
// existence in the target table (using source row to match)
// existence in the target table (using source row to match)
StringBuilder
targetMatchQuerySQL
=
new
StringBuilder
(
StringBuilder
targetMatchQuerySQL
=
new
StringBuilder
(
"SELECT _ROWID_ FROM "
);
"SELECT _ROWID_ FROM "
+
command
.
getTargetTable
().
getName
());
appendTableWithSchemaAndAlias
(
targetMatchQuerySQL
,
command
.
getTargetTable
(),
if
(
command
.
getTargetTableFilter
().
getTableAlias
()
!=
null
)
{
command
.
getTargetTableFilter
().
getTableAlias
());
targetMatchQuerySQL
.
append
(
" AS "
).
append
(
command
.
getTargetTableFilter
().
getTableAlias
());
}
targetMatchQuerySQL
targetMatchQuerySQL
.
append
(
" WHERE "
).
append
(
command
.
getOnCondition
().
getSQL
());
.
append
(
" WHERE "
).
append
(
command
.
getOnCondition
().
getSQL
());
command
.
setTargetMatchQuery
(
command
.
setTargetMatchQuery
(
...
@@ -1210,6 +1205,14 @@ public class Parser {
...
@@ -1210,6 +1205,14 @@ public class Parser {
return
command
;
return
command
;
}
}
private
static
void
appendTableWithSchemaAndAlias
(
StringBuilder
buff
,
Table
table
,
String
alias
)
{
buff
.
append
(
quoteIdentifier
(
table
.
getSchema
().
getName
()))
.
append
(
'.'
).
append
(
quoteIdentifier
(
table
.
getName
()));
if
(
alias
!=
null
)
{
buff
.
append
(
" AS "
).
append
(
quoteIdentifier
(
alias
));
}
}
private
Insert
parseInsert
()
{
private
Insert
parseInsert
()
{
Insert
command
=
new
Insert
(
session
);
Insert
command
=
new
Insert
(
session
);
currentPrepared
=
command
;
currentPrepared
=
command
;
...
...
h2/src/test/org/h2/test/scripts/dml/mergeUsing.sql
浏览文件 @
83e4f3bd
...
@@ -30,4 +30,45 @@ EXPLAIN PLAN
...
@@ -30,4 +30,45 @@ EXPLAIN PLAN
INSERT
(
ID
,
NAME
)
VALUES
(
S
.
ID
,
S
.
NAME
);
INSERT
(
ID
,
NAME
)
VALUES
(
S
.
ID
,
S
.
NAME
);
>
PLAN
>
PLAN
>
---------------------------------------------------------------------------------------------------------------------------------
>
---------------------------------------------------------------------------------------------------------------------------------
>
MERGE
INTO
PUBLIC
.
PARENT
(
ID
,
NAME
)
KEY
(
ID
)
SELECT
X
AS
ID
,
(
'Coco'
||
X
)
AS
NAME
FROM
SYSTEM_RANGE
(
1
,
2
)
/* PUBLIC.RANGE_INDEX */
>
MERGE
INTO
PUBLIC
.
PARENT
(
ID
,
NAME
)
KEY
(
ID
)
SELECT
X
AS
ID
,
(
'Coco'
||
X
)
AS
NAME
FROM
SYSTEM_RANGE
(
1
,
2
)
/* PUBLIC.RANGE_INDEX */
\ No newline at end of file
DROP
TABLE
PARENT
;
>
ok
CREATE
SCHEMA
SOURCESCHEMA
;
>
ok
CREATE
TABLE
SOURCESCHEMA
.
SOURCE
(
ID
INT
PRIMARY
KEY
,
VALUE
INT
);
>
ok
INSERT
INTO
SOURCESCHEMA
.
SOURCE
VALUES
(
1
,
10
),
(
3
,
30
),
(
5
,
50
);
>
update
count
:
3
CREATE
SCHEMA
DESTSCHEMA
;
>
ok
CREATE
TABLE
DESTSCHEMA
.
DESTINATION
(
ID
INT
PRIMARY
KEY
,
VALUE
INT
);
>
ok
INSERT
INTO
DESTSCHEMA
.
DESTINATION
VALUES
(
3
,
300
),
(
6
,
600
);
>
update
count
:
2
MERGE
INTO
DESTSCHEMA
.
DESTINATION
USING
SOURCESCHEMA
.
SOURCE
ON
(
DESTSCHEMA
.
DESTINATION
.
ID
=
SOURCESCHEMA
.
SOURCE
.
ID
)
WHEN
MATCHED
THEN
UPDATE
SET
VALUE
=
SOURCESCHEMA
.
SOURCE
.
VALUE
WHEN
NOT
MATCHED
THEN
INSERT
(
ID
,
VALUE
)
VALUES
(
SOURCESCHEMA
.
SOURCE
.
ID
,
SOURCESCHEMA
.
SOURCE
.
VALUE
);
>
update
count
:
3
SELECT
*
FROM
DESTSCHEMA
.
DESTINATION
;
>
ID
VALUE
>
-- -----
>
1
10
>
3
30
>
5
50
>
6
600
>
rows
:
4
DROP
SCHEMA
SOURCESCHEMA
CASCADE
;
>
ok
DROP
SCHEMA
DESTSCHEMA
CASCADE
;
>
ok
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
83e4f3bd
...
@@ -771,4 +771,4 @@ openoffice organize libre systemtables gmane sea borders announced millennium al
...
@@ -771,4 +771,4 @@ openoffice organize libre systemtables gmane sea borders announced millennium al
opti excessively
opti excessively
iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections
iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections
geometries
geometries
sourceschema destschema
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论