pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Avoid double transformation of json_array()'s subquery. 3+ messages / 1 participants [nested] [flat]
* pgsql: Avoid double transformation of json_array()'s subquery. @ 2025-04-05 16:14 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2025-04-05 16:14 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid double transformation of json_array()'s subquery. transformJsonArrayQueryConstructor() applied transformStmt() to the same subquery tree twice. While this causes no issue in many cases, there are some where it causes a coredump, thanks to the parser's habit of scribbling on its input. Fix by making a copy before the first transformation (compare 0f43083d1). This is quite brute-force, but then so is the whole business of transforming the input twice. Per discussion in the bug thread, this implementation of json_array() parsing should be replaced completely. But that will take some work and will surely not be back-patchable, so for the moment let's take the easy way out. Oversight in 7081ac46a. Back-patch to v16 where that came in. Bug: #18877 Reported-by: Yu Liang <luy70@psu.edu> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/18877-c3c3ad75845833bb@postgresql.org Backpatch-through: 16 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/e33f2335a9d9754ccf3bf7181085cfa581ee03c3 Modified Files -------------- src/backend/parser/parse_expr.c | 2 +- src/test/regress/expected/sqljson.out | 6 ++++++ src/test/regress/sql/sqljson.sql | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Avoid double transformation of json_array()'s subquery. @ 2025-04-05 16:14 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2025-04-05 16:14 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid double transformation of json_array()'s subquery. transformJsonArrayQueryConstructor() applied transformStmt() to the same subquery tree twice. While this causes no issue in many cases, there are some where it causes a coredump, thanks to the parser's habit of scribbling on its input. Fix by making a copy before the first transformation (compare 0f43083d1). This is quite brute-force, but then so is the whole business of transforming the input twice. Per discussion in the bug thread, this implementation of json_array() parsing should be replaced completely. But that will take some work and will surely not be back-patchable, so for the moment let's take the easy way out. Oversight in 7081ac46a. Back-patch to v16 where that came in. Bug: #18877 Reported-by: Yu Liang <luy70@psu.edu> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/18877-c3c3ad75845833bb@postgresql.org Backpatch-through: 16 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/717e8a1e5256fd01ed5b4cd60f2aac97dceb00bd Modified Files -------------- src/backend/parser/parse_expr.c | 2 +- src/test/regress/expected/sqljson.out | 6 ++++++ src/test/regress/sql/sqljson.sql | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Avoid double transformation of json_array()'s subquery. @ 2025-04-05 16:14 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2025-04-05 16:14 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid double transformation of json_array()'s subquery. transformJsonArrayQueryConstructor() applied transformStmt() to the same subquery tree twice. While this causes no issue in many cases, there are some where it causes a coredump, thanks to the parser's habit of scribbling on its input. Fix by making a copy before the first transformation (compare 0f43083d1). This is quite brute-force, but then so is the whole business of transforming the input twice. Per discussion in the bug thread, this implementation of json_array() parsing should be replaced completely. But that will take some work and will surely not be back-patchable, so for the moment let's take the easy way out. Oversight in 7081ac46a. Back-patch to v16 where that came in. Bug: #18877 Reported-by: Yu Liang <luy70@psu.edu> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/18877-c3c3ad75845833bb@postgresql.org Backpatch-through: 16 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ca54f9b706f66f8f7191551aec8eac8b86b0fb9b Modified Files -------------- src/backend/parser/parse_expr.c | 2 +- src/test/regress/expected/sqljson.out | 6 ++++++ src/test/regress/sql/sqljson.sql | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2025-04-05 16:14 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-04-05 16:14 pgsql: Avoid double transformation of json_array()'s subquery. Tom Lane <tgl@sss.pgh.pa.us> 2025-04-05 16:14 pgsql: Avoid double transformation of json_array()'s subquery. Tom Lane <tgl@sss.pgh.pa.us> 2025-04-05 16:14 pgsql: Avoid double transformation of json_array()'s subquery. Tom Lane <tgl@sss.pgh.pa.us>
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