agora inbox for pgsql-bugs@postgresql.org
help / color / mirror / Atom feedFrom: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: dllggyx@outlook.com
Subject: BUG #19589: JSON_QUERY rejects domain-over-bytea input when using FORMAT JSON ENCODING UTF8.
Date: Thu, 30 Jul 2026 10:29:19 +0000
Message-ID: <19589-edd0b3b861601fef@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 19589
Logged by: Yuxiao Guo
Email address: dllggyx@outlook.com
PostgreSQL version: 18.4
Operating system: Ubuntu 20.04 x86-64, docker image postgres:18.4
Description:
Query A and Query B are equivalent, but while JSON_QUERY(... FORMAT JSON
ENCODING UTF8 ...) accepts a direct bytea input, it incorrectly rejects a
domain-over-bytea input with the error JSON ENCODING clause is only allowed
for bytea input type.
PoC:
```sql
CREATE DOMAIN d_json_bytea AS bytea;
-- Query A
SELECT JSON_QUERY(convert_to(txt, 'utf8') FORMAT JSON ENCODING UTF8, '$') AS
j
FROM (VALUES ('[1,2]')) AS src(txt);
-- Query B
SELECT JSON_QUERY(b FORMAT JSON ENCODING UTF8, '$') AS j
FROM (
SELECT convert_to(txt, 'utf8')::d_json_bytea AS b
FROM (
SELECT txt
FROM (
SELECT '[1,2]'::text AS txt
UNION ALL
SELECT '[9,9]'::text WHERE false
) AS u
WHERE txt LIKE '[%'
) AS filtered
) AS typed;
```
Result of Query A:
j
--------
[1, 2]
(1 row)
Result of Query B:
ERROR: JSON ENCODING clause is only allowed for bytea input type
LINE 1: SELECT JSON_QUERY(b FORMAT JSON ENCODING UTF8, '$') AS j
view thread (2+ messages) latest in thread
Message-ID: <19589-edd0b3b861601fef@postgresql.org>
Permalink: ../19589-edd0b3b861601fef@postgresql.org/
Also on: postgresql.org/message-id/19589-edd0b3b861601fef@postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, dllggyx@outlook.com
Subject: Re: BUG #19589: JSON_QUERY rejects domain-over-bytea input when using FORMAT JSON ENCODING UTF8.
In-Reply-To: <19589-edd0b3b861601fef@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox