Re: jsonb_array_elements_recursive() - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: jsonb_array_elements_recursive()
Date
Msg-id CAKFQuwY4-kzcUOmTHFVA_oi_vDH7Q_QXvuzmDhB8SVsHjoc1SA@mail.gmail.com
Whole thread Raw
In response to Re: jsonb_array_elements_recursive()  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
On Sun, Feb 7, 2021 at 11:39 AM Pavel Stehule <pavel.stehule@gmail.com> wrote:


ne 7. 2. 2021 v 19:18 odesílatel Zhihong Yu <zyu@yugabyte.com> napsal:
Hi,

bq. SELECT unnest('[[5,2],"a",[8,[3,2],6]]'::jsonb);

Since the array without cast is not normal array (and would be rejected), I wonder if the cast is needed.
Because casting to jsonb is the only legitimate interpretation here.

only until somebody does support for hstore, xml, ... some future data type

Minimally now, we have json, jsonb types.


More generally, a sequence of characters has no meaning to the system unless and until an externally supplied type is given to it allowing it to interpret the sequence of characters in some concrete way.  The system will never assign a concrete type to some random sequence of characters based upon what those characters are.  Forgive the idiom, but to do otherwise would be putting the cart before the horse.  It would also be quite expensive and prone to, as above, different types deciding on the same textual representation being valid input to each.

David J.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bug in query rewriter - hasModifyingCTE not getting set
Next
From: John Naylor
Date:
Subject: Re: [POC] verifying UTF-8 using SIMD instructions