JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding) - Mailing list pgsql-hackers

From Shay Rojansky
Subject JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)
Date
Msg-id CADT4RqB9y5A58CAxMgWQpKG2QA1pzk3dzAUmNH8bJ9SwMP=ZnA@mail.gmail.com
Whole thread Raw
Responses Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)
Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)
List pgsql-hackers
Greetings hackers,

The de-facto standard for storing binary data in JSON documents seems to be base64-encoded strings, so I was expecting JSON_VALUE's RETURNING bytea to do base64 decoding. However, that does not seem to be the case:

SELECT decode('AQID', 'base64'); -- 0x010203
SELECT JSON_VALUE(jsonb '"AQID"', '$' RETURNING bytea); -- Expected 0x010203, got AQID

This forces an additional explicit decode() function call:

SELECT decode(JSON_VALUE(jsonb '"AQID"', '$'), 'base64'); -- 0x010203

Is the above behavior intentional?

Shay

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Disabling vacuum truncate for autovacuum
Next
From: Ian Lawrence Barwick
Date:
Subject: Re: jsonb_strip_nulls with arrays?