| From: | Amit Langote <amitlan(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: JSON_TABLE: fix missing collation assignments |
| Date: | 2026-11-06 08:31:43 |
| Message-ID: | E1xPFMN-00000000RWd-1WNi@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
JSON_TABLE: fix missing collation assignments
transformJsonTable() transforms the context item and the PASSING
arguments into the JsonExpr stored in TableFunc.docexpr, and copies the
transformed PASSING arguments into TableFunc.passingvalexprs, but never
ran assign_expr_collations() over them. That is needed here because
assign_query_collations() doesn't look into the range table, which is
why transformRangeTableFunc() does it for XMLTABLE, as does
transformJsonTableColumn() for JSON_TABLE's own column expressions.
As a result, expressions in there were left without collations. A text
comparison failed with "could not determine which collation to use for
string comparison", even with an explicit COLLATE clause, and a row
comparison was left with an empty inputcollids list, which made the
executor compare zero columns and return the result for equal rows (so
ROW(1, 2) < ROW(3, 4) yielded false), or trip an assertion in
ExecInitExprRec() in assert-enabled builds.
Fix by calling assign_expr_collations() on the transformed JsonExpr,
before the PASSING arguments are copied out of it.
Oversight in commit de3600452b6, so back-patch to 17.
Bug: #19768
Reported-by: Venu Kummari <venu2805k(at)gmail(dot)com>
Author: Venu Kummari <venu2805k(at)gmail(dot)com>
Discussion: https://postgr.es/m/19768-3633daa830be95db@postgresql.org
Backpatch-through: 17
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/c7656ac9e652534d2ec7603bfe0947eec6c7fc22
Modified Files
--------------
src/backend/parser/parse_jsontable.c | 8 +++++++
src/test/regress/expected/sqljson_jsontable.out | 30 +++++++++++++++++++++++++
src/test/regress/sql/sqljson_jsontable.sql | 11 +++++++++
3 files changed, 49 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-11-06 08:31:57 | pgsql: JSON_TABLE: fix missing collation assignments |
| Previous Message | Amit Langote | 2026-11-06 08:31:29 | pgsql: JSON_TABLE: fix missing collation assignments |