mirror of https://github.com/citusdata/citus.git
refactor IsLocalReferenceTableJoin & its usages and rename it
parent
653295e512
commit
5baea1dfcb
|
@ -70,7 +70,7 @@ int ExecutorLevel = 0;
|
|||
/* local function forward declarations */
|
||||
static Relation StubRelation(TupleDesc tupleDescriptor);
|
||||
static bool AlterTableConstraintCheck(QueryDesc *queryDesc);
|
||||
static bool IsLocalReferenceTableJoinPlan(PlannedStmt *plan);
|
||||
static bool IsValidLocalReferenceTableJoinPlan(PlannedStmt *plan);
|
||||
static List * FindCitusCustomScanStates(PlanState *planState);
|
||||
static bool CitusCustomScanStateWalker(PlanState *planState,
|
||||
List **citusCustomScanStates);
|
||||
|
@ -149,7 +149,7 @@ CitusExecutorRun(QueryDesc *queryDesc,
|
|||
|
||||
if (CitusHasBeenLoaded())
|
||||
{
|
||||
if (IsLocalReferenceTableJoinPlan(queryDesc->plannedstmt) &&
|
||||
if (IsValidLocalReferenceTableJoinPlan(queryDesc->plannedstmt) &&
|
||||
IsMultiStatementTransaction())
|
||||
{
|
||||
/*
|
||||
|
@ -742,13 +742,13 @@ AlterTableConstraintCheck(QueryDesc *queryDesc)
|
|||
|
||||
|
||||
/*
|
||||
* IsLocalReferenceTableJoinPlan returns true if the given plan joins local tables
|
||||
* IsValidLocalReferenceTableJoinPlan returns true if the given plan joins local tables
|
||||
* with reference table shards.
|
||||
*
|
||||
* This should be consistent with IsLocalReferenceTableJoin() in distributed_planner.c.
|
||||
*/
|
||||
static bool
|
||||
IsLocalReferenceTableJoinPlan(PlannedStmt *plan)
|
||||
IsValidLocalReferenceTableJoinPlan(PlannedStmt *plan)
|
||||
{
|
||||
bool hasReferenceTable = false;
|
||||
bool hasLocalTable = false;
|
||||
|
|
|
@ -122,7 +122,7 @@ static void PopPlannerRestrictionContext(void);
|
|||
static void ResetPlannerRestrictionContext(
|
||||
PlannerRestrictionContext *plannerRestrictionContext);
|
||||
static bool HasUnresolvedExternParamsWalker(Node *expression, ParamListInfo boundParams);
|
||||
static bool IsLocalReferenceTableJoin(Query *parse, List *rangeTableList);
|
||||
static bool IsValidLocalReferenceTableJoin(Query *parse, List *rangeTableList);
|
||||
static bool QueryIsNotSimpleSelect(Node *node);
|
||||
static bool UpdateReferenceTablesWithShard(Node *node, void *context);
|
||||
static PlannedStmt * PlanFastPathDistributedStmt(DistributedPlanningContext *planContext,
|
||||
|
@ -158,7 +158,7 @@ distributed_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
|
|||
}
|
||||
else if (CitusHasBeenLoaded())
|
||||
{
|
||||
if (IsLocalReferenceTableJoin(parse, rangeTableList))
|
||||
if (IsValidLocalReferenceTableJoin(parse, rangeTableList))
|
||||
{
|
||||
/*
|
||||
* For joins between reference tables and local tables, we replace
|
||||
|
@ -2341,38 +2341,21 @@ HasUnresolvedExternParamsWalker(Node *expression, ParamListInfo boundParams)
|
|||
|
||||
|
||||
/*
|
||||
* IsLocalReferenceTableJoin returns if the given query is a join between
|
||||
* reference tables and local tables.
|
||||
* IsValidLocalReferenceTableJoin returns true if the given query
|
||||
* is a valid join query between reference tables and local tables
|
||||
*/
|
||||
static bool
|
||||
IsLocalReferenceTableJoin(Query *parse, List *rangeTableList)
|
||||
IsValidLocalReferenceTableJoin(Query *parse, List *rangeTableList)
|
||||
{
|
||||
bool hasReferenceTable = false;
|
||||
bool hasLocalTable = false;
|
||||
ListCell *rangeTableCell = false;
|
||||
|
||||
bool hasReferenceTableReplica = false;
|
||||
|
||||
/*
|
||||
* We only allow join between reference tables and local tables in the
|
||||
* coordinator.
|
||||
* Check if we are in the coordinator and coordinator can have reference
|
||||
* table placements
|
||||
*/
|
||||
if (!IsCoordinator())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* All groups that have pg_dist_node entries, also have reference
|
||||
* table replicas.
|
||||
*/
|
||||
PrimaryNodeForGroup(COORDINATOR_GROUP_ID, &hasReferenceTableReplica);
|
||||
|
||||
/*
|
||||
* If reference table doesn't have replicas on the coordinator, we don't
|
||||
* allow joins with local tables.
|
||||
*/
|
||||
if (!hasReferenceTableReplica)
|
||||
if (!CanUseCoordinatorLocalTablesWithReferenceTables())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue