From 45832376f9b05672902a709a9b63bec026baf0df Mon Sep 17 00:00:00 2001 From: shihao zhong Date: Sun, 29 Nov 2026 23:42:44 -0500 Subject: [PATCH 3/3] Test collations of PASSING arguments in JSON query functions Bug: #19872 Discussion: https://postgr.es/m/19872-fe8b70fdefd5d598@postgresql.org --- src/test/regress/expected/sqljson_queryfuncs.out | 9 +++++++++ src/test/regress/sql/sqljson_queryfuncs.sql | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/test/regress/expected/sqljson_queryfuncs.out b/src/test/regress/expected/sqljson_queryfuncs.out index 19db825c8ab..0f5a2fad5e5 100644 --- a/src/test/regress/expected/sqljson_queryfuncs.out +++ b/src/test/regress/expected/sqljson_queryfuncs.out @@ -1842,3 +1842,12 @@ SELECT JSON_VALUE(x, '$' RETURNING jsonb) FROM (VALUES ('1'::jsonb), (NULL), ('2 2 (3 rows) +-- PASSING arguments must not affect the result collation, and needn't agree +-- with each other (bug #19872) +SELECT pg_collation_for(JSON_VALUE(jsonb '"a"', '$' + PASSING 'b' COLLATE "C" AS x, 'c' COLLATE "POSIX" AS y)); + pg_collation_for +------------------ + "default" +(1 row) + diff --git a/src/test/regress/sql/sqljson_queryfuncs.sql b/src/test/regress/sql/sqljson_queryfuncs.sql index 5c675d98235..515c139aa59 100644 --- a/src/test/regress/sql/sqljson_queryfuncs.sql +++ b/src/test/regress/sql/sqljson_queryfuncs.sql @@ -625,3 +625,8 @@ SELECT JSON_VALUE(x, '$' RETURNING json) FROM (VALUES ('1'::json), ('null'), ('2 SELECT JSON_VALUE(x, '$.a' RETURNING jsonb) FROM (VALUES ('{"a": 1}'::jsonb), ('{}'), ('{"a": 2}')) v(x); SELECT JSON_VALUE(x, 'strict $.a' RETURNING jsonb) FROM (VALUES ('{"a": 1}'::jsonb), ('[]'), ('{"a": 2}')) v(x); SELECT JSON_VALUE(x, '$' RETURNING jsonb) FROM (VALUES ('1'::jsonb), (NULL), ('2')) v(x); + +-- PASSING arguments must not affect the result collation, and needn't agree +-- with each other (bug #19872) +SELECT pg_collation_for(JSON_VALUE(jsonb '"a"', '$' + PASSING 'b' COLLATE "C" AS x, 'c' COLLATE "POSIX" AS y)); -- 2.37.1 (Apple Git-137.1)