Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)

From: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
To: Shay Rojansky <roji(at)roji(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)
Date: 2025-03-06 00:51:50
Message-ID: CAKAnmmLPhU=fucw8B-TUs44+64R17LZ1eDN8qKORR+dTJVj77w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

It looks like your bytea_output is set to 'escape', which would explain
what you are seeing. Try adding this in first:

SET bytea_output = hex;
SELECT JSON_VALUE(jsonb '"AQID"', '$' RETURNING bytea);

That (hex) is the default value, so you must be setting it to escape
somewhere. You can see where by running:

select * from pg_settings where name = 'bytea_output';

Examine the source, sourcefile, and sourceline columns

I personally prefer hex, but perhaps it's set to octet in your system for a
reason. If not, maybe change it globally?

Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Shay Rojansky 2025-03-06 00:54:35 Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)
Previous Message Heikki Linnakangas 2025-03-06 00:47:38 Re: Interrupts vs signals