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

From Shay Rojansky
Subject Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)
Date
Msg-id CADT4RqDDJN4t8A8Za4yhJeLmZJMeHES5aZvW2W4EpWnDd6U0FQ@mail.gmail.com
Whole thread Raw
In response to Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)
List pgsql-hackers

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

I get \x41514944 which is precisely what I would expect since it what this query results in as well:

select 'AQID'::bytea;

If the behavior of RETURNING is meant to be identical to that of simply applying a cast, is there any actual advantage in using JSON_VALUE with RETURNING? In other words, why not just do JSON_VALUE(json '"AQID"', '$')::bytea instead of using RETURNING? I thought the point was precisely for RETURNING to be able to perform JSON-specific conversions (e.g. take into account that the base64 is being converted from a *JSON* string, and therefore apply base64 decoding to it).

pgsql-hackers by date:

Previous
From: Greg Sabino Mullane
Date:
Subject: Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)
Next
From: "David G. Johnston"
Date:
Subject: Re: JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)