From ef6651d5ab653e762e31fb73109ab32c7ecab020 Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Thu, 3 Jan 2019 14:33:04 +0100 Subject: [PATCH] Avoid using GP_ROLE_UNDEFINED in code The segment role GP_ROLE_UNDEFINED should never be set, and cdbvars is guarding against that ever happening. Thus, testing for it in the code makes it look like it could indeed happen which is misleading to the reader. Remove the test and refactor the switch() to instead use an if-else clause with an assertion that maintains the same guarantee as the previous coding did. Discussion: https://github.com/greenplum-db/gpdb/pull/6423 Reviewed-by: Ashwin Agrawal --- src/backend/cdb/cdbllize.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/backend/cdb/cdbllize.c b/src/backend/cdb/cdbllize.c index a82f05a769..e1ee8616b7 100644 --- a/src/backend/cdb/cdbllize.c +++ b/src/backend/cdb/cdbllize.c @@ -140,16 +140,12 @@ cdbparallelize(PlannerInfo *root, PlanProfile *context = &profile; /* Make sure we're called correctly (and need to be called). */ - switch (Gp_role) - { - case GP_ROLE_DISPATCH: - break; - case GP_ROLE_UTILITY: - return plan; - case GP_ROLE_EXECUTE: - case GP_ROLE_UNDEFINED: - Insist(0); - } + if (Gp_role == GP_ROLE_UTILITY) + return plan; + if (Gp_role != GP_ROLE_DISPATCH) + elog(ERROR, "Plan parallelization invoked for incorrect role: %s", + role_to_string(Gp_role)); + Assert(is_plan_node((Node *) plan)); Assert(query !=NULL && IsA(query, Query)); -- GitLab