pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: SQL/JSON: Fix PASSING of string types other than text and varcha
4+ messages / 1 participants
[nested] [flat]

* pgsql: SQL/JSON: Fix PASSING of string types other than text and varcha
@ 2026-11-11 06:05 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Amit Langote @ 2026-11-11 06:05 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Fix PASSING of string types other than text and varchar

For PASSING arguments, transformJsonValueExpr() passes values of any
type of the string category to the jsonpath executor as they are,
without converting them to jsonb.  However, JsonItemFromDatum() only
handled text and varchar among those, so passing a char(n) or name
value (such as current_user), or a value of a domain over text, failed
at run time:

  ERROR:  could not convert value of type character to jsonpath

Fix by making JsonItemFromDatum() handle those types too.  bpchar is
handled like text, keeping its padding as to_jsonb() does, and name
directly.  Any other type of the string category, including domains
over string types and types provided by extensions, is converted
through its output function, again as to_jsonb() does.

Doing this in the executor rather than coercing the argument in the
parser leaves parse trees unchanged, so that existing views and rules
using such PASSING arguments start working too.

Oversight in commit 6185c9737cf, so back-patch to 17.

Reported-by: Ilya Staroverov <i.staroverov@ftdata.ru>
Reported-by: chunling qin <303677365@qq.com>
Author: Ilya Staroverov <i.staroverov@ftdata.ru>
Discussion: https://postgr.es/m/4601EAD4-F3E7-4182-9E49-5FFD3DA8CC8E@localhost.localdomain
Discussion: https://postgr.es/m/19813-6a460679ae295ed6@postgresql.org
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5b0e267f3528b16ecee0a3b4e4e2c34f8343290e

Modified Files
--------------
src/backend/utils/adt/jsonpath_exec.c            | 50 ++++++++++++++++--
src/test/regress/expected/sqljson_queryfuncs.out | 64 ++++++++++++++++++++++++
src/test/regress/sql/sqljson_queryfuncs.sql      | 25 +++++++++
3 files changed, 135 insertions(+), 4 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: SQL/JSON: Fix PASSING of string types other than text and varcha
@ 2026-11-11 06:05 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Amit Langote @ 2026-11-11 06:05 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Fix PASSING of string types other than text and varchar

For PASSING arguments, transformJsonValueExpr() passes values of any
type of the string category to the jsonpath executor as they are,
without converting them to jsonb.  However, JsonItemFromDatum() only
handled text and varchar among those, so passing a char(n) or name
value (such as current_user), or a value of a domain over text, failed
at run time:

  ERROR:  could not convert value of type character to jsonpath

Fix by making JsonItemFromDatum() handle those types too.  bpchar is
handled like text, keeping its padding as to_jsonb() does, and name
directly.  Any other type of the string category, including domains
over string types and types provided by extensions, is converted
through its output function, again as to_jsonb() does.

Doing this in the executor rather than coercing the argument in the
parser leaves parse trees unchanged, so that existing views and rules
using such PASSING arguments start working too.

Oversight in commit 6185c9737cf, so back-patch to 17.

Reported-by: Ilya Staroverov <i.staroverov@ftdata.ru>
Reported-by: chunling qin <303677365@qq.com>
Author: Ilya Staroverov <i.staroverov@ftdata.ru>
Discussion: https://postgr.es/m/4601EAD4-F3E7-4182-9E49-5FFD3DA8CC8E@localhost.localdomain
Discussion: https://postgr.es/m/19813-6a460679ae295ed6@postgresql.org
Backpatch-through: 17

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/23f3c0bb5c206b3fe8c0ee20140c6de86161186e

Modified Files
--------------
src/backend/utils/adt/jsonpath_exec.c            | 51 ++++++++++++++++--
src/test/regress/expected/sqljson_queryfuncs.out | 66 ++++++++++++++++++++++++
src/test/regress/sql/sqljson_queryfuncs.sql      | 25 +++++++++
3 files changed, 138 insertions(+), 4 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: SQL/JSON: Fix PASSING of string types other than text and varcha
@ 2026-11-11 06:05 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Amit Langote @ 2026-11-11 06:05 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Fix PASSING of string types other than text and varchar

For PASSING arguments, transformJsonValueExpr() passes values of any
type of the string category to the jsonpath executor as they are,
without converting them to jsonb.  However, JsonItemFromDatum() only
handled text and varchar among those, so passing a char(n) or name
value (such as current_user), or a value of a domain over text, failed
at run time:

  ERROR:  could not convert value of type character to jsonpath

Fix by making JsonItemFromDatum() handle those types too.  bpchar is
handled like text, keeping its padding as to_jsonb() does, and name
directly.  Any other type of the string category, including domains
over string types and types provided by extensions, is converted
through its output function, again as to_jsonb() does.

Doing this in the executor rather than coercing the argument in the
parser leaves parse trees unchanged, so that existing views and rules
using such PASSING arguments start working too.

Oversight in commit 6185c9737cf, so back-patch to 17.

Reported-by: Ilya Staroverov <i.staroverov@ftdata.ru>
Reported-by: chunling qin <303677365@qq.com>
Author: Ilya Staroverov <i.staroverov@ftdata.ru>
Discussion: https://postgr.es/m/4601EAD4-F3E7-4182-9E49-5FFD3DA8CC8E@localhost.localdomain
Discussion: https://postgr.es/m/19813-6a460679ae295ed6@postgresql.org
Backpatch-through: 17

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f4a302985d9859f35bced4cd2709b4a9fcf881d3

Modified Files
--------------
src/backend/utils/adt/jsonpath_exec.c            | 51 ++++++++++++++++--
src/test/regress/expected/sqljson_queryfuncs.out | 66 ++++++++++++++++++++++++
src/test/regress/sql/sqljson_queryfuncs.sql      | 25 +++++++++
3 files changed, 138 insertions(+), 4 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: SQL/JSON: Fix PASSING of string types other than text and varcha
@ 2026-11-11 06:06 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Amit Langote @ 2026-11-11 06:06 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Fix PASSING of string types other than text and varchar

For PASSING arguments, transformJsonValueExpr() passes values of any
type of the string category to the jsonpath executor as they are,
without converting them to jsonb.  However, JsonItemFromDatum() only
handled text and varchar among those, so passing a char(n) or name
value (such as current_user), or a value of a domain over text, failed
at run time:

  ERROR:  could not convert value of type character to jsonpath

Fix by making JsonItemFromDatum() handle those types too.  bpchar is
handled like text, keeping its padding as to_jsonb() does, and name
directly.  Any other type of the string category, including domains
over string types and types provided by extensions, is converted
through its output function, again as to_jsonb() does.

Doing this in the executor rather than coercing the argument in the
parser leaves parse trees unchanged, so that existing views and rules
using such PASSING arguments start working too.

Oversight in commit 6185c9737cf, so back-patch to 17.

Reported-by: Ilya Staroverov <i.staroverov@ftdata.ru>
Reported-by: chunling qin <303677365@qq.com>
Author: Ilya Staroverov <i.staroverov@ftdata.ru>
Discussion: https://postgr.es/m/4601EAD4-F3E7-4182-9E49-5FFD3DA8CC8E@localhost.localdomain
Discussion: https://postgr.es/m/19813-6a460679ae295ed6@postgresql.org
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c5daeb1e0f5adfbc19ed621bb97ce2d68c8455bf

Modified Files
--------------
src/backend/utils/adt/jsonpath_exec.c            | 51 ++++++++++++++++--
src/test/regress/expected/sqljson_queryfuncs.out | 66 ++++++++++++++++++++++++
src/test/regress/sql/sqljson_queryfuncs.sql      | 25 +++++++++
3 files changed, 138 insertions(+), 4 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-11-11 06:06 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 06:05 pgsql: SQL/JSON: Fix PASSING of string types other than text and varcha Amit Langote <amitlan@postgresql.org>
2026-11-11 06:05 pgsql: SQL/JSON: Fix PASSING of string types other than text and varcha Amit Langote <amitlan@postgresql.org>
2026-11-11 06:05 pgsql: SQL/JSON: Fix PASSING of string types other than text and varcha Amit Langote <amitlan@postgresql.org>
2026-11-11 06:06 pgsql: SQL/JSON: Fix PASSING of string types other than text and varcha 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