| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | e1638616(at)u(dot)nus(dot)edu |
| Subject: | BUG #19971: JSON_VALUE RETURNING json drops the quotes of a jsonb string DEFAULT |
| Date: | 2026-12-02 13:27:33 |
| Message-ID: | 19971-5a844714bd6f89f8@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19971
Logged by: Yibo Dong
Email address: e1638616(at)u(dot)nus(dot)edu
PostgreSQL version: 19.0
Operating system: macOS 15 arm64.
Description:
With RETURNING json, a jsonb DEFAULT "123" is returned as the number 123,
and "abc" fails with "invalid input syntax for type json". A JSON string
found by the path, a json DEFAULT and RETURNING jsonb all keep the quotes.
A domain over jsonb as the RETURNING type and DEFAULT ... ON ERROR behave
the same way.
Steps to reproduce:
SELECT JSON_VALUE(jsonb '"123"', '$' RETURNING json) AS path_json,
JSON_VALUE(jsonb '{}', '$.a' RETURNING json DEFAULT '"123"'::json ON
EMPTY) AS json_default,
JSON_VALUE(jsonb '{}', '$.a' RETURNING jsonb DEFAULT '"123"'::jsonb
ON EMPTY) AS jsonb_to_jsonb,
JSON_VALUE(jsonb '{}', '$.a' RETURNING json DEFAULT '"123"'::jsonb ON
EMPTY) AS jsonb_to_json;
Actual result:
path_json | json_default | jsonb_to_jsonb | jsonb_to_json
-----------+--------------+----------------+---------------
"123" | "123" | "123" | 123
Expected result: jsonb_to_json is "123", like the other three columns.
PostgreSQL 19.0 (Homebrew), macOS 15 arm64.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Shrihari Danawe | 2026-12-02 14:25:17 | Re: pg_rewind WAL segments deletion pitfall |
| Previous Message | PG Bug reporting form | 2026-12-02 13:17:10 | BUG #19970: json #> finds a nested key under an earlier duplicate key |