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.b0feda79fdhas 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 in6185c9737c. Author: Chaitanya Choudhary <chaitanyyachoudhary@gmail.com> Author: Shihao Zhong <zhong950419@gmail.com> Discussion: https://postgr.es/m/19693-2ecd2b52c838b3e5@postgresql.org Backpatch-through: 17
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/19/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/19/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.