Fix JsonExpr deparsing to quote variable names in the PASSING clause.
authorDean Rasheed <dean.a.rasheed@gmail.com>
Sun, 12 Jan 2025 13:36:44 +0000 (13:36 +0000)
committerDean Rasheed <dean.a.rasheed@gmail.com>
Sun, 12 Jan 2025 13:36:44 +0000 (13:36 +0000)
commitd037cc2af14ae59f0d1d0cfae826a2c7b0aa1a37
treeb5003da6e85b51adc5ea11693e2ab9ec6125bb6e
parent61b12135f5b71df3721e8f13eab812b38c0de11f
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
src/test/regress/expected/sqljson_queryfuncs.out
src/test/regress/sql/sqljson_queryfuncs.sql