Re: [HACKERS] [PATCH] Generic type subscripting - Mailing list pgsql-hackers

From Dmitry Dolgov
Subject Re: [HACKERS] [PATCH] Generic type subscripting
Date
Msg-id CA+q6zcUws7270pFKgT7G0jFuLxmCaBLqPL0o4sfgfLnRBGg9gg@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] [PATCH] Generic type subscripting  (Dmitry Dolgov <9erthalion6@gmail.com>)
Responses Re: [HACKERS] [PATCH] Generic type subscripting  (Arthur Zakirov <a.zakirov@postgrespro.ru>)
List pgsql-hackers
> On 14 November 2017 at 22:25, Dmitry Dolgov <9erthalion6@gmail.com> wrote:
> But now I wonder if `resnull` is really needed in `jsonb_get_element`,
> `array_get_element` and it seems to me that I can even get rid of it so

On the second thought, no, looks like I'm wrong and it should be like this. The
reason is that any `fetch` function should be in form

    (container, internal) -> extracted value

which means that we need to return an extracted value (for jsonb it's a `jsonb`,
for array it's an `anyelement`). But at the same time in general case we can
figure out if the result is null only inside a `fetch` function,
(`jsonb_get_element` for jsonb or whatever it may be for a custom data type)
because it returns Datum. So the only way to return this information is by
reference through the `internal` argument. To summarize, If as you said it's
not that critical, I would suggest to leave it as it is.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Updated macOS start scripts
Next
From: Tom Lane
Date:
Subject: Re: Further simplification of c.h's #include section