From: | Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Chapman Flack <chap(at)anastigmatix(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Extract numeric filed in JSONB more effectively |
Date: | 2023-08-17 09:07:31 |
Message-ID: | CAKU4AWqbd_oDwXyK7=yMKbhAR=CQtVOWszcgft+cTG6JCTKmzQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi jian:
On Thu, Aug 17, 2023 at 12:32 AM jian he <jian(dot)universality(at)gmail(dot)com>
wrote:
> On Wed, Aug 16, 2023 at 2:28 PM Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> wrote:
> >
> > update with the correct patch..
>
> regression=# select proname, pg_catalog.pg_get_function_arguments(oid)
> from pg_proc
> where proname = 'jsonb_extract_path_type';
> proname | pg_get_function_arguments
>
> -------------------------+--------------------------------------------------------------------
> jsonb_extract_path_type | from_json jsonb, VARIADIC path_elems
> text[], target_oid anyelement
> (1 row)
>
> VARIADIC should be the last argument?
>
Currently if users call this function directly(usually I don't think
so), they will get something wrong. This issue is fixed in the
v9 version. To keep the consistency among all the functions,
I moved the 'target_type anyelement' to the 1st argument.
Thanks for the report!
> select jsonb_array_element_type(jsonb'[1231]',0, null::int);
> now return null.
> Should it return 1231?
>
No, this is by design. the function is declared as strict, so
any NULL inputs yield a NULL output. That's just what we
talked above (the markDummyConst section). I don't
think this should be addressed.
> select jsonb_array_element_type(jsonb'[1231]',0, '1'::jsonb);
> will crash
>
OK, looks I didn't pay enough attention to the 'user directly call
jsonb_xx_type' function, so I changed the code in v9 based on
your suggestion.
Thanks for the review, v9 attached!
--
Best Regards
Andy Fan
Attachment | Content-Type | Size |
---|---|---|
test.sql | application/octet-stream | 4.4 KB |
v9-0001-optimize-casting-jsonb-to-a-given-type.patch | application/octet-stream | 31.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | a.rybakina | 2023-08-17 10:08:03 | Re: POC, WIP: OR-clause support for indexes |
Previous Message | Anthony Roberts | 2023-08-17 08:41:44 | Re: [PATCH] Add native windows on arm64 support |