Disallow INSERT ... SELECT to pushdown joins on non-partition keys

With this commit, we disallow JOINs on non-partition keys. Simply,
while instantiating the qual we check whether the qual is on the
partition key.
pull/1250/head
Onder Kalaci 2017-02-20 14:00:25 +02:00
parent 681da71251
commit fd8df25daf
1 changed files with 8 additions and 0 deletions

View File

@ -387,6 +387,7 @@ RouterModifyTaskForShardInterval(Query *originalQuery, ShardInterval *shardInter
List *originalBaserestrictInfo = restriction->relOptInfo->baserestrictinfo;
InstantiateQualContext instantiateQualWalker;
Var *relationPartitionKey = PartitionKey(restriction->relationId);
Var *relationPartitionKey = PartitionKey(restriction->relationId);
/*
* We haven't added the quals if all participating tables are reference
@ -3047,6 +3048,13 @@ InstantiatePartitionQualWalker(Node *node, void *context)
return node;
}
/* if the qual is not on the partition column, do not instantiate */
if (relationPartitionColumn && currentColumn &&
currentColumn->varattno != relationPartitionColumn->varattno)
{
return node;
}
/* get the integer >=, <= operators from the catalog */
integer4GEoperatorId = get_opfamily_member(INTEGER_BTREE_FAM_OID, INT4OID,
INT4OID,