Github user linwen commented on a diff in the pull request: https://github.com/apache/incubator-hawq/pull/1279#discussion_r132612133 --- Diff: src/backend/optimizer/plan/planner.c --- @@ -438,256 +438,224 @@ PlannedStmt *refineCachedPlan(PlannedStmt * plannedstmt, * *****************************************************************************/ -PlannedStmt * -planner(Query *parse, int cursorOptions, - ParamListInfo boundParams, QueryResourceLife resourceLife) -{ - PlannedStmt *result = NULL; - instr_time starttime, endtime; - ResourceNegotiatorResult *ppResult = (ResourceNegotiatorResult *) palloc(sizeof(ResourceNegotiatorResult)); - SplitAllocResult initResult = {NULL, NIL, 0, NIL, NULL}; - ppResult->saResult = initResult; - ppResult->stmt = NULL; - static int plannerLevel = 0; - bool resourceNegotiateDone = false; - QueryResource *savedQueryResource = GetActiveQueryResource(); - SetActiveRelType(NIL); - - bool isDispatchParallel = false; - /* - * Before doing the true query optimization, we first run a resource_negotiator to give - * us some sense of the complexity of the query, and allocate the appropriate - * resource to run this query. After gaining the resource, we can perform the - * actual optimization. - */ - increase_planning_depth(); - - plannerLevel++; - if (!resourceNegotiateDone) - { - PG_TRY(); - { - START_MEMORY_ACCOUNT(MemoryAccounting_CreateAccount(0, MEMORY_OWNER_TYPE_Resource_Negotiator)); - { - resource_negotiator(parse, cursorOptions, boundParams, resourceLife, &ppResult); - - decrease_planning_depth(); - - if(ppResult->stmt && ppResult->stmt->planTree) - { - isDispatchParallel = ppResult->stmt->planTree->dispatch == DISPATCH_PARALLEL; - } - } - END_MEMORY_ACCOUNT(); - } - PG_CATCH(); - { - decrease_planning_depth(); - - if ((ppResult != NULL)) - { - pfree(ppResult); - ppResult = NULL; - } - plannerLevel = 0; - PG_RE_THROW(); - } - PG_END_TRY(); - } - SetActiveRelType(NIL); - if (plannerLevel >= 1) - { - resourceNegotiateDone = true; - gp_segments_for_planner = ppResult->saResult.planner_segments; - if (ppResult->saResult.resource) - { - SetActiveQueryResource(ppResult->saResult.resource); - SetActiveRelType(ppResult->saResult.relsType); - } - } +PlannedStmt * +planner(Query *parse, int cursorOptions, ParamListInfo boundParams, QueryResourceLife resourceLife) { + PlannedStmt *result = NULL; + instr_time starttime, endtime; + ResourceNegotiatorResult *ppResult = (ResourceNegotiatorResult *) palloc(sizeof(ResourceNegotiatorResult)); + SplitAllocResult initResult = { NULL, NIL, 0, NIL, NULL }; + ppResult->saResult = initResult; + ppResult->stmt = NULL; + static int plannerLevel = 0; + bool resourceNegotiateDone = false; + QueryResource *savedQueryResource = GetActiveQueryResource(); + SetActiveRelType(NIL); + + bool isDispatchParallel = false; + /* + * Before doing the true query optimization, we first run a resource_negotiator to give + * us some sense of the complexity of the query, and allocate the appropriate + * resource to run this query. After gaining the resource, we can perform the + * actual optimization. + */ + increase_planning_depth(); + + plannerLevel++; + if (!resourceNegotiateDone) { + PG_TRY(); + { + START_MEMORY_ACCOUNT(MemoryAccounting_CreateAccount(0, MEMORY_OWNER_TYPE_Resource_Negotiator)); + { + resource_negotiator(parse, cursorOptions, boundParams, resourceLife, &ppResult); + + decrease_planning_depth(); + + if (ppResult->stmt && ppResult->stmt->planTree) { + isDispatchParallel = ppResult->stmt->planTree->dispatch == DISPATCH_PARALLEL; + } + } + END_MEMORY_ACCOUNT(); + }PG_CATCH(); + { + decrease_planning_depth(); + + if ((ppResult != NULL)) { + pfree(ppResult); + ppResult = NULL; + } + plannerLevel = 0; + PG_RE_THROW(); + }PG_END_TRY(); + } + SetActiveRelType(NIL); + if (plannerLevel >= 1) { + resourceNegotiateDone = true; + gp_segments_for_planner = ppResult->saResult.planner_segments; + if (ppResult->saResult.resource) { + SetActiveQueryResource(ppResult->saResult.resource); + SetActiveRelType(ppResult->saResult.relsType); + } + } - int optimizer_segments_saved_value = optimizer_segments; + int optimizer_segments_saved_value = optimizer_segments; - PG_TRY(); - { - if (resourceNegotiateDone) - { + PG_TRY(); + { --- End diff -- Indent from here doesn't align. Please fix.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---