Avoid double transformation of json_array()'s subquery.
Tom Lane <tgl@sss.pgh.pa.us>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/parser/parse_expr.c | modified | +1 −1 |
| src/test/regress/expected/sqljson.out | modified | +6 −0 |
| src/test/regress/sql/sqljson.sql | modified | +2 −0 |
Discussion
- BUG #18877: PostgreSQL triggers assertion failure 9 messages · 2025-04-04 → 2025-04-05