pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: JSON_TABLE: fix missing collation assignments 4+ messages / 1 participants [nested] [flat]
* pgsql: JSON_TABLE: fix missing collation assignments @ 2026-11-06 08:31 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Amit Langote @ 2026-11-06 08:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Venu Kummari <venu2805k@gmail.com> Discussion: https://postgr.es/m/19768-3633daa830be95db@postgresql.org Backpatch-through: 17 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/03550d3cfb941af2cc5312d8b8efcf90b8d8dbec 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(+) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: JSON_TABLE: fix missing collation assignments @ 2026-11-06 08:31 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Amit Langote @ 2026-11-06 08:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Venu Kummari <venu2805k@gmail.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(+) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: JSON_TABLE: fix missing collation assignments @ 2026-11-06 08:31 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Amit Langote @ 2026-11-06 08:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Venu Kummari <venu2805k@gmail.com> Discussion: https://postgr.es/m/19768-3633daa830be95db@postgresql.org Backpatch-through: 17 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3d72e63b825afa64848fd057ea937f89ec61d521 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(+) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: JSON_TABLE: fix missing collation assignments @ 2026-11-06 08:32 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Amit Langote @ 2026-11-06 08:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Venu Kummari <venu2805k@gmail.com> Discussion: https://postgr.es/m/19768-3633daa830be95db@postgresql.org Backpatch-through: 17 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/e405a46c45bae070364ed143fb9d5a631422e5e4 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(+) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-11-06 08:32 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-06 08:31 pgsql: JSON_TABLE: fix missing collation assignments Amit Langote <amitlan@postgresql.org> 2026-11-06 08:31 pgsql: JSON_TABLE: fix missing collation assignments Amit Langote <amitlan@postgresql.org> 2026-11-06 08:31 pgsql: JSON_TABLE: fix missing collation assignments Amit Langote <amitlan@postgresql.org> 2026-11-06 08:32 pgsql: JSON_TABLE: fix missing collation assignments Amit Langote <amitlan@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox