agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Fix PASSING of toasted text values in JSON query functions 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix PASSING of toasted text values in JSON query functions @ 2026-09-19 11:16 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 4+ messages in thread From: Michael Paquier @ 2026-09-19 11:16 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix PASSING of toasted text values in JSON query functions The PASSING arguments of JSON_EXISTS(), JSON_QUERY(), JSON_VALUE() and JSON_TABLE() are evaluated by plain expression steps and given to the jsonpath executor as-is. When dealing with a varlena, JsonItemFromDatum() was building a jbvString directly the contents of a varlena. For a varatt_external (varatt_external[oid/oid8] on HEAD), this ignored that the contents of the varlena need to be detoasted, leading to incorrect contents returned. Let's detoast the value, like the jsonb and json cases. b0feda79fdf0 has fixed the same issue for subscript values in jsonb. Note that the results of DatumGetTextPP() are allocated in the memory context used for the evaluation of the expression, which is reset once per row. Oversight in 6185c9737cf4. Author: Chaitanya Choudhary <chaitanyyachoudhary@gmail.com> Author: Shihao Zhong <zhong950419@gmail.com> Discussion: https://postgr.es/m/19693-2ecd2b52c838b3e5@postgresql.org Backpatch-through: 17 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ab713cdcdbfd05b72a6959ff17aad56cf075ae31 Modified Files -------------- src/backend/utils/adt/jsonpath_exec.c | 12 +++++++---- src/test/regress/expected/sqljson_queryfuncs.out | 26 ++++++++++++++++++++++++ src/test/regress/sql/sqljson_queryfuncs.sql | 16 +++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix PASSING of toasted text values in JSON query functions @ 2026-09-19 11:16 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 4+ messages in thread From: Michael Paquier @ 2026-09-19 11:16 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix PASSING of toasted text values in JSON query functions The PASSING arguments of JSON_EXISTS(), JSON_QUERY(), JSON_VALUE() and JSON_TABLE() are evaluated by plain expression steps and given to the jsonpath executor as-is. When dealing with a varlena, JsonItemFromDatum() was building a jbvString directly the contents of a varlena. For a varatt_external (varatt_external[oid/oid8] on HEAD), this ignored that the contents of the varlena need to be detoasted, leading to incorrect contents returned. Let's detoast the value, like the jsonb and json cases. b0feda79fdf0 has fixed the same issue for subscript values in jsonb. Note that the results of DatumGetTextPP() are allocated in the memory context used for the evaluation of the expression, which is reset once per row. Oversight in 6185c9737cf4. Author: Chaitanya Choudhary <chaitanyyachoudhary@gmail.com> Author: Shihao Zhong <zhong950419@gmail.com> Discussion: https://postgr.es/m/19693-2ecd2b52c838b3e5@postgresql.org Backpatch-through: 17 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fdb88a51cda0ec0e09b986ec68bcea3935424794 Modified Files -------------- src/backend/utils/adt/jsonpath_exec.c | 12 +++++++---- src/test/regress/expected/sqljson_queryfuncs.out | 26 ++++++++++++++++++++++++ src/test/regress/sql/sqljson_queryfuncs.sql | 16 +++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix PASSING of toasted text values in JSON query functions @ 2026-09-19 11:16 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 4+ messages in thread From: Michael Paquier @ 2026-09-19 11:16 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix PASSING of toasted text values in JSON query functions The PASSING arguments of JSON_EXISTS(), JSON_QUERY(), JSON_VALUE() and JSON_TABLE() are evaluated by plain expression steps and given to the jsonpath executor as-is. When dealing with a varlena, JsonItemFromDatum() was building a jbvString directly the contents of a varlena. For a varatt_external (varatt_external[oid/oid8] on HEAD), this ignored that the contents of the varlena need to be detoasted, leading to incorrect contents returned. Let's detoast the value, like the jsonb and json cases. b0feda79fdf0 has fixed the same issue for subscript values in jsonb. Note that the results of DatumGetTextPP() are allocated in the memory context used for the evaluation of the expression, which is reset once per row. Oversight in 6185c9737cf4. Author: Chaitanya Choudhary <chaitanyyachoudhary@gmail.com> Author: Shihao Zhong <zhong950419@gmail.com> Discussion: https://postgr.es/m/19693-2ecd2b52c838b3e5@postgresql.org Backpatch-through: 17 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b8736db6e09137c36b19222ee73e81a28dc1690c Modified Files -------------- src/backend/utils/adt/jsonpath_exec.c | 12 +++++++---- src/test/regress/expected/sqljson_queryfuncs.out | 26 ++++++++++++++++++++++++ src/test/regress/sql/sqljson_queryfuncs.sql | 16 +++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix PASSING of toasted text values in JSON query functions @ 2026-09-19 11:16 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 4+ messages in thread From: Michael Paquier @ 2026-09-19 11:16 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix PASSING of toasted text values in JSON query functions The PASSING arguments of JSON_EXISTS(), JSON_QUERY(), JSON_VALUE() and JSON_TABLE() are evaluated by plain expression steps and given to the jsonpath executor as-is. When dealing with a varlena, JsonItemFromDatum() was building a jbvString directly the contents of a varlena. For a varatt_external (varatt_external[oid/oid8] on HEAD), this ignored that the contents of the varlena need to be detoasted, leading to incorrect contents returned. Let's detoast the value, like the jsonb and json cases. b0feda79fdf0 has fixed the same issue for subscript values in jsonb. Note that the results of DatumGetTextPP() are allocated in the memory context used for the evaluation of the expression, which is reset once per row. Oversight in 6185c9737cf4. Author: Chaitanya Choudhary <chaitanyyachoudhary@gmail.com> Author: Shihao Zhong <zhong950419@gmail.com> Discussion: https://postgr.es/m/19693-2ecd2b52c838b3e5@postgresql.org Backpatch-through: 17 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8bccf0159409b9ce46171c5182772c0a27aa8bad Modified Files -------------- src/backend/utils/adt/jsonpath_exec.c | 12 +++++++---- src/test/regress/expected/sqljson_queryfuncs.out | 26 ++++++++++++++++++++++++ src/test/regress/sql/sqljson_queryfuncs.sql | 16 +++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-09-19 11:16 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-09-19 11:16 pgsql: Fix PASSING of toasted text values in JSON query functions Michael Paquier <michael@paquier.xyz> 2026-09-19 11:16 pgsql: Fix PASSING of toasted text values in JSON query functions Michael Paquier <michael@paquier.xyz> 2026-09-19 11:16 pgsql: Fix PASSING of toasted text values in JSON query functions Michael Paquier <michael@paquier.xyz> 2026-09-19 11:16 pgsql: Fix PASSING of toasted text values in JSON query functions Michael Paquier <michael@paquier.xyz>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox