From d037cc2af14ae59f0d1d0cfae826a2c7b0aa1a37 Mon Sep 17 00:00:00 2001 From: Dean Rasheed Date: Sun, 12 Jan 2025 13:36:44 +0000 Subject: Fix JsonExpr deparsing to quote variable names in the PASSING clause. When deparsing a JsonExpr, variable names in the PASSING clause were not quoted. However, since they are parsed as ColLabel tokens, some variable names require double quotes to ensure that they are properly interpreted. Fix by using quote_identifier() in the deparsing code. This oversight was limited to the SQL/JSON query functions JSON_EXISTS(), JSON_QUERY(), and JSON_VALUE(). Back-patch to v17, where these functions were added. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/CAEZATCXTpAS%3DncfLNTZ7YS6O5puHeLg_SUYAit%2Bcs7wsrd9Msg%40mail.gmail.com --- src/backend/utils/adt/ruleutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/backend/utils/adt/ruleutils.c') diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index c725e80ed03..7d6d9141a94 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -10250,7 +10250,7 @@ get_rule_expr(Node *node, deparse_context *context, get_rule_expr((Node *) lfirst(lc2), context, showimplicit); appendStringInfo(buf, " AS %s", - ((String *) lfirst_node(String, lc1))->sval); + quote_identifier(lfirst_node(String, lc1)->sval)); } } -- cgit v1.2.3