From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, jian he <jian(dot)universality(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Extract numeric filed in JSONB more effectively |
Date: | 2023-08-14 08:01:31 |
Message-ID: | CAFj8pRDbZCBgZhnOPK5JbMRDpUrpxceaGVaorz30PycAjteeig@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
po 14. 8. 2023 v 9:06 odesílatel Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> napsal:
>
>> We'd still have functions like jsonb_field_as_numeric() under the
>> hood, but there's not an expectation that users call them explicitly.
>>
>
> To avoid the lots of functions like jsonb_field_as_int2/int4, I defined
> Datum jsonb_object_field_type(.., Oid target_oid) at last, so the
> function must return "internal" or "anyelement". Then we can see:
>
> select jsonb_object_field_type(tb.a, 'a'::text, 1700) from tb;
> ERROR: cannot display a value of type anyelement.
>
you cannot to use type as parameter. There should be some typed value - like
jsonb_object_field, '{"a":10}', 'a', NULL::int)
and return type should be anyelement.
Another solution should be more deeper change like implementation of
"coalesce"
>
> The reason is clear to me, but I'm not sure how to fix that or deserves
> a fix? Or shall I define jsonb_object_field_int2/int8 to avoid this?
>
> This is an unresolved issue at the latest patch.
> --
> Best Regards
> Andy Fan
>
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiro Ikeda | 2023-08-14 08:12:47 | Re: Fix pg_stat_reset_single_table_counters function |
Previous Message | Thomas Munro | 2023-08-14 07:15:20 | Re: pgbench with libevent? |