pgsql: Fix JsonExpr deparsing to quote variable names in the PASSING cl

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix JsonExpr deparsing to quote variable names in the PASSING cl
Date: 2025-01-12 13:39:38
Message-ID: E1tWyBl-0019Gg-QV@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a93e2a1e25a6d5410abb1446637c4d9a4f24e35d

Modified Files
--------------
src/backend/utils/adt/ruleutils.c | 2 +-
src/test/regress/expected/sqljson_queryfuncs.out | 20 +++++++++++++++++---
src/test/regress/sql/sqljson_queryfuncs.sql | 5 ++++-
3 files changed, 22 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-01-12 19:07:21 Re: pgsql: Consolidate docs for vacuum-related GUCs in new subsection
Previous Message Dean Rasheed 2025-01-12 13:05:51 pgsql: Fix XMLTABLE() deparsing to quote namespace names if necessary.