agora inbox for pgsql-bugs@postgresql.org
help / color / mirror / Atom feedBUG #19589: JSON_QUERY rejects domain-over-bytea input when using FORMAT JSON ENCODING UTF8.
2+ messages / 2 participants
[nested] [flat]
* BUG #19589: JSON_QUERY rejects domain-over-bytea input when using FORMAT JSON ENCODING UTF8.
@ 2026-07-30 10:29 PG Bug reporting form <noreply@postgresql.org>
2026-07-31 05:41 ` Re: BUG #19589: JSON_QUERY rejects domain-over-bytea input when using FORMAT JSON ENCODING UTF8. Tristan Partin <tristan@partin.io>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2026-07-30 10:29 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: dllggyx@outlook.com
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #19589: JSON_QUERY rejects domain-over-bytea input when using FORMAT JSON ENCODING UTF8.
2026-07-30 10:29 BUG #19589: JSON_QUERY rejects domain-over-bytea input when using FORMAT JSON ENCODING UTF8. PG Bug reporting form <noreply@postgresql.org>
@ 2026-07-31 05:41 ` Tristan Partin <tristan@partin.io>
0 siblings, 0 replies; 2+ messages in thread
From: Tristan Partin @ 2026-07-31 05:41 UTC (permalink / raw)
To: dllggyx@outlook.com; +Cc: pgsql-bugs@lists.postgresql.org
On Thu Jul 30, 2026 at 1:40 PM CDT, PG Bug reporting form wrote:
> 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
Thanks for the report. I am currently taking a look at this. I have
reproduced the issue and am working on a fix.
--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-07-31 05:41 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-30 10:29 BUG #19589: JSON_QUERY rejects domain-over-bytea input when using FORMAT JSON ENCODING UTF8. PG Bug reporting form <noreply@postgresql.org>
2026-07-31 05:41 ` Tristan Partin <tristan@partin.io>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox