Apply feedback

pull/2606/head
Onder Kalaci 2019-02-22 18:14:30 +03:00
parent 407d0e30f5
commit e521e7e39c
2 changed files with 9 additions and 22 deletions

View File

@ -209,17 +209,6 @@ FastPathRouterQuery(Query *query)
return false; return false;
} }
/*
* hasForUpdate is tricky because Citus does support only when
* replication = 1 or reference tables.
*/
if (query->hasForUpdate &&
!(cacheEntry->partitionMethod == DISTRIBUTE_BY_NONE ||
SingleReplicatedTable(distributedTableId)))
{
return false;
}
/* WHERE clause should not be empty for distributed tables */ /* WHERE clause should not be empty for distributed tables */
if (joinTree == NULL || if (joinTree == NULL ||
(cacheEntry->partitionMethod != DISTRIBUTE_BY_NONE && joinTree->quals == NULL)) (cacheEntry->partitionMethod != DISTRIBUTE_BY_NONE && joinTree->quals == NULL))

View File

@ -137,8 +137,7 @@ static void NormalizeMultiRowInsertTargetList(Query *query);
static List * BuildRoutesForInsert(Query *query, DeferredErrorMessage **planningError); static List * BuildRoutesForInsert(Query *query, DeferredErrorMessage **planningError);
static List * GroupInsertValuesByShardId(List *insertValuesList); static List * GroupInsertValuesByShardId(List *insertValuesList);
static List * ExtractInsertValuesList(Query *query, Var *partitionColumn); static List * ExtractInsertValuesList(Query *query, Var *partitionColumn);
static bool MultiRouterPlannableQuery(Query *query, static bool MultiRouterPlannableQuery(Query *query);
RelationRestrictionContext *restrictionContext);
static DeferredErrorMessage * ErrorIfQueryHasModifyingCTE(Query *queryTree); static DeferredErrorMessage * ErrorIfQueryHasModifyingCTE(Query *queryTree);
static RangeTblEntry * GetUpdateOrDeleteRTE(Query *query); static RangeTblEntry * GetUpdateOrDeleteRTE(Query *query);
static bool SelectsFromDistributedTable(List *rangeTableList, Query *query); static bool SelectsFromDistributedTable(List *rangeTableList, Query *query);
@ -169,8 +168,7 @@ DistributedPlan *
CreateRouterPlan(Query *originalQuery, Query *query, CreateRouterPlan(Query *originalQuery, Query *query,
PlannerRestrictionContext *plannerRestrictionContext) PlannerRestrictionContext *plannerRestrictionContext)
{ {
if (MultiRouterPlannableQuery(query, if (MultiRouterPlannableQuery(query))
plannerRestrictionContext->relationRestrictionContext))
{ {
return CreateSingleTaskRouterPlan(originalQuery, query, return CreateSingleTaskRouterPlan(originalQuery, query,
plannerRestrictionContext); plannerRestrictionContext);
@ -2133,7 +2131,7 @@ TargetShardIntervalForFastPathQuery(Query *query, Const **partitionValueConst,
*isMultiShardQuery = true; *isMultiShardQuery = true;
} }
else if (list_length(prunedShardIntervalList) == 1 && else if (list_length(prunedShardIntervalList) == 1 &&
queryPartitionValueConst != NULL) partitionValueConst != NULL)
{ {
/* set the outgoing partition column value if requested */ /* set the outgoing partition column value if requested */
*partitionValueConst = queryPartitionValueConst; *partitionValueConst = queryPartitionValueConst;
@ -2910,10 +2908,11 @@ ExtractInsertPartitionKeyValue(Query *query)
* flag to false. * flag to false.
*/ */
static bool static bool
MultiRouterPlannableQuery(Query *query, RelationRestrictionContext *restrictionContext) MultiRouterPlannableQuery(Query *query)
{ {
CmdType commandType = query->commandType; CmdType commandType = query->commandType;
ListCell *relationRestrictionContextCell = NULL; List *rangeTableRelationList = NIL;
ListCell *rangeTableRelationCell = NULL;
if (commandType == CMD_INSERT || commandType == CMD_UPDATE || if (commandType == CMD_INSERT || commandType == CMD_UPDATE ||
commandType == CMD_DELETE) commandType == CMD_DELETE)
@ -2928,11 +2927,10 @@ MultiRouterPlannableQuery(Query *query, RelationRestrictionContext *restrictionC
return false; return false;
} }
foreach(relationRestrictionContextCell, restrictionContext->relationRestrictionList) ExtractRangeTableRelationWalker((Node *) query, &rangeTableRelationList);
foreach(rangeTableRelationCell, rangeTableRelationList)
{ {
RelationRestriction *relationRestriction = RangeTblEntry *rte = (RangeTblEntry *) lfirst(rangeTableRelationCell);
(RelationRestriction *) lfirst(relationRestrictionContextCell);
RangeTblEntry *rte = relationRestriction->rte;
if (rte->rtekind == RTE_RELATION) if (rte->rtekind == RTE_RELATION)
{ {
/* only hash partitioned tables are supported */ /* only hash partitioned tables are supported */