mirror of https://github.com/citusdata/citus.git
Incorrect attNum BugFix
parent
3a1ff0eae5
commit
2fc5e14ee8
|
@ -331,7 +331,6 @@ CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes)
|
||||||
int numberOfAttributes = RelationGetNumberOfAttributes(relation);
|
int numberOfAttributes = RelationGetNumberOfAttributes(relation);
|
||||||
|
|
||||||
List *targetList = NIL;
|
List *targetList = NIL;
|
||||||
int varAttrNo = 1;
|
|
||||||
|
|
||||||
for (int attrNum = 1; attrNum <= numberOfAttributes; attrNum++)
|
for (int attrNum = 1; attrNum <= numberOfAttributes; attrNum++)
|
||||||
{
|
{
|
||||||
|
@ -362,7 +361,7 @@ CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TargetEntry *targetEntry =
|
TargetEntry *targetEntry =
|
||||||
CreateTargetEntryForColumn(attributeTuple, SINGLE_RTE_INDEX, varAttrNo++,
|
CreateTargetEntryForColumn(attributeTuple, SINGLE_RTE_INDEX, attrNum,
|
||||||
resNo);
|
resNo);
|
||||||
targetList = lappend(targetList, targetEntry);
|
targetList = lappend(targetList, targetEntry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,6 +476,41 @@ WHEN MATCHED THEN DO NOTHING;
|
||||||
Filter: ('2'::bigint = id)
|
Filter: ('2'::bigint = id)
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS source;
|
||||||
|
DROP TABLE IF EXISTS target;
|
||||||
|
-- Bug Fix Test as part of this PR
|
||||||
|
CREATE TABLE source (
|
||||||
|
id int,
|
||||||
|
age int,
|
||||||
|
salary int
|
||||||
|
);
|
||||||
|
CREATE TABLE target (
|
||||||
|
id int,
|
||||||
|
age int,
|
||||||
|
salary int
|
||||||
|
);
|
||||||
|
SELECT create_distributed_table('source', 'id', colocate_with=>'none');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_distributed_table('target', 'id', colocate_with=>'none');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO source (id, age, salary) VALUES (1,30, 100000);
|
||||||
|
MERGE INTO ONLY target USING source ON (source.id = target.id)
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
INSERT (id, salary) VALUES (source.id, source.salary);
|
||||||
|
SELECT * FROM TARGET;
|
||||||
|
id | age | salary
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1 | | 100000
|
||||||
|
(1 row)
|
||||||
|
|
||||||
DROP TABLE IF EXISTS source;
|
DROP TABLE IF EXISTS source;
|
||||||
DROP TABLE IF EXISTS target;
|
DROP TABLE IF EXISTS target;
|
||||||
DROP SCHEMA IF EXISTS merge_vcore_schema CASCADE;
|
DROP SCHEMA IF EXISTS merge_vcore_schema CASCADE;
|
||||||
|
|
|
@ -311,4 +311,35 @@ WHEN MATCHED THEN DO NOTHING;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS source;
|
DROP TABLE IF EXISTS source;
|
||||||
DROP TABLE IF EXISTS target;
|
DROP TABLE IF EXISTS target;
|
||||||
|
|
||||||
|
-- Bug Fix Test as part of this PR
|
||||||
|
CREATE TABLE source (
|
||||||
|
id int,
|
||||||
|
age int,
|
||||||
|
salary int
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE target (
|
||||||
|
id int,
|
||||||
|
age int,
|
||||||
|
salary int
|
||||||
|
);
|
||||||
|
|
||||||
|
SELECT create_distributed_table('source', 'id', colocate_with=>'none');
|
||||||
|
SELECT create_distributed_table('target', 'id', colocate_with=>'none');
|
||||||
|
|
||||||
|
INSERT INTO source (id, age, salary) VALUES (1,30, 100000);
|
||||||
|
|
||||||
|
MERGE INTO ONLY target USING source ON (source.id = target.id)
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
INSERT (id, salary) VALUES (source.id, source.salary);
|
||||||
|
|
||||||
|
SELECT * FROM TARGET;
|
||||||
|
DROP TABLE IF EXISTS source;
|
||||||
|
DROP TABLE IF EXISTS target;
|
||||||
|
|
||||||
DROP SCHEMA IF EXISTS merge_vcore_schema CASCADE;
|
DROP SCHEMA IF EXISTS merge_vcore_schema CASCADE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue