From 4b9b4b0995dbbfebe1b6c9be7e97a4a07ea58eb9 Mon Sep 17 00:00:00 2001 From: Jelte Fennema Date: Fri, 15 Nov 2019 09:46:06 +0100 Subject: [PATCH] Don't warn for declaration-after-statement since we only support GNU99 (#3132) This change was actually already intended in #3124. However, the postgres Makefile manually enables this warning too. This way we undo that. To confirm that it works two functions were changed to make use of not having the warning anymore. --- configure | 39 +++++++++++++++++ configure.in | 1 + .../planner/multi_master_planner.c | 42 +++++++------------ 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/configure b/configure index 0e11119ad..98102ee97 100755 --- a/configure +++ b/configure @@ -3946,6 +3946,45 @@ if test x"$citusac_cv_prog_cc_cflags__Wno_gnu_variable_sized_type_not_at_end" = CITUS_CFLAGS="$CITUS_CFLAGS -Wno-gnu-variable-sized-type-not-at-end" fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-declaration-after-statement" >&5 +$as_echo_n "checking whether $CC supports -Wno-declaration-after-statement... " >&6; } +if ${citusac_cv_prog_cc_cflags__Wno_declaration_after_statement+:} false; then : + $as_echo_n "(cached) " >&6 +else + citusac_save_CFLAGS=$CFLAGS +flag=-Wno-declaration-after-statement +case $flag in -Wno*) + flag=-W$(echo $flag | cut -c 6-) +esac +CFLAGS="$citusac_save_CFLAGS $flag" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + citusac_cv_prog_cc_cflags__Wno_declaration_after_statement=yes +else + citusac_cv_prog_cc_cflags__Wno_declaration_after_statement=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag +CFLAGS="$citusac_save_CFLAGS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $citusac_cv_prog_cc_cflags__Wno_declaration_after_statement" >&5 +$as_echo "$citusac_cv_prog_cc_cflags__Wno_declaration_after_statement" >&6; } +if test x"$citusac_cv_prog_cc_cflags__Wno_declaration_after_statement" = x"yes"; then + CITUS_CFLAGS="$CITUS_CFLAGS -Wno-declaration-after-statement" +fi + # And add a few extra warnings { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wendif-labels" >&5 $as_echo_n "checking whether $CC supports -Wendif-labels... " >&6; } diff --git a/configure.in b/configure.in index 2c7e4f212..9a649b809 100644 --- a/configure.in +++ b/configure.in @@ -163,6 +163,7 @@ CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-sign-compare]) CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-missing-field-initializers]) CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-clobbered]) CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-gnu-variable-sized-type-not-at-end]) +CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-declaration-after-statement]) # And add a few extra warnings CITUSAC_PROG_CC_CFLAGS_OPT([-Wendif-labels]) CITUSAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute]) diff --git a/src/backend/distributed/planner/multi_master_planner.c b/src/backend/distributed/planner/multi_master_planner.c index 74d782aca..8992e3b50 100644 --- a/src/backend/distributed/planner/multi_master_planner.c +++ b/src/backend/distributed/planner/multi_master_planner.c @@ -17,6 +17,7 @@ #include "commands/extension.h" #include "distributed/citus_ruleutils.h" #include "distributed/function_utils.h" +#include "distributed/listutils.h" #include "distributed/multi_logical_optimizer.h" #include "distributed/multi_master_planner.h" #include "distributed/multi_physical_planner.h" @@ -141,13 +142,13 @@ MasterTargetList(List *workerTargetList) static PlannedStmt * BuildSelectStatement(Query *masterQuery, List *masterTargetList, CustomScan *remoteScan) { - PlannedStmt *selectStatement = NULL; + /* top level select query should have only one range table entry */ + Assert(list_length(masterQuery->rtable) == 1); Agg *aggregationPlan = NULL; Plan *topLevelPlan = NULL; List *sortClauseList = copyObject(masterQuery->sortClause); - ListCell *targetEntryCell = NULL; - List *columnNameList = NULL; - RangeTblEntry *customScanRangeTableEntry = NULL; + List *columnNameList = NIL; + TargetEntry *targetEntry = NULL; PlannerGlobal *glob = makeNode(PlannerGlobal); PlannerInfo *root = makeNode(PlannerInfo); @@ -159,13 +160,11 @@ BuildSelectStatement(Query *masterQuery, List *masterTargetList, CustomScan *rem /* (1) make PlannedStmt and set basic information */ - selectStatement = makeNode(PlannedStmt); + PlannedStmt *selectStatement = makeNode(PlannedStmt); selectStatement->canSetTag = true; selectStatement->relationOids = NIL; selectStatement->commandType = CMD_SELECT; - /* top level select query should have only one range table entry */ - Assert(list_length(masterQuery->rtable) == 1); remoteScan->custom_scan_tlist = masterTargetList; @@ -276,13 +275,12 @@ BuildSelectStatement(Query *masterQuery, List *masterTargetList, CustomScan *rem /* * (7) Replace rangetable with one with nice names to show in EXPLAIN plans */ - foreach(targetEntryCell, masterTargetList) + foreach_ptr(targetEntry, masterTargetList) { - TargetEntry *targetEntry = lfirst(targetEntryCell); columnNameList = lappend(columnNameList, makeString(targetEntry->resname)); } - customScanRangeTableEntry = linitial(selectStatement->rtable); + RangeTblEntry *customScanRangeTableEntry = linitial(selectStatement->rtable); customScanRangeTableEntry->eref = makeAlias("remote_scan", columnNameList); return selectStatement; @@ -371,18 +369,12 @@ FinalizeStatement(PlannerInfo *root, PlannedStmt *result, Plan *top_plan) static Agg * BuildAggregatePlan(PlannerInfo *root, Query *masterQuery, Plan *subPlan) { - Agg *aggregatePlan = NULL; - AggStrategy aggregateStrategy = AGG_PLAIN; - AggClauseCosts aggregateCosts; - List *aggregateTargetList = NIL; - List *groupColumnList = NIL; - Node *havingQual = NULL; - uint32 groupColumnCount = 0; - /* assert that we need to build an aggregate plan */ Assert(masterQuery->hasAggs || masterQuery->groupClause); - - aggregateTargetList = masterQuery->targetList; + AggClauseCosts aggregateCosts; + AggStrategy aggregateStrategy = AGG_PLAIN; + List *groupColumnList = masterQuery->groupClause; + List *aggregateTargetList = masterQuery->targetList; /* * Replaces SubLink nodes with SubPlan nodes in the having section of the @@ -392,7 +384,7 @@ BuildAggregatePlan(PlannerInfo *root, Query *masterQuery, Plan *subPlan) * these when that is true. However, for some reason hasSubLinks is false * even when there are SubLinks. */ - havingQual = SS_process_sublinks(root, masterQuery->havingQual, true); + Node *havingQual = SS_process_sublinks(root, masterQuery->havingQual, true); /* * Right now this is not really needed, since we don't support correlated @@ -409,11 +401,9 @@ BuildAggregatePlan(PlannerInfo *root, Query *masterQuery, Plan *subPlan) get_agg_clause_costs(root, (Node *) havingQual, AGGSPLIT_SIMPLE, &aggregateCosts); - groupColumnList = masterQuery->groupClause; - groupColumnCount = list_length(groupColumnList); /* if we have grouping, then initialize appropriate information */ - if (groupColumnCount > 0) + if (list_length(groupColumnList) > 0) { bool groupingIsHashable = grouping_is_hashable(groupColumnList); bool groupingIsSortable = grouping_is_sortable(groupColumnList); @@ -460,8 +450,8 @@ BuildAggregatePlan(PlannerInfo *root, Query *masterQuery, Plan *subPlan) } /* finally create the plan */ - aggregatePlan = makeAggNode(groupColumnList, (List *) havingQual, - aggregateStrategy, aggregateTargetList, subPlan); + Agg *aggregatePlan = makeAggNode(groupColumnList, (List *) havingQual, + aggregateStrategy, aggregateTargetList, subPlan); /* just for reproducible costs between different PostgreSQL versions */ aggregatePlan->plan.startup_cost = 0;