Re: Extract numeric filed in JSONB more effectively
От | Chapman Flack |
---|---|
Тема | Re: Extract numeric filed in JSONB more effectively |
Дата | |
Msg-id | 900892914fdc3f477b101d699efb40e0@anastigmatix.net обсуждение исходный текст |
Ответ на | Re: Extract numeric filed in JSONB more effectively (Andy Fan <zhihui.fan1213@gmail.com>) |
Ответы |
Re: Extract numeric filed in JSONB more effectively
|
Список | pgsql-hackers |
On 2023-08-14 03:06, Andy Fan wrote: >> 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". > ... > I'm not sure how to fix that or deserves > a fix? Or shall I define jsonb_object_field_int2/int8 to avoid this? As far as I'm concerned, if the intent is for this to be a function that is swapped in by SupportRequestSimplify and not necessarily to be called by users directly, I don't mind if users can't call it directly. As long as there is a nice familiar jsonb function the user can call in a nice familiar way and knows it will be handled efficiently behind the curtain, that seems to be good enough for the user--better, even, than having a new oddball function to remember. However, I believe the rule is that a function declared to return internal must also declare at least one parameter as internal. That way, a user won't be shown errors about displaying its returned value, because the user won't be able to call it in the first place, having no values of type 'internal' lying around to pass to it. It could simply have that trailing oid parameter declared as internal, and there you have a strictly internal-use function. Providing a function with return type declared internal but with no parameter of that type is not good, because then a user could, in principle, call it and obtain a value of 'internal' type, and so get around the typing rules that prevent calling other internal functions. Regards, -Chap
В списке pgsql-hackers по дате отправления: