From a203082816c4601e80acd7c80e072c10d74d6ae0 Mon Sep 17 00:00:00 2001 From: Lukas Fittl Date: Mon, 16 Dec 2024 18:14:31 -0800 Subject: [PATCH] Deparser: Set A_EXPR node context for deparseExpr and deparseFuncCall This allows us to handle keyword-style FuncCalls correctly in deparseFuncCall, as will be done in a subsequent commit. Note that the safe choice here is to set the context to NONE, which intends to add parenthesis in places where a_expr is not allowed (b_expr or c_expr can be turned into an a_expr by being wrapped in parens) --- src/postgres_deparse.c | 279 +++++++++++++++++++++-------------------- 1 file changed, 140 insertions(+), 139 deletions(-) diff --git a/src/postgres_deparse.c b/src/postgres_deparse.c index 48aca831..dbf60a09 100644 --- a/src/postgres_deparse.c +++ b/src/postgres_deparse.c @@ -181,9 +181,9 @@ static void deparseReplicaIdentityStmt(StringInfo str, ReplicaIdentityStmt *repl static void deparseRangeTableSample(StringInfo str, RangeTableSample *range_table_sample); static void deparseRangeTableFunc(StringInfo str, RangeTableFunc* range_table_func); static void deparseGroupingSet(StringInfo str, GroupingSet *grouping_set); -static void deparseFuncCall(StringInfo str, FuncCall *func_call); +static void deparseFuncCall(StringInfo str, FuncCall *func_call, DeparseNodeContext context); static void deparseMinMaxExpr(StringInfo str, MinMaxExpr *min_max_expr); -static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr); +static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr, DeparseNodeContext context); static void deparseXmlSerialize(StringInfo str, XmlSerialize *xml_serialize); static void deparseJsonIsPredicate(StringInfo str, JsonIsPredicate *json_is_predicate); static void deparseJsonObjectAgg(StringInfo str, JsonObjectAgg *json_object_agg); @@ -261,12 +261,12 @@ static void deparseAnyNameSkipLast(StringInfo str, List *parts) } // "func_expr" in gram.y -static void deparseFuncExpr(StringInfo str, Node *node) +static void deparseFuncExpr(StringInfo str, Node *node, DeparseNodeContext context) { switch (nodeTag(node)) { case T_FuncCall: - deparseFuncCall(str, castNode(FuncCall, node)); + deparseFuncCall(str, castNode(FuncCall, node), context); break; case T_SQLValueFunction: deparseSQLValueFunction(str, castNode(SQLValueFunction, node)); @@ -278,7 +278,7 @@ static void deparseFuncExpr(StringInfo str, Node *node) deparseCoalesceExpr(str, castNode(CoalesceExpr, node)); break; case T_XmlExpr: - deparseXmlExpr(str, castNode(XmlExpr, node)); + deparseXmlExpr(str, castNode(XmlExpr, node), context); break; case T_XmlSerialize: deparseXmlSerialize(str, castNode(XmlSerialize, node)); @@ -308,7 +308,7 @@ static void deparseFuncExpr(StringInfo str, Node *node) static void deparseCExpr(StringInfo str, Node *node); // "a_expr" in gram.y -static void deparseExpr(StringInfo str, Node *node) +static void deparseExpr(StringInfo str, Node *node, DeparseNodeContext context) { if (node == NULL) return; @@ -375,7 +375,7 @@ static void deparseExpr(StringInfo str, Node *node) case T_JsonObjectConstructor: case T_JsonArrayConstructor: case T_JsonArrayQueryConstructor: - deparseFuncExpr(str, node); + deparseFuncExpr(str, node, context); break; default: // Note that this is also the fallthrough for deparseBExpr and deparseCExpr @@ -389,7 +389,7 @@ static void deparseExpr(StringInfo str, Node *node) static void deparseBExpr(StringInfo str, Node *node) { if (IsA(node, XmlExpr)) { - deparseXmlExpr(str, castNode(XmlExpr, node)); + deparseXmlExpr(str, castNode(XmlExpr, node), DEPARSE_NODE_CONTEXT_NONE); return; } @@ -474,11 +474,12 @@ static void deparseCExpr(StringInfo str, Node *node) case T_JsonObjectConstructor: case T_JsonArrayConstructor: case T_JsonArrayQueryConstructor: - deparseFuncExpr(str, node); + deparseFuncExpr(str, node, DEPARSE_NODE_CONTEXT_NONE); break; default: appendStringInfoChar(str, '('); - deparseExpr(str, node); + // Because we wrap this in parenthesis, the expression inside follows "a_expr" parser rules + deparseExpr(str, node, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ')'); break; } @@ -490,7 +491,7 @@ static void deparseExprList(StringInfo str, List *exprs) ListCell *lc; foreach(lc, exprs) { - deparseExpr(str, lfirst(lc)); + deparseExpr(str, lfirst(lc), DEPARSE_NODE_CONTEXT_A_EXPR); if (lnext(exprs, lc)) appendStringInfoString(str, ", "); } @@ -1596,7 +1597,7 @@ static void deparseTargetList(StringInfo str, List *l) else if (IsA(res_target->val, ColumnRef)) deparseColumnRef(str, castNode(ColumnRef, res_target->val)); else - deparseExpr(str, res_target->val); + deparseExpr(str, res_target->val, DEPARSE_NODE_CONTEXT_A_EXPR); if (res_target->name != NULL) { appendStringInfoString(str, " AS "); @@ -1634,7 +1635,7 @@ static void deparseXmlAttributeList(StringInfo str, List *l) ResTarget *res_target = castNode(ResTarget, lfirst(lc)); Assert(res_target->val != NULL); - deparseExpr(str, res_target->val); + deparseExpr(str, res_target->val, DEPARSE_NODE_CONTEXT_A_EXPR); if (res_target->name != NULL) { @@ -1660,7 +1661,7 @@ static void deparseXmlNamespaceList(StringInfo str, List *l) if (res_target->name == NULL) appendStringInfoString(str, "DEFAULT "); - deparseExpr(str, res_target->val); + deparseExpr(str, res_target->val, DEPARSE_NODE_CONTEXT_NONE /* b_expr */); if (res_target->name != NULL) { @@ -1738,7 +1739,7 @@ static void deparseWhereClause(StringInfo str, Node *node) if (node != NULL) { appendStringInfoString(str, "WHERE "); - deparseExpr(str, node); + deparseExpr(str, node, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); } } @@ -1758,7 +1759,7 @@ static void deparseWhereOrCurrentClause(StringInfo str, Node *node) appendStringInfoString(str, "CURRENT OF "); appendStringInfoString(str, quote_identifier(current_of_expr->cursor_name)); } else { - deparseExpr(str, node); + deparseExpr(str, node, DEPARSE_NODE_CONTEXT_A_EXPR); } appendStringInfoChar(str, ' '); @@ -1774,7 +1775,7 @@ static void deparseGroupByList(StringInfo str, List *l) if (IsA(lfirst(lc), GroupingSet)) deparseGroupingSet(str, castNode(GroupingSet, lfirst(lc))); else - deparseExpr(str, lfirst(lc)); + deparseExpr(str, lfirst(lc), DEPARSE_NODE_CONTEXT_A_EXPR); if (lnext(l, lc)) appendStringInfoString(str, ", "); @@ -1844,11 +1845,11 @@ static void deparseFuncArgExpr(StringInfo str, Node *node) NamedArgExpr *named_arg_expr = castNode(NamedArgExpr, node); appendStringInfoString(str, named_arg_expr->name); appendStringInfoString(str, " := "); - deparseExpr(str, (Node *) named_arg_expr->arg); + deparseExpr(str, (Node *) named_arg_expr->arg, DEPARSE_NODE_CONTEXT_A_EXPR); } else { - deparseExpr(str, node); + deparseExpr(str, node, DEPARSE_NODE_CONTEXT_A_EXPR); } } @@ -1888,14 +1889,14 @@ static void deparseSetClauseList(StringInfo str, List *target_list) appendStringInfoString(str, ", "); } appendStringInfoString(str, ") = "); - deparseExpr(str, r->source); + deparseExpr(str, r->source, DEPARSE_NODE_CONTEXT_A_EXPR); skip_next_n_elems = r->ncolumns - 1; } else { deparseSetTarget(str, res_target); appendStringInfoString(str, " = "); - deparseExpr(str, res_target->val); + deparseExpr(str, res_target->val, DEPARSE_NODE_CONTEXT_A_EXPR); } } } @@ -1906,7 +1907,7 @@ static void deparseFuncExprWindowless(StringInfo str, Node* node) switch (nodeTag(node)) { case T_FuncCall: - deparseFuncCall(str, castNode(FuncCall, node)); + deparseFuncCall(str, castNode(FuncCall, node), DEPARSE_NODE_CONTEXT_NONE /* we don't know which kind of expression */); break; case T_SQLValueFunction: deparseSQLValueFunction(str, castNode(SQLValueFunction, node)); @@ -1921,7 +1922,7 @@ static void deparseFuncExprWindowless(StringInfo str, Node* node) deparseMinMaxExpr(str, castNode(MinMaxExpr, node)); break; case T_XmlExpr: - deparseXmlExpr(str, castNode(XmlExpr, node)); + deparseXmlExpr(str, castNode(XmlExpr, node), DEPARSE_NODE_CONTEXT_NONE /* we don't know which kind of expression */); break; case T_XmlSerialize: deparseXmlSerialize(str, castNode(XmlSerialize, node)); @@ -1968,7 +1969,7 @@ static void deparseIndexElem(StringInfo str, IndexElem* index_elem) break; default: appendStringInfoChar(str, '('); - deparseExpr(str, index_elem->expr); + deparseExpr(str, index_elem->expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } } @@ -2318,7 +2319,7 @@ static void deparseSelectStmt(StringInfo str, SelectStmt *stmt) if (stmt->havingClause != NULL) { appendStringInfoString(str, "HAVING "); - deparseExpr(str, stmt->havingClause); + deparseExpr(str, stmt->havingClause, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); } @@ -2401,7 +2402,7 @@ static void deparseSelectStmt(StringInfo str, SelectStmt *stmt) else if (stmt->limitOption == LIMIT_OPTION_WITH_TIES) deparseCExpr(str, stmt->limitCount); else - deparseExpr(str, stmt->limitCount); + deparseExpr(str, stmt->limitCount, DEPARSE_NODE_CONTEXT_NONE /* c_expr */); appendStringInfoChar(str, ' '); @@ -2412,7 +2413,7 @@ static void deparseSelectStmt(StringInfo str, SelectStmt *stmt) if (stmt->limitOffset != NULL) { appendStringInfoString(str, "OFFSET "); - deparseExpr(str, stmt->limitOffset); + deparseExpr(str, stmt->limitOffset, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); } @@ -2538,7 +2539,7 @@ static void deparseAConst(StringInfo str, A_Const *a_const) deparseValue(str, val, DEPARSE_NODE_CONTEXT_CONSTANT); } -static void deparseFuncCall(StringInfo str, FuncCall *func_call) +static void deparseFuncCall(StringInfo str, FuncCall *func_call, DeparseNodeContext context) { const ListCell *lc = NULL; @@ -2554,13 +2555,13 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) * keyword parameter style when its called as a keyword, not as a regular function (i.e. pg_catalog.overlay) */ appendStringInfoString(str, "OVERLAY("); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " PLACING "); - deparseExpr(str, lsecond(func_call->args)); + deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " FROM "); - deparseExpr(str, lthird(func_call->args)); + deparseExpr(str, lthird(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " FOR "); - deparseExpr(str, lfourth(func_call->args)); + deparseExpr(str, lfourth(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ')'); return; } else if (func_call->funcformat == COERCE_SQL_SYNTAX && @@ -2574,13 +2575,13 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) */ Assert(list_length(func_call->args) == 2 || list_length(func_call->args) == 3); appendStringInfoString(str, "SUBSTRING("); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " FROM "); - deparseExpr(str, lsecond(func_call->args)); + deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); if (list_length(func_call->args) == 3) { appendStringInfoString(str, " FOR "); - deparseExpr(str, lthird(func_call->args)); + deparseExpr(str, lthird(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); } appendStringInfoChar(str, ')'); return; @@ -2612,11 +2613,11 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) * keyword parameter style when its called as a keyword, not as a regular function (i.e. pg_catalog.overlay) */ appendStringInfoString(str, "overlay("); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " placing "); - deparseExpr(str, lsecond(func_call->args)); + deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " from "); - deparseExpr(str, lthird(func_call->args)); + deparseExpr(str, lthird(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ')'); return; } else if (func_call->funcformat == COERCE_SQL_SYNTAX && @@ -2630,7 +2631,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) * keyword parameter style when its called as a keyword, not as a regular function (i.e. pg_catalog.overlay) */ appendStringInfoString(str, "collation for ("); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ')'); return; } else if (func_call->funcformat == COERCE_SQL_SYNTAX && @@ -2644,9 +2645,9 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) * keyword parameter style when its called as a keyword, not as a regular function (i.e. pg_catalog.extract) */ appendStringInfoString(str, "extract ("); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " FROM "); - deparseExpr(str, lsecond(func_call->args)); + deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ')'); return; } else if (func_call->funcformat == COERCE_SQL_SYNTAX && @@ -2661,16 +2662,16 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) * format: (start_1, end_1) overlaps (start_2, end_2) */ appendStringInfoChar(str, '('); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ", "); - deparseExpr(str, lsecond(func_call->args)); + deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); appendStringInfoString(str, "overlaps "); appendStringInfoChar(str, '('); - deparseExpr(str, lthird(func_call->args)); + deparseExpr(str, lthird(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ", "); - deparseExpr(str, lfourth(func_call->args)); + deparseExpr(str, lfourth(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); return; } else if (func_call->funcformat == COERCE_SQL_SYNTAX && @@ -2697,9 +2698,9 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) appendStringInfoString(str, "TRAILING "); if (list_length(func_call->args) == 2) - deparseExpr(str, lsecond(func_call->args)); + deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " FROM "); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ')'); return; } else if (func_call->funcformat == COERCE_SQL_SYNTAX && @@ -2726,7 +2727,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) appendStringInfoChar(str, '('); } - deparseExpr(str, (Node*) e); + deparseExpr(str, (Node*) e, DEPARSE_NODE_CONTEXT_A_EXPR); if (IsA(e, A_Expr)) { appendStringInfoChar(str, ')'); @@ -2736,7 +2737,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) appendStringInfoString(str, " AT LOCAL"); else { appendStringInfoString(str, " AT TIME ZONE "); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); } return; } else if (func_call->funcformat == COERCE_SQL_SYNTAX && @@ -2751,7 +2752,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) Assert(list_length(func_call->args) == 1 || list_length(func_call->args) == 2); appendStringInfoString(str, "normalize ("); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); if (list_length(func_call->args) == 2) { appendStringInfoString(str, ", "); @@ -2772,7 +2773,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) */ Assert(list_length(func_call->args) == 1 || list_length(func_call->args) == 2); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " IS "); if (list_length(func_call->args) == 2) { @@ -2789,9 +2790,9 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) list_length(func_call->args) == 2) { appendStringInfoString(str, "xmlexists ("); - deparseExpr(str, linitial(func_call->args)); + deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_NONE /* c_expr */); appendStringInfoString(str, " PASSING "); - deparseExpr(str, lsecond(func_call->args)); + deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_NONE /* c_expr */); appendStringInfoChar(str, ')'); return; } else if (func_call->funcformat == COERCE_SQL_SYNTAX && @@ -2845,7 +2846,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call) if (func_call->agg_filter) { appendStringInfoString(str, "FILTER (WHERE "); - deparseExpr(str, func_call->agg_filter); + deparseExpr(str, func_call->agg_filter, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } @@ -2912,13 +2913,13 @@ static void deparseWindowDef(StringInfo str, WindowDef* window_def) else if (window_def->frameOptions & FRAMEOPTION_START_OFFSET_PRECEDING) { Assert(window_def->startOffset != NULL); - deparseExpr(str, window_def->startOffset); + deparseExpr(str, window_def->startOffset, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " PRECEDING "); } else if (window_def->frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING) { Assert(window_def->startOffset != NULL); - deparseExpr(str, window_def->startOffset); + deparseExpr(str, window_def->startOffset, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " FOLLOWING "); } @@ -2942,13 +2943,13 @@ static void deparseWindowDef(StringInfo str, WindowDef* window_def) else if (window_def->frameOptions & FRAMEOPTION_END_OFFSET_PRECEDING) { Assert(window_def->endOffset != NULL); - deparseExpr(str, window_def->endOffset); + deparseExpr(str, window_def->endOffset, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " PRECEDING "); } else if (window_def->frameOptions & FRAMEOPTION_END_OFFSET_FOLLOWING) { Assert(window_def->endOffset != NULL); - deparseExpr(str, window_def->endOffset); + deparseExpr(str, window_def->endOffset, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " FOLLOWING "); } } @@ -2986,7 +2987,7 @@ static void deparseSubLink(StringInfo str, SubLink* sub_link) appendStringInfoChar(str, ')'); return; case ALL_SUBLINK: - deparseExpr(str, sub_link->testexpr); + deparseExpr(str, sub_link->testexpr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); deparseSubqueryOp(str, sub_link->operName); appendStringInfoString(str, " ALL ("); @@ -2994,7 +2995,7 @@ static void deparseSubLink(StringInfo str, SubLink* sub_link) appendStringInfoChar(str, ')'); return; case ANY_SUBLINK: - deparseExpr(str, sub_link->testexpr); + deparseExpr(str, sub_link->testexpr, DEPARSE_NODE_CONTEXT_A_EXPR); if (list_length(sub_link->operName) > 0) { appendStringInfoChar(str, ' '); @@ -3054,7 +3055,7 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont { if (need_lexpr_parens) appendStringInfoChar(str, '('); - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); if (need_lexpr_parens) appendStringInfoChar(str, ')'); appendStringInfoChar(str, ' '); @@ -3065,7 +3066,7 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont appendStringInfoChar(str, ' '); if (need_rexpr_parens) appendStringInfoChar(str, '('); - deparseExpr(str, a_expr->rexpr); + deparseExpr(str, a_expr->rexpr, context); if (need_rexpr_parens) appendStringInfoChar(str, ')'); } @@ -3075,19 +3076,19 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont } return; case AEXPR_OP_ANY: /* scalar op ANY (array) */ - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); appendStringInfoChar(str, ' '); deparseSubqueryOp(str, a_expr->name); appendStringInfoString(str, " ANY("); - deparseExpr(str, a_expr->rexpr); + deparseExpr(str, a_expr->rexpr, context); appendStringInfoChar(str, ')'); return; case AEXPR_OP_ALL: /* scalar op ALL (array) */ - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); appendStringInfoChar(str, ' '); deparseSubqueryOp(str, a_expr->name); appendStringInfoString(str, " ALL("); - deparseExpr(str, a_expr->rexpr); + deparseExpr(str, a_expr->rexpr, context); appendStringInfoChar(str, ')'); return; case AEXPR_DISTINCT: /* IS DISTINCT FROM - name must be "=" */ @@ -3097,13 +3098,13 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont if (need_lexpr_parens) appendStringInfoChar(str, '('); - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); if (need_lexpr_parens) appendStringInfoChar(str, ')'); appendStringInfoString(str, " IS DISTINCT FROM "); if (need_rexpr_parens) appendStringInfoChar(str, '('); - deparseExpr(str, a_expr->rexpr); + deparseExpr(str, a_expr->rexpr, context); if (need_rexpr_parens) appendStringInfoChar(str, ')'); return; @@ -3112,9 +3113,9 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont Assert(IsA(linitial(a_expr->name), String)); Assert(strcmp(strVal(linitial(a_expr->name)), "=") == 0); - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); appendStringInfoString(str, " IS NOT DISTINCT FROM "); - deparseExpr(str, a_expr->rexpr); + deparseExpr(str, a_expr->rexpr, context); return; case AEXPR_NULLIF: /* NULLIF - name must be "=" */ Assert(list_length(a_expr->name) == 1); @@ -3122,16 +3123,16 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont Assert(strcmp(strVal(linitial(a_expr->name)), "=") == 0); appendStringInfoString(str, "NULLIF("); - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); appendStringInfoString(str, ", "); - deparseExpr(str, a_expr->rexpr); + deparseExpr(str, a_expr->rexpr, context); appendStringInfoChar(str, ')'); return; case AEXPR_IN: /* [NOT] IN - name must be "=" or "<>" */ Assert(list_length(a_expr->name) == 1); Assert(IsA(linitial(a_expr->name), String)); Assert(IsA(a_expr->rexpr, List)); - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); appendStringInfoChar(str, ' '); name = ((union ValUnion *) linitial(a_expr->name))->sval.sval; if (strcmp(name, "=") == 0) { @@ -3151,7 +3152,7 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont case AEXPR_LIKE: /* [NOT] LIKE - name must be "~~" or "!~~" */ Assert(list_length(a_expr->name) == 1); Assert(IsA(linitial(a_expr->name), String)); - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); appendStringInfoChar(str, ' '); name = ((union ValUnion *) linitial(a_expr->name))->sval.sval; @@ -3163,12 +3164,12 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont Assert(false); } - deparseExpr(str, a_expr->rexpr); + deparseExpr(str, a_expr->rexpr, context); return; case AEXPR_ILIKE: /* [NOT] ILIKE - name must be "~~*" or "!~~*" */ Assert(list_length(a_expr->name) == 1); Assert(IsA(linitial(a_expr->name), String)); - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); appendStringInfoChar(str, ' '); name = ((union ValUnion *) linitial(a_expr->name))->sval.sval; @@ -3180,12 +3181,12 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont Assert(false); } - deparseExpr(str, a_expr->rexpr); + deparseExpr(str, a_expr->rexpr, context); return; case AEXPR_SIMILAR: /* [NOT] SIMILAR - name must be "~" or "!~" */ Assert(list_length(a_expr->name) == 1); Assert(IsA(linitial(a_expr->name), String)); - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); appendStringInfoChar(str, ' '); name = ((union ValUnion *) linitial(a_expr->name))->sval.sval; @@ -3203,11 +3204,11 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont Assert(strcmp(strVal(lsecond(n->funcname)), "similar_to_escape") == 0); Assert(list_length(n->args) == 1 || list_length(n->args) == 2); - deparseExpr(str, linitial(n->args)); + deparseExpr(str, linitial(n->args), context); if (list_length(n->args) == 2) { appendStringInfoString(str, " ESCAPE "); - deparseExpr(str, lsecond(n->args)); + deparseExpr(str, lsecond(n->args), context); } return; @@ -3219,13 +3220,13 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont Assert(IsA(linitial(a_expr->name), String)); Assert(IsA(a_expr->rexpr, List)); - deparseExpr(str, a_expr->lexpr); + deparseExpr(str, a_expr->lexpr, context); appendStringInfoChar(str, ' '); appendStringInfoString(str, strVal(linitial(a_expr->name))); appendStringInfoChar(str, ' '); foreach(lc, castNode(List, a_expr->rexpr)) { - deparseExpr(str, lfirst(lc)); + deparseExpr(str, lfirst(lc), context); if (lnext(castNode(List, a_expr->rexpr), lc)) appendStringInfoString(str, " AND "); } @@ -3247,7 +3248,7 @@ static void deparseBoolExpr(StringInfo str, BoolExpr *bool_expr) if (need_parens) appendStringInfoChar(str, '('); - deparseExpr(str, lfirst(lc)); + deparseExpr(str, lfirst(lc), DEPARSE_NODE_CONTEXT_A_EXPR); if (need_parens) appendStringInfoChar(str, ')'); @@ -3265,7 +3266,7 @@ static void deparseBoolExpr(StringInfo str, BoolExpr *bool_expr) if (need_parens) appendStringInfoChar(str, '('); - deparseExpr(str, lfirst(lc)); + deparseExpr(str, lfirst(lc), DEPARSE_NODE_CONTEXT_A_EXPR); if (need_parens) appendStringInfoChar(str, ')'); @@ -3280,7 +3281,7 @@ static void deparseBoolExpr(StringInfo str, BoolExpr *bool_expr) appendStringInfoString(str, "NOT "); if (need_parens) appendStringInfoChar(str, '('); - deparseExpr(str, linitial(bool_expr->args)); + deparseExpr(str, linitial(bool_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR); if (need_parens) appendStringInfoChar(str, ')'); return; @@ -3300,7 +3301,7 @@ static void deparseCollateClause(StringInfo str, CollateClause* collate_clause) bool need_parens = IsA(collate_clause->arg, A_Expr); if (need_parens) appendStringInfoChar(str, '('); - deparseExpr(str, collate_clause->arg); + deparseExpr(str, collate_clause->arg, DEPARSE_NODE_CONTEXT_A_EXPR); if (need_parens) appendStringInfoChar(str, ')'); appendStringInfoChar(str, ' '); @@ -3312,7 +3313,7 @@ static void deparseCollateClause(StringInfo str, CollateClause* collate_clause) // "sortby" in gram.y static void deparseSortBy(StringInfo str, SortBy* sort_by) { - deparseExpr(str, sort_by->node); + deparseExpr(str, sort_by->node, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); switch (sort_by->sortby_dir) @@ -3483,7 +3484,7 @@ static void deparseJoinExpr(StringInfo str, JoinExpr *join_expr) if (join_expr->quals != NULL) { appendStringInfoString(str, "ON "); - deparseExpr(str, join_expr->quals); + deparseExpr(str, join_expr->quals, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); } @@ -3713,7 +3714,7 @@ static void deparseTypeCast(StringInfo str, TypeCast *type_cast, DeparseNodeCont if (IsA(type_cast->arg, A_Expr) || context == DEPARSE_NODE_CONTEXT_FUNC_EXPR) { appendStringInfoString(str, "CAST("); - deparseExpr(str, type_cast->arg); + deparseExpr(str, type_cast->arg, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " AS "); deparseTypeName(str, type_cast->typeName); appendStringInfoChar(str, ')'); @@ -3780,7 +3781,7 @@ static void deparseTypeCast(StringInfo str, TypeCast *type_cast, DeparseNodeCont if (need_parens) appendStringInfoChar(str, '('); - deparseExpr(str, type_cast->arg); + deparseExpr(str, type_cast->arg, DEPARSE_NODE_CONTEXT_NONE /* could be either a_expr or b_expr (we could pass this down, but that'd require two kinds of contexts most likely) */); if (need_parens) appendStringInfoChar(str, ')'); @@ -4009,7 +4010,7 @@ static void deparseNullTest(StringInfo str, NullTest *null_test) // argisrow is always false in raw parser output Assert(null_test->argisrow == false); - deparseExpr(str, (Node *) null_test->arg); + deparseExpr(str, (Node *) null_test->arg, DEPARSE_NODE_CONTEXT_A_EXPR); switch (null_test->nulltesttype) { case IS_NULL: @@ -4030,7 +4031,7 @@ static void deparseCaseExpr(StringInfo str, CaseExpr *case_expr) if (case_expr->arg != NULL) { - deparseExpr(str, (Node *) case_expr->arg); + deparseExpr(str, (Node *) case_expr->arg, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); } @@ -4043,7 +4044,7 @@ static void deparseCaseExpr(StringInfo str, CaseExpr *case_expr) if (case_expr->defresult != NULL) { appendStringInfoString(str, "ELSE "); - deparseExpr(str, (Node *) case_expr->defresult); + deparseExpr(str, (Node *) case_expr->defresult, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); } @@ -4054,9 +4055,9 @@ static void deparseCaseExpr(StringInfo str, CaseExpr *case_expr) static void deparseCaseWhen(StringInfo str, CaseWhen *case_when) { appendStringInfoString(str, "WHEN "); - deparseExpr(str, (Node *) case_when->expr); + deparseExpr(str, (Node *) case_when->expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " THEN "); - deparseExpr(str, (Node *) case_when->result); + deparseExpr(str, (Node *) case_when->result, DEPARSE_NODE_CONTEXT_A_EXPR); } static void deparseAIndirection(StringInfo str, A_Indirection *a_indirection) @@ -4074,7 +4075,7 @@ static void deparseAIndirection(StringInfo str, A_Indirection *a_indirection) if (need_parens) appendStringInfoChar(str, '('); - deparseExpr(str, a_indirection->arg); + deparseExpr(str, a_indirection->arg, need_parens ? DEPARSE_NODE_CONTEXT_A_EXPR : DEPARSE_NODE_CONTEXT_NONE); if (need_parens) appendStringInfoChar(str, ')'); @@ -4086,11 +4087,11 @@ static void deparseAIndices(StringInfo str, A_Indices *a_indices) { appendStringInfoChar(str, '['); if (a_indices->lidx != NULL) - deparseExpr(str, a_indices->lidx); + deparseExpr(str, a_indices->lidx, DEPARSE_NODE_CONTEXT_A_EXPR); if (a_indices->is_slice) appendStringInfoChar(str, ':'); if (a_indices->uidx != NULL) - deparseExpr(str, a_indices->uidx); + deparseExpr(str, a_indices->uidx, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ']'); } @@ -4123,7 +4124,7 @@ static void deparseBooleanTest(StringInfo str, BooleanTest *boolean_test) if (need_parens) appendStringInfoChar(str, '('); - deparseExpr(str, (Node *) boolean_test->arg); + deparseExpr(str, (Node *) boolean_test->arg, DEPARSE_NODE_CONTEXT_A_EXPR); if (need_parens) appendStringInfoChar(str, ')'); @@ -4180,7 +4181,7 @@ static void deparseColumnDef(StringInfo str, ColumnDef *column_def) if (column_def->raw_default != NULL) { appendStringInfoString(str, "USING "); - deparseExpr(str, column_def->raw_default); + deparseExpr(str, column_def->raw_default, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); } @@ -4394,7 +4395,7 @@ static void deparseMergeStmt(StringInfo str, MergeStmt *merge_stmt) appendStringInfoChar(str, ' '); appendStringInfoString(str, "ON "); - deparseExpr(str, merge_stmt->joinCondition); + deparseExpr(str, merge_stmt->joinCondition, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); ListCell *lc; @@ -4420,7 +4421,7 @@ static void deparseMergeStmt(StringInfo str, MergeStmt *merge_stmt) if (clause->condition) { appendStringInfoString(str, "AND "); - deparseExpr(str, clause->condition); + deparseExpr(str, clause->condition, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); } @@ -4838,12 +4839,12 @@ static void deparseConstraint(StringInfo str, Constraint *constraint) case CONSTR_GENERATED: Assert(constraint->generated_when == ATTRIBUTE_IDENTITY_ALWAYS); appendStringInfoString(str, "GENERATED ALWAYS AS ("); - deparseExpr(str, constraint->raw_expr); + deparseExpr(str, constraint->raw_expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") STORED "); break; case CONSTR_CHECK: appendStringInfoString(str, "CHECK ("); - deparseExpr(str, constraint->raw_expr); + deparseExpr(str, constraint->raw_expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); break; case CONSTR_PRIMARY: @@ -4877,7 +4878,7 @@ static void deparseConstraint(StringInfo str, Constraint *constraint) if (constraint->where_clause != NULL) { appendStringInfoString(str, "WHERE ("); - deparseExpr(str, constraint->where_clause); + deparseExpr(str, constraint->where_clause, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } break; @@ -5053,7 +5054,7 @@ static void deparseConstraint(StringInfo str, Constraint *constraint) static void deparseReturnStmt(StringInfo str, ReturnStmt *return_stmt) { appendStringInfoString(str, "RETURN "); - deparseExpr(str, return_stmt->returnval); + deparseExpr(str, return_stmt->returnval, DEPARSE_NODE_CONTEXT_A_EXPR); } static void deparseCreateFunctionStmt(StringInfo str, CreateFunctionStmt *create_function_stmt) @@ -5193,7 +5194,7 @@ static void deparseFunctionParameter(StringInfo str, FunctionParameter *function if (function_parameter->defexpr != NULL) { appendStringInfoString(str, "= "); - deparseExpr(str, function_parameter->defexpr); + deparseExpr(str, function_parameter->defexpr, DEPARSE_NODE_CONTEXT_A_EXPR); } removeTrailingSpace(str); @@ -5314,7 +5315,7 @@ static void deparsePartitionElem(StringInfo str, PartitionElem *partition_elem) else if (partition_elem->expr != NULL) { appendStringInfoChar(str, '('); - deparseExpr(str, partition_elem->expr); + deparseExpr(str, partition_elem->expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } @@ -6668,7 +6669,7 @@ static void deparseAlterTableCmd(StringInfo str, AlterTableCmd *alter_table_cmd, case AT_ColumnDefault: if (alter_table_cmd->def != NULL) { - deparseExpr(str, alter_table_cmd->def); + deparseExpr(str, alter_table_cmd->def, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); } break; @@ -6724,7 +6725,7 @@ static void deparseAlterTableCmd(StringInfo str, AlterTableCmd *alter_table_cmd, break; case AT_SetExpression: appendStringInfoString(str, "SET EXPRESSION AS ("); - deparseExpr(str, alter_table_cmd->def); + deparseExpr(str, alter_table_cmd->def, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ')'); break; default: @@ -6845,7 +6846,7 @@ static void deparseAlterDomainStmt(StringInfo str, AlterDomainStmt *alter_domain if (alter_domain_stmt->def != NULL) { appendStringInfoString(str, "SET DEFAULT "); - deparseExpr(str, alter_domain_stmt->def); + deparseExpr(str, alter_domain_stmt->def, DEPARSE_NODE_CONTEXT_A_EXPR); } else { @@ -9105,14 +9106,14 @@ static void deparseCreatePolicyStmt(StringInfo str, CreatePolicyStmt *create_pol if (create_policy_stmt->qual != NULL) { appendStringInfoString(str, "USING ("); - deparseExpr(str, create_policy_stmt->qual); + deparseExpr(str, create_policy_stmt->qual, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } if (create_policy_stmt->with_check != NULL) { appendStringInfoString(str, "WITH CHECK ("); - deparseExpr(str, create_policy_stmt->with_check); + deparseExpr(str, create_policy_stmt->with_check, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } } @@ -9136,14 +9137,14 @@ static void deparseAlterPolicyStmt(StringInfo str, AlterPolicyStmt *alter_policy if (alter_policy_stmt->qual != NULL) { appendStringInfoString(str, "USING ("); - deparseExpr(str, alter_policy_stmt->qual); + deparseExpr(str, alter_policy_stmt->qual, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } if (alter_policy_stmt->with_check != NULL) { appendStringInfoString(str, "WITH CHECK ("); - deparseExpr(str, alter_policy_stmt->with_check); + deparseExpr(str, alter_policy_stmt->with_check, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } } @@ -9251,7 +9252,7 @@ static void deparsePublicationObjectList(StringInfo str, List *pubobjects) { if (obj->pubtable->whereClause) { appendStringInfoString(str, " WHERE ("); - deparseExpr(str, obj->pubtable->whereClause); + deparseExpr(str, obj->pubtable->whereClause, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ")"); } @@ -9609,7 +9610,7 @@ static void deparseStatsElem(StringInfo str, StatsElem *stats_elem) else if (stats_elem->expr) { appendStringInfoChar(str, '('); - deparseExpr(str, stats_elem->expr); + deparseExpr(str, stats_elem->expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ')'); } } @@ -9772,7 +9773,7 @@ static void deparseRangeTableSample(StringInfo str, RangeTableSample *range_tabl if (range_table_sample->repeatable != NULL) { appendStringInfoString(str, "REPEATABLE ("); - deparseExpr(str, range_table_sample->repeatable); + deparseExpr(str, range_table_sample->repeatable, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } @@ -9897,7 +9898,7 @@ static void deparseDropSubscriptionStmt(StringInfo str, DropSubscriptionStmt *dr static void deparseCallStmt(StringInfo str, CallStmt *call_stmt) { appendStringInfoString(str, "CALL "); - deparseFuncCall(str, call_stmt->funccall); + deparseFuncCall(str, call_stmt->funccall, DEPARSE_NODE_CONTEXT_NONE); } static void deparseAlterOwnerStmt(StringInfo str, AlterOwnerStmt *alter_owner_stmt) @@ -10185,7 +10186,7 @@ static void deparseCreateTrigStmt(StringInfo str, CreateTrigStmt *create_trig_st if (create_trig_stmt->whenClause) { appendStringInfoString(str, "WHEN ("); - deparseExpr(str, create_trig_stmt->whenClause); + deparseExpr(str, create_trig_stmt->whenClause, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } @@ -10216,7 +10217,7 @@ static void deparseTriggerTransition(StringInfo str, TriggerTransition *trigger_ appendStringInfoString(str, quote_identifier(trigger_transition->name)); } -static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr) +static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr, DeparseNodeContext context) { switch (xml_expr->op) { @@ -10260,7 +10261,7 @@ static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr) default: Assert(false); } - deparseExpr(str, linitial(xml_expr->args)); + deparseExpr(str, linitial(xml_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ')'); break; case IS_XMLPI: /* XMLPI(name [, args]) */ @@ -10269,18 +10270,18 @@ static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr) if (xml_expr->args != NULL) { appendStringInfoString(str, ", "); - deparseExpr(str, linitial(xml_expr->args)); + deparseExpr(str, linitial(xml_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR); } appendStringInfoChar(str, ')'); break; case IS_XMLROOT: /* XMLROOT(xml, version, standalone) */ appendStringInfoString(str, "xmlroot("); - deparseExpr(str, linitial(xml_expr->args)); + deparseExpr(str, linitial(xml_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ", version "); if (castNode(A_Const, lsecond(xml_expr->args))->isnull) appendStringInfoString(str, "NO VALUE"); else - deparseExpr(str, lsecond(xml_expr->args)); + deparseExpr(str, lsecond(xml_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR); if (intVal(&castNode(A_Const, lthird(xml_expr->args))->val) == XML_STANDALONE_YES) appendStringInfoString(str, ", STANDALONE YES"); else if (intVal(&castNode(A_Const, lthird(xml_expr->args))->val) == XML_STANDALONE_NO) @@ -10295,7 +10296,7 @@ static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr) break; case IS_DOCUMENT: /* xmlval IS DOCUMENT */ Assert(list_length(xml_expr->args) == 1); - deparseExpr(str, linitial(xml_expr->args)); + deparseExpr(str, linitial(xml_expr->args), context); appendStringInfoString(str, " IS DOCUMENT"); break; } @@ -10319,14 +10320,14 @@ static void deparseRangeTableFuncCol(StringInfo str, RangeTableFuncCol* range_ta if (range_table_func_col->colexpr) { appendStringInfoString(str, "PATH "); - deparseExpr(str, range_table_func_col->colexpr); + deparseExpr(str, range_table_func_col->colexpr, DEPARSE_NODE_CONTEXT_NONE /* b_expr */); appendStringInfoChar(str, ' '); } if (range_table_func_col->coldefexpr) { appendStringInfoString(str, "DEFAULT "); - deparseExpr(str, range_table_func_col->coldefexpr); + deparseExpr(str, range_table_func_col->coldefexpr, DEPARSE_NODE_CONTEXT_NONE /* b_expr */); appendStringInfoChar(str, ' '); } @@ -10354,11 +10355,11 @@ static void deparseRangeTableFunc(StringInfo str, RangeTableFunc* range_table_fu } appendStringInfoChar(str, '('); - deparseExpr(str, range_table_func->rowexpr); + deparseExpr(str, range_table_func->rowexpr, DEPARSE_NODE_CONTEXT_NONE /* c_expr */); appendStringInfoChar(str, ')'); appendStringInfoString(str, " PASSING "); - deparseExpr(str, range_table_func->docexpr); + deparseExpr(str, range_table_func->docexpr, DEPARSE_NODE_CONTEXT_NONE /* c_expr */); appendStringInfoString(str, " COLUMNS "); foreach(lc, range_table_func->columns) @@ -10393,7 +10394,7 @@ static void deparseXmlSerialize(StringInfo str, XmlSerialize *xml_serialize) default: Assert(false); } - deparseExpr(str, xml_serialize->expr); + deparseExpr(str, xml_serialize->expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, " AS "); deparseTypeName(str, xml_serialize->typeName); @@ -10430,7 +10431,7 @@ static void deparseJsonFormat(StringInfo str, JsonFormat *json_format) static void deparseJsonIsPredicate(StringInfo str, JsonIsPredicate *j) { - deparseExpr(str, j->expr); + deparseExpr(str, j->expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); deparseJsonFormat(str, castNode(JsonFormat, j->format)); @@ -10462,7 +10463,7 @@ static void deparseJsonIsPredicate(StringInfo str, JsonIsPredicate *j) // "json_value_expr" in gram.y static void deparseJsonValueExpr(StringInfo str, JsonValueExpr *json_value_expr) { - deparseExpr(str, (Node *) json_value_expr->raw_expr); + deparseExpr(str, (Node *) json_value_expr->raw_expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoChar(str, ' '); deparseJsonFormat(str, json_value_expr->format); } @@ -10484,7 +10485,7 @@ static void deparseJsonValueExprList(StringInfo str, List *exprs) // "json_name_and_value" in gram.y static void deparseJsonKeyValue(StringInfo str, JsonKeyValue *json_key_value) { - deparseExpr(str, (Node *) json_key_value->key); + deparseExpr(str, (Node *) json_key_value->key, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ": "); deparseJsonValueExpr(str, json_key_value->value); } @@ -10538,7 +10539,7 @@ static void deparseJsonObjectAgg(StringInfo str, JsonObjectAgg *json_object_agg) if (json_object_agg->constructor->agg_filter) { appendStringInfoString(str, "FILTER (WHERE "); - deparseExpr(str, json_object_agg->constructor->agg_filter); + deparseExpr(str, json_object_agg->constructor->agg_filter, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } @@ -10575,7 +10576,7 @@ static void deparseJsonArrayAgg(StringInfo str, JsonArrayAgg *json_array_agg) if (json_array_agg->constructor->agg_filter) { appendStringInfoString(str, "FILTER (WHERE "); - deparseExpr(str, json_array_agg->constructor->agg_filter); + deparseExpr(str, json_array_agg->constructor->agg_filter, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ") "); } @@ -10650,7 +10651,7 @@ static void deparseJsonParseExpr(StringInfo str, JsonParseExpr *json_parse_expr) static void deparseJsonScalarExpr(StringInfo str, JsonScalarExpr *json_scalar_expr) { appendStringInfoString(str, "JSON_SCALAR("); - deparseExpr(str, (Node*) json_scalar_expr->expr); + deparseExpr(str, (Node*) json_scalar_expr->expr, DEPARSE_NODE_CONTEXT_A_EXPR); appendStringInfoString(str, ")"); } @@ -10721,7 +10722,7 @@ static void deparseJsonFuncExpr(StringInfo str, JsonFuncExpr *json_func_expr) deparseJsonValueExpr(str, json_func_expr->context_item); appendStringInfoString(str, ", "); - deparseExpr(str, json_func_expr->pathspec); + deparseExpr(str, json_func_expr->pathspec, DEPARSE_NODE_CONTEXT_A_EXPR); if (json_func_expr->passing) appendStringInfoString(str, " PASSING "); @@ -10805,7 +10806,7 @@ static void deparseJsonBehavior(StringInfo str, JsonBehavior *json_behavior) break; case JSON_BEHAVIOR_DEFAULT: appendStringInfoString(str, "DEFAULT "); - deparseExpr(str, (Node*) json_behavior->expr); + deparseExpr(str, (Node*) json_behavior->expr, DEPARSE_NODE_CONTEXT_A_EXPR); break; case JSON_BEHAVIOR_UNKNOWN: appendStringInfoString(str, "UNKNOWN");