| From: | Staroverov Ilja <i(dot)staroverov(at)ftdata(dot)ru> |
|---|---|
| To: | Nikhil Sontakke <nikkhils(at)gmail(dot)com>, Matt Blewitt <mble(at)planetscale(dot)com> |
| Cc: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [***DKIM violation***] Re: [PATCH] Fix JSON_SERIALIZE() coercion placeholder type for jsonb input |
| Date: | 2026-10-15 13:06:20 |
| Message-ID: | 8A3E69FD-4AF6-4320-B898-B7E2DA75FD99@localhost.localdomain |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
One more consequence of this bug that I think matters for the
back-patching question. Nikhil wrote upthread that no back-patch is
intended. The bug doesn't just produce a confusing result: the result is
a text value whose bytes are taken from the jsonb header, so it can be
invalidly encoded, and it can be stored. In a UTF8 database, on 18.6:
CREATE TABLE t (s text);
INSERT INTO t SELECT json_serialize(jsonb_agg(g))
FROM generate_series(1, 200) g;
SELECT encode(s::bytea, 'hex') FROM t; -- c8
SELECT convert_to(s, 'UTF8') FROM t;
ERROR: invalid byte sequence for encoding "UTF8": 0xc8
pg_dump of such a table succeeds, but restoring the dump fails:
ERROR: invalid byte sequence for encoding "UTF8": 0xc8 0x0a
and the table ends up empty. With v3 applied to master, the same INSERT stores the correct
892-byte text. Given that, I think the fix should be back-patched to 17,
where JSON_SERIALIZE() was added (REL_17_STABLE has the same code).
Also, in the original pgsql-bugs thread, Shihao Zhong has since posted
another patch for the same bug:
https://postgr.es/m/03583FE7-A5EE-407C-907D-67865F3F8BFC@gmail.com
so it's probably worth closing both together.
--
Ilya Staroverov
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Aidar Imamov | 2026-10-15 13:26:24 | Re: Disable startup progress timeout during standby WAL replay |
| Previous Message | Hayato Kuroda (Fujitsu) | 2026-10-15 13:06:00 | RE: [PG19] Promotion hangs behind a backend blocked on a stuck client |