Re: proposal: jsonb_populate_array

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Chapman Flack <chap(at)anastigmatix(dot)net>, Erik Rijkers <er(at)xs4all(dot)nl>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: proposal: jsonb_populate_array
Date: 2023-08-15 05:59:05
Message-ID: CAFj8pRDvwrB+jMaY-qXYL75Pk+mNQUSyNhAQ5EfqYeV2uHW83g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

út 15. 8. 2023 v 5:12 odesílatel jian he <jian(dot)universality(at)gmail(dot)com>
napsal:

> \df jsonb_populate_record
> List of functions
> Schema | Name | Result data type | Argument data
> types | Type
>
> ------------+-----------------------+------------------+---------------------+------
> pg_catalog | jsonb_populate_record | anyelement | anyelement,
> jsonb | func
> (1 row)
>
> manual:
> > anyelement Indicates that a function accepts any data type.
> > For the “simple” family of polymorphic types, the matching and deduction
> rules work like this:
> > Each position (either argument or return value) declared as anyelement
> is allowed to have any specific actual data type, but in any given call
> they must all be the same actual type.
>
> So jsonb_populate_record signature can handle cases like
> jsonb_populate_record(anyarray, jsonb)? obviously this is a cast, it
> may fail.
> also if input is anyarray, so the output anyarray will have the same
> base type as input anyarray.
>

It fails (what is expected - else be too strange to use function in name
"record" for arrays)

(2023-08-15 07:57:40) postgres=# select
jsonb_populate_record(null::varchar[], '[1,2,3]');
ERROR: first argument of jsonb_populate_record must be a row type

regards

Pavel

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Meskes 2023-08-15 05:59:42 Re: ECPG Semantic Analysis
Previous Message Vik Fearing 2023-08-15 05:58:17 Re: [PATCH] Add function to_oct