diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 200a4a4c2af51f7adad33379bf50533540201057..c4b38e18633f6ae0f8be829cd453dec038bf6497 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -2973,7 +2973,7 @@ cookConstraint (ParseState *pstate, ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), errmsg("cannot use aggregate function in check constraint"))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("cannot use window function in check constraint"))); @@ -3082,7 +3082,7 @@ cookDefault(ParseState *pstate, ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), errmsg("cannot use aggregate function in default expression"))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("cannot use window function in default expression"))); diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 9dcab958c548a6ddbbc99d9ac0449bc9eca7ef16..8a045a82df60e3b45a4b60242626879eb2c42a8a 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -376,7 +376,7 @@ examine_parameter_list(List *parameters, Oid languageOid, (errcode(ERRCODE_GROUPING_ERROR), errmsg("cannot use aggregate function in parameter default value"))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), errmsg("cannot use window function in parameter default value"))); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index e149c8d55d4a45df329c4067dd7413d8d83af683..4c972cee7c04b168481fb57c7c3036e97a4e7283 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8131,7 +8131,7 @@ ATPrepAlterColumnType(List **wqueue, ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), errmsg("cannot use aggregate function in transform expression"))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("cannot use window function in transform expression"))); diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index 87abb528fc26bb035c40d873188a5c217416693d..d7820a653f8e5b8eea0d4b7175eaba584580e49c 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -2300,7 +2300,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), errmsg("cannot use aggregate function in check constraint"))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("cannot use window function in check constraint"))); diff --git a/src/backend/gpopt/translate/CQueryMutators.cpp b/src/backend/gpopt/translate/CQueryMutators.cpp index d184d4636240ef6291e4cdb7bc805e7a475000f2..4233bb16a6ac7cf5edd2afe129c60718abe7ae20 100644 --- a/src/backend/gpopt/translate/CQueryMutators.cpp +++ b/src/backend/gpopt/translate/CQueryMutators.cpp @@ -1280,7 +1280,7 @@ CQueryMutators::PqueryNormalizeHaving pqueryNewSubquery->targetList = NIL; pqueryNewSubquery->hasAggs = false; - pqueryNewSubquery->hasWindFuncs = false; + pqueryNewSubquery->hasWindowFuncs = false; pqueryNewSubquery->hasSubLinks = false; ListCell *plc = NULL; @@ -1595,7 +1595,7 @@ CQueryMutators::FNeedsWindowPrLNormalization const Query *pquery ) { - if (!pquery->hasWindFuncs) + if (!pquery->hasWindowFuncs) { return false; } @@ -1759,7 +1759,7 @@ CQueryMutators::PqueryNormalizeWindowPrL GPOS_ASSERT(gpdb::UlListLength(pqueryNew->targetList) <= gpdb::UlListLength(pquery->targetList)); - pqueryNew->hasWindFuncs = false; + pqueryNew->hasWindowFuncs = false; ReassignSortClause(pqueryNew, pqueryDrdTbl); return pqueryNew; diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index a2484bac8d8a9990881a5747d373957764ce6a1b..dca3c41ae865435271639884ca0107db17340caf 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -2826,7 +2826,7 @@ _copyQuery(Query *from) COPY_SCALAR_FIELD(resultRelation); COPY_NODE_FIELD(intoClause); COPY_SCALAR_FIELD(hasAggs); - COPY_SCALAR_FIELD(hasWindFuncs); + COPY_SCALAR_FIELD(hasWindowFuncs); COPY_SCALAR_FIELD(hasSubLinks); COPY_SCALAR_FIELD(hasDynamicFunctions); COPY_NODE_FIELD(rtable); diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 2b18baab4823d8bfbb0e436ebb31150ca7d26d2d..1a428e1286e551670430a10201db6097522733ac 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -840,7 +840,7 @@ _equalQuery(Query *a, Query *b) COMPARE_SCALAR_FIELD(resultRelation); COMPARE_NODE_FIELD(intoClause); COMPARE_SCALAR_FIELD(hasAggs); - COMPARE_SCALAR_FIELD(hasWindFuncs); + COMPARE_SCALAR_FIELD(hasWindowFuncs); COMPARE_SCALAR_FIELD(hasSubLinks); COMPARE_SCALAR_FIELD(hasDynamicFunctions); COMPARE_NODE_FIELD(rtable); diff --git a/src/backend/nodes/outfast.c b/src/backend/nodes/outfast.c index d3ef28ba61d6dc1eb59c75522ebee5c3e009766f..ce2257ca45d1435d4e8fc56365e6916283bff62f 100644 --- a/src/backend/nodes/outfast.c +++ b/src/backend/nodes/outfast.c @@ -894,7 +894,7 @@ _outQuery(StringInfo str, Query *node) WRITE_INT_FIELD(resultRelation); WRITE_NODE_FIELD(intoClause); WRITE_BOOL_FIELD(hasAggs); - WRITE_BOOL_FIELD(hasWindFuncs); + WRITE_BOOL_FIELD(hasWindowFuncs); WRITE_BOOL_FIELD(hasSubLinks); WRITE_BOOL_FIELD(hasDynamicFunctions); WRITE_NODE_FIELD(rtable); diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 657410781b7b500dd9a33bb1701c8a47986f1372..22e1cc533a93c3dc3caaa0047a057d6bc178fbad 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -3493,7 +3493,7 @@ _outQuery(StringInfo str, Query *node) WRITE_INT_FIELD(resultRelation); WRITE_NODE_FIELD(intoClause); WRITE_BOOL_FIELD(hasAggs); - WRITE_BOOL_FIELD(hasWindFuncs); + WRITE_BOOL_FIELD(hasWindowFuncs); WRITE_BOOL_FIELD(hasSubLinks); WRITE_BOOL_FIELD(hasDynamicFunctions); WRITE_NODE_FIELD(rtable); diff --git a/src/backend/nodes/readfast.c b/src/backend/nodes/readfast.c index 8e60601babf423433a62b8563cb8c721f806237e..892ead6c2acaa97fc1957ed39a6fa31a4e8f9020 100644 --- a/src/backend/nodes/readfast.c +++ b/src/backend/nodes/readfast.c @@ -228,7 +228,7 @@ _readQuery(void) READ_INT_FIELD(resultRelation); READ_NODE_FIELD(intoClause); READ_BOOL_FIELD(hasAggs); - READ_BOOL_FIELD(hasWindFuncs); + READ_BOOL_FIELD(hasWindowFuncs); READ_BOOL_FIELD(hasSubLinks); READ_BOOL_FIELD(hasDynamicFunctions); READ_NODE_FIELD(rtable); diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 9c49fb4402a252c71eeac3b8d0db4715741c2676..3e29b5b4f42f1b9ac9d815ade922823f549a06e7 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -322,7 +322,7 @@ _readQuery(void) READ_INT_FIELD(resultRelation); READ_NODE_FIELD(intoClause); READ_BOOL_FIELD(hasAggs); - READ_BOOL_FIELD(hasWindFuncs); + READ_BOOL_FIELD(hasWindowFuncs); READ_BOOL_FIELD(hasSubLinks); READ_BOOL_FIELD(hasDynamicFunctions); READ_NODE_FIELD(rtable); diff --git a/src/backend/optimizer/plan/planwindow.c b/src/backend/optimizer/plan/planwindow.c index c68ce88ada604b6d33c4397424c5aa81c1e577e9..6c448d17ff17316ab601a6615dc4b4e0f0e5b1d3 100644 --- a/src/backend/optimizer/plan/planwindow.c +++ b/src/backend/optimizer/plan/planwindow.c @@ -296,7 +296,7 @@ window_planner(PlannerInfo *root, double tuple_fraction, List **pathkeys_ptr) /* Assert existence of windowing in query. */ Assert(parse->targetList != NIL); Assert(parse->windowClause != NULL); - Assert(parse->hasWindFuncs); + Assert(parse->hasWindowFuncs); /* Assert no unsupported stuff */ Assert(parse->setOperations == NULL); Assert(!parse->hasAggs); @@ -1303,7 +1303,7 @@ make_lower_targetlist(Query *parse, SortClause *dummy; ListCell *lc; - Assert ( parse->hasWindFuncs ); + Assert ( parse->hasWindowFuncs ); /* Start with a "flattened" tlist (having just the vars mentioned in * the targetlist or the window clause --- but no upper-level Vars; @@ -3958,7 +3958,7 @@ Plan *wrap_plan(PlannerInfo *root, Plan *plan, Query *query, subquery->resultRelation = 0; subquery->intoClause = NULL; subquery->hasAggs = false; - subquery->hasWindFuncs = false; + subquery->hasWindowFuncs = false; subquery->hasSubLinks = false; subquery->returningList = NIL; subquery->groupClause = NIL; @@ -4084,7 +4084,7 @@ Query *copy_common_subquery(Query *original, List *targetList) common->resultRelation = 0; common->utilityStmt = NULL; common->intoClause = NULL; - common->hasWindFuncs = false; + common->hasWindowFuncs = false; common->hasSubLinks = false; /* XXX */ common->returningList = NIL; common->distinctClause = NIL; diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index 3f4b7b038257450c37ced1d5a0793bba275ccb60..885fbd4ed2162c55615fbbcd80569b3dfc11466d 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -716,7 +716,7 @@ is_simple_subquery(PlannerInfo *root, Query *subquery) * limiting, or WITH. (XXX WITH could possibly be allowed later) */ if (subquery->hasAggs || - subquery->hasWindFuncs || + subquery->hasWindowFuncs || subquery->groupClause || subquery->havingQual || subquery->windowClause || diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index ac82ed8af8e97b4b6e23b9adba3e9b9bf98e42d4..63ec2b54aea0d0468543bfb8998544b45c1df661 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -809,7 +809,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) errmsg("cannot use aggregate function in VALUES"), parser_errposition(pstate, locate_agg_of_level((Node *) qry, 0)))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), errmsg("cannot use window function in VALUES"))); @@ -918,7 +918,7 @@ transformGroupedWindows(Query *qry) Assert(!PointerIsValid(qry->utilityStmt)); Assert(qry->returningList == NIL); - if ( !qry->hasWindFuncs || !(qry->groupClause || qry->hasAggs) ) + if ( !qry->hasWindowFuncs || !(qry->groupClause || qry->hasAggs) ) return qry; /* Make the new subquery (Q''). Note that (per SQL:2003) there @@ -933,7 +933,7 @@ transformGroupedWindows(Query *qry) subq->resultRelation = 0; subq->intoClause = NULL; subq->hasAggs = qry->hasAggs; - subq->hasWindFuncs = false; /* reevaluate later */ + subq->hasWindowFuncs = false; /* reevaluate later */ subq->hasSubLinks = qry->hasSubLinks; /* reevaluate later */ /* Core of subquery input table expression: */ @@ -953,10 +953,10 @@ transformGroupedWindows(Query *qry) subq->setOperations = NULL; /* Check if there is a window function in the join tree. If so - * we must mark hasWindFuncs in the sub query as well. + * we must mark hasWindowFuncs in the sub query as well. */ if (checkExprHasWindFuncs((Node *)subq->jointree)) - subq->hasWindFuncs = true; + subq->hasWindowFuncs = true; /* Make the single range table entry for the outer query Q' as * a wrapper for the subquery (Q'') currently under construction. @@ -1652,8 +1652,8 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) if (pstate->p_hasTblValueExpr) parseCheckTableFunctions(pstate, qry); - qry->hasWindFuncs = pstate->p_hasWindFuncs; - if (pstate->p_hasWindFuncs) + qry->hasWindowFuncs = pstate->p_hasWindowFuncs; + if (pstate->p_hasWindowFuncs) parseProcessWindFuncs(pstate, qry); @@ -1666,7 +1666,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) * If the query mixes window functions and aggregates, we need to * transform it such that the grouped query appears as a subquery */ - if (qry->hasWindFuncs && (qry->groupClause || qry->hasAggs)) + if (qry->hasWindowFuncs && (qry->groupClause || qry->hasAggs)) transformGroupedWindows(qry); return qry; @@ -1882,7 +1882,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt) errmsg("cannot use aggregate function in VALUES"), parser_errposition(pstate, locate_agg_of_level((Node *) newExprsLists, 0)))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), errmsg("cannot use window function in VALUES"))); @@ -2744,7 +2744,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt) errmsg("cannot use aggregate function in UPDATE"), parser_errposition(pstate, locate_agg_of_level((Node *) qry, 0)))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), errmsg("cannot use window function in UPDATE"))); @@ -2853,7 +2853,7 @@ transformReturningList(ParseState *pstate, List *returningList) (errcode(ERRCODE_GROUPING_ERROR), errmsg("cannot use aggregate function in RETURNING"))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("cannot use window function in RETURNING"))); @@ -3044,7 +3044,7 @@ CheckSelectLocking(Query *qry) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("SELECT FOR UPDATE/SHARE is not allowed with aggregate functions"))); - if (qry->hasWindFuncs) + if (qry->hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("SELECT FOR UPDATE/SHARE is not allowed with window functions"))); diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 7b982b3d98e9abc65592b2bcb7dd1155b9547bb7..ff896a47a0471e02aeb0c5d84dbdd4a2d353b8bb 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -121,7 +121,7 @@ check_call(ParseState *pstate, Node *call) if (is_agg) pstate->p_hasAggs = true; else - pstate->p_hasWindFuncs = true; + pstate->p_hasWindowFuncs = true; } /* @@ -212,7 +212,7 @@ transformWindowFuncCall(ParseState *pstate, WindowRef *wind, check_call(pstate, (Node *)wind); - pstate->p_hasWindFuncs = true; + pstate->p_hasWindowFuncs = true; } /* @@ -995,7 +995,7 @@ void parseProcessWindFuncs(ParseState *pstate, Query *qry) { /* This should only be called if we found window functions */ - Assert(pstate->p_hasWindFuncs); + Assert(pstate->p_hasWindowFuncs); /* * Window functions must never appear in WHERE or diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 4e3d1c0217564013eac656b3211860576a9ab10b..39aaaa03e7320d5699d08351bcdbc79c16afb69f 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -708,7 +708,7 @@ transformWindowClause(ParseState *pstate, Query *qry) /* If there are no window functions in the targetlist, * forget the window clause. */ - if (!pstate->p_hasWindFuncs) + if (!pstate->p_hasWindowFuncs) { pstate->p_win_clauses = NIL; qry->windowClause = NIL; @@ -2851,7 +2851,7 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, { /* We had SELECT DISTINCT */ - if (!pstate->p_hasAggs && !pstate->p_hasWindFuncs && *groupClause == NIL) + if (!pstate->p_hasAggs && !pstate->p_hasWindowFuncs && *groupClause == NIL) { /* * MPP-15040 diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index bbb635bc31a7050ec3ef20f0b31ed6cd8efdae6b..9452f9b590076bcefb52829d3fb08a0525f31ed6 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -2803,7 +2803,7 @@ transformRuleStmt(RuleStmt *stmt, const char *queryString, (errcode(ERRCODE_GROUPING_ERROR), errmsg("cannot use aggregate function in rule WHERE condition"))); - if (pstate->p_hasWindFuncs) + if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("cannot use window function in rule WHERE condition"))); diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 9e2a58294bba435e62bd99d5792efc52f04ac7c8..cab92b193ab19c775f9af0eaf4c293bd0da60b76 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -120,7 +120,7 @@ typedef struct Query IntoClause *intoClause; /* target for SELECT INTO / CREATE TABLE AS */ bool hasAggs; /* has aggregates in tlist or havingQual */ - bool hasWindFuncs; /* has window function(s) in target list */ + bool hasWindowFuncs; /* has window functions in tlist */ bool hasSubLinks; /* has subquery SubLink */ bool hasDynamicFunctions; /* has functions with unstable return types */ diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h index afc83a0eddf89e645746eedaa601c8909a544b2d..1bec26d56dc9bd969adb6d0c95e2018f298bbc21 100644 --- a/src/include/parser/parse_node.h +++ b/src/include/parser/parse_node.h @@ -84,7 +84,7 @@ typedef struct ParseState Node *p_value_substitute; /* what to replace VALUE with, if any */ bool p_variableparams; bool p_hasAggs; - bool p_hasWindFuncs; + bool p_hasWindowFuncs; bool p_hasSubLinks; bool p_hasModifyingCTE; bool p_is_insert;