提交 b8692ac0 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remove unexpected check for column count in MergeUsing

上级 ea42b4a7
...@@ -397,11 +397,6 @@ public class MergeUsing extends Prepared { ...@@ -397,11 +397,6 @@ public class MergeUsing extends Prepared {
} }
} }
} }
} else {
query.prepare();
if (query.getColumnCount() != columns.length) {
throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
}
} }
int embeddedStatementsCount = 0; int embeddedStatementsCount = 0;
......
...@@ -72,3 +72,46 @@ DROP SCHEMA SOURCESCHEMA CASCADE; ...@@ -72,3 +72,46 @@ DROP SCHEMA SOURCESCHEMA CASCADE;
DROP SCHEMA DESTSCHEMA CASCADE; DROP SCHEMA DESTSCHEMA CASCADE;
> ok > ok
CREATE TABLE SOURCE_TABLE(ID BIGINT PRIMARY KEY, C1 INT NOT NULL);
> ok
INSERT INTO SOURCE_TABLE VALUES (1, 10), (2, 20), (3, 30);
> update count: 3
CREATE TABLE DEST_TABLE(ID BIGINT PRIMARY KEY, C1 INT NOT NULL, C2 INT NOT NULL);
> ok
INSERT INTO DEST_TABLE VALUES (2, 200, 2000), (4, 400, 4000);
> update count: 2
MERGE INTO DEST_TABLE USING SOURCE_TABLE ON (DEST_TABLE.ID = SOURCE_TABLE.ID)
WHEN MATCHED THEN UPDATE SET DEST_TABLE.C1 = SOURCE_TABLE.C1, DEST_TABLE.C2 = 100;
> update count: 1
SELECT * FROM DEST_TABLE;
> ID C1 C2
> -- --- ----
> 2 20 100
> 4 400 4000
> rows: 2
MERGE INTO DEST_TABLE D USING SOURCE_TABLE S ON (D.ID = S.ID)
WHEN MATCHED THEN UPDATE SET D.C1 = S.C1, D.C2 = 100
WHEN NOT MATCHED THEN INSERT (ID, C1, C2) VALUES (S.ID, S.C1, 1000);
> update count: 3
SELECT * FROM DEST_TABLE;
> ID C1 C2
> -- --- ----
> 1 10 1000
> 2 20 100
> 3 30 1000
> 4 400 4000
> rows: 4
DROP TABLE SOURCE_TABLE;
> ok
DROP TABLE DEST_TABLE;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论