Refactor RouterSelectTask/RouterSelectQuery - remove query parameter since it is not required at all

pull/896/head
Onder Kalaci 2016-10-19 14:33:22 +03:00
parent 0d0642f5a3
commit 11d0476153
1 changed files with 10 additions and 13 deletions

View File

@ -93,10 +93,10 @@ static ShardInterval * FastShardPruning(Oid distributedTableId,
Const *partionColumnValue); Const *partionColumnValue);
static Oid ExtractFirstDistributedTableId(Query *query); static Oid ExtractFirstDistributedTableId(Query *query);
static Const * ExtractInsertPartitionValue(Query *query, Var *partitionColumn); static Const * ExtractInsertPartitionValue(Query *query, Var *partitionColumn);
static Task * RouterSelectTask(Query *originalQuery, Query *query, static Task * RouterSelectTask(Query *originalQuery,
RelationRestrictionContext *restrictionContext, RelationRestrictionContext *restrictionContext,
List **placementList); List **placementList);
static bool RouterSelectQuery(Query *originalQuery, Query *query, static bool RouterSelectQuery(Query *originalQuery,
RelationRestrictionContext *restrictionContext, RelationRestrictionContext *restrictionContext,
List **placementList, uint64 *anchorShardId); List **placementList, uint64 *anchorShardId);
static List * TargetShardIntervalsForSelect(Query *query, static List * TargetShardIntervalsForSelect(Query *query,
@ -186,7 +186,7 @@ CreateSingleTaskRouterPlan(Query *originalQuery, Query *query,
{ {
Assert(commandType == CMD_SELECT); Assert(commandType == CMD_SELECT);
task = RouterSelectTask(originalQuery, query, restrictionContext, &placementList); task = RouterSelectTask(originalQuery, restrictionContext, &placementList);
} }
if (task == NULL) if (task == NULL)
@ -344,9 +344,8 @@ RouterModifyTaskForShardInterval(Query *originalQuery, Query *query,
* or not. If we can, we also rely on the side-effects that all RTEs have been * or not. If we can, we also rely on the side-effects that all RTEs have been
* updated to point to the relevant nodes and selectPlacementList is determined. * updated to point to the relevant nodes and selectPlacementList is determined.
*/ */
queryRoutable = RouterSelectQuery(copiedSubquery, subquery, queryRoutable = RouterSelectQuery(copiedSubquery, copiedRestrictionContext,
copiedRestrictionContext, &selectPlacementList, &selectPlacementList, &selectAnchorShardId);
&selectAnchorShardId);
if (!queryRoutable) if (!queryRoutable)
{ {
@ -1597,8 +1596,7 @@ ExtractInsertPartitionValue(Query *query, Var *partitionColumn)
/* RouterSelectTask builds a Task to represent a single shard select query */ /* RouterSelectTask builds a Task to represent a single shard select query */
static Task * static Task *
RouterSelectTask(Query *originalQuery, Query *query, RouterSelectTask(Query *originalQuery, RelationRestrictionContext *restrictionContext,
RelationRestrictionContext *restrictionContext,
List **placementList) List **placementList)
{ {
Task *task = NULL; Task *task = NULL;
@ -1607,7 +1605,7 @@ RouterSelectTask(Query *originalQuery, Query *query,
bool upsertQuery = false; bool upsertQuery = false;
uint64 shardId = INVALID_SHARD_ID; uint64 shardId = INVALID_SHARD_ID;
queryRoutable = RouterSelectQuery(originalQuery, query, restrictionContext, queryRoutable = RouterSelectQuery(originalQuery, restrictionContext,
placementList, &shardId); placementList, &shardId);
@ -1641,14 +1639,13 @@ RouterSelectTask(Query *originalQuery, Query *query,
* anchorShardId is set to the first pruned shardId of the given query. * anchorShardId is set to the first pruned shardId of the given query.
*/ */
static bool static bool
RouterSelectQuery(Query *originalQuery, Query *query, RouterSelectQuery(Query *originalQuery, RelationRestrictionContext *restrictionContext,
RelationRestrictionContext *restrictionContext,
List **placementList, uint64 *anchorShardId) List **placementList, uint64 *anchorShardId)
{ {
List *prunedRelationShardList = TargetShardIntervalsForSelect(query, List *prunedRelationShardList = TargetShardIntervalsForSelect(originalQuery,
restrictionContext); restrictionContext);
uint64 shardId = INVALID_SHARD_ID; uint64 shardId = INVALID_SHARD_ID;
CmdType commandType PG_USED_FOR_ASSERTS_ONLY = query->commandType; CmdType commandType PG_USED_FOR_ASSERTS_ONLY = originalQuery->commandType;
ListCell *prunedRelationShardListCell = NULL; ListCell *prunedRelationShardListCell = NULL;
List *workerList = NIL; List *workerList = NIL;
bool shardsPresent = false; bool shardsPresent = false;