mirror of https://github.com/citusdata/citus.git
Removing Fix changes for Now Will raise in seprate PR
parent
346422e7be
commit
d29e3ccbc5
|
@ -857,11 +857,8 @@ ConvertRelationRTEIntoSubquery(Query *mergeQuery, RangeTblEntry *sourceRte,
|
||||||
/* set the FROM expression to the subquery */
|
/* set the FROM expression to the subquery */
|
||||||
newRangeTableRef->rtindex = SINGLE_RTE_INDEX;
|
newRangeTableRef->rtindex = SINGLE_RTE_INDEX;
|
||||||
sourceResultsQuery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL);
|
sourceResultsQuery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL);
|
||||||
|
sourceResultsQuery->targetList = CreateAllTargetListForRelation(sourceRte->relid,
|
||||||
bool isMergeQuery = true;
|
requiredAttributes);
|
||||||
sourceResultsQuery->targetList =
|
|
||||||
CreateAllTargetListForRelation(sourceRte->relid, requiredAttributes,
|
|
||||||
isMergeQuery);
|
|
||||||
List *restrictionList =
|
List *restrictionList =
|
||||||
GetRestrictInfoListForRelation(sourceRte, plannerRestrictionContext);
|
GetRestrictInfoListForRelation(sourceRte, plannerRestrictionContext);
|
||||||
List *copyRestrictionList = copyObject(restrictionList);
|
List *copyRestrictionList = copyObject(restrictionList);
|
||||||
|
|
|
@ -325,14 +325,13 @@ WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation,
|
||||||
* as a NULL column.
|
* as a NULL column.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes, bool
|
CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes)
|
||||||
isMergeQuery)
|
|
||||||
{
|
{
|
||||||
Relation relation = relation_open(relationId, AccessShareLock);
|
Relation relation = relation_open(relationId, AccessShareLock);
|
||||||
int numberOfAttributes = RelationGetNumberOfAttributes(relation);
|
int numberOfAttributes = RelationGetNumberOfAttributes(relation);
|
||||||
|
|
||||||
List *targetList = NIL;
|
List *targetList = NIL;
|
||||||
int colAppendIdx = 1;
|
int varAttrNo = 1;
|
||||||
|
|
||||||
for (int attrNum = 1; attrNum <= numberOfAttributes; attrNum++)
|
for (int attrNum = 1; attrNum <= numberOfAttributes; attrNum++)
|
||||||
{
|
{
|
||||||
|
@ -362,9 +361,8 @@ CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes, bool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int varAttNum = isMergeQuery ? attrNum : colAppendIdx++;
|
|
||||||
TargetEntry *targetEntry =
|
TargetEntry *targetEntry =
|
||||||
CreateTargetEntryForColumn(attributeTuple, SINGLE_RTE_INDEX, varAttNum,
|
CreateTargetEntryForColumn(attributeTuple, SINGLE_RTE_INDEX, varAttrNo,
|
||||||
resNo);
|
resNo);
|
||||||
targetList = lappend(targetList, targetEntry);
|
targetList = lappend(targetList, targetEntry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1767,10 +1767,8 @@ ReplaceRTERelationWithRteSubquery(RangeTblEntry *rangeTableEntry,
|
||||||
{
|
{
|
||||||
Query *subquery = WrapRteRelationIntoSubquery(rangeTableEntry, requiredAttrNumbers,
|
Query *subquery = WrapRteRelationIntoSubquery(rangeTableEntry, requiredAttrNumbers,
|
||||||
perminfo);
|
perminfo);
|
||||||
bool isMergeQuery = false;
|
|
||||||
List *outerQueryTargetList = CreateAllTargetListForRelation(rangeTableEntry->relid,
|
List *outerQueryTargetList = CreateAllTargetListForRelation(rangeTableEntry->relid,
|
||||||
requiredAttrNumbers,
|
requiredAttrNumbers);
|
||||||
isMergeQuery);
|
|
||||||
|
|
||||||
List *restrictionList =
|
List *restrictionList =
|
||||||
GetRestrictInfoListForRelation(rangeTableEntry,
|
GetRestrictInfoListForRelation(rangeTableEntry,
|
||||||
|
|
|
@ -38,7 +38,6 @@ extern bool SubqueryColocated(Query *subquery, ColocatedJoinChecker *context);
|
||||||
extern Query * WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation,
|
extern Query * WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation,
|
||||||
List *requiredAttributes,
|
List *requiredAttributes,
|
||||||
RTEPermissionInfo *perminfo);
|
RTEPermissionInfo *perminfo);
|
||||||
extern List * CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes,
|
extern List * CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes);
|
||||||
bool isMergeQuery);
|
|
||||||
|
|
||||||
#endif /* QUERY_COLOCATION_CHECKER_H */
|
#endif /* QUERY_COLOCATION_CHECKER_H */
|
||||||
|
|
|
@ -476,41 +476,6 @@ 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;
|
||||||
|
|
|
@ -312,32 +312,6 @@ 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