Re: Extract numeric filed in JSONB more effectively

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Chapman Flack <chap(at)anastigmatix(dot)net>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Extract numeric filed in JSONB more effectively
Date: 2023-09-06 07:00:00
Message-ID: CAKU4AWqQ0hed=ZmpT+7Vxnp4H9ZxQqFz30=k=vvrmNe57X4dKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
>
> based on v13.
> IMHO, it might be a good idea to write some comments on
> jsonb_object_field_internal. especially the second boolean argument.
> something like "some case, we just want return JsonbValue rather than
> Jsonb. to return JsonbValue, make as_jsonb be false".
>

OK, I will proposal "return a JsonbValue when as_jsonb is false".

> I am not sure "jsonb_object_field_start" is a good name, so far I only
> come up with "jsonb_object_field_to_jsonbvalues".

Yes, I think it is a good idea. Puting the jsonbvalue in the name can
compensate for the imprecision of "internal" as a return type. I am
thinking
if we should rename jsonb_finish_numeric to jsonbvalue_to_numeric as
well.

>
linitial(jsonb_start_func->args) =
> makeRelabelType(linitial(jsonb_start_func->args),
> INTERNALOID, 0,
> InvalidOid,
> COERCE_IMPLICIT_CAST);
>
> if no need, output typmod (usually -1), so here should be -1 rather than 0?

I agree. -1 is better than 0.

Thanks for the code level review again! I want to wait for some longer time
to gather more feedback. I'm willing to name it better, but hope I didn't
rename it to A and rename it back shortly.

--
Best Regards
Andy Fan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Fan 2023-09-06 07:13:39 Re: A minor adjustment to get_cheapest_path_for_pathkeys
Previous Message Peter Eisentraut 2023-09-06 06:52:14 Re: [PATCH] psql: Add tab-complete for optional view parameters