public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Michel Pelletier <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Using Expanded Objects other than Arrays from plpgsql
Date: Sun, 20 Oct 2024 23:46:44 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CACxu=vLXvpzN4X3k+9jsMt6ujuOvFVUSkA80t_cROSsF4y2jQQ@mail.gmail.com>
References: <CACxu=vJaKFNsYxooSnW1wEgsAO5u_v1XYBacfVJ14wgJV_PYeg@mail.gmail.com>
<[email protected]>
<CACxu=vLXvpzN4X3k+9jsMt6ujuOvFVUSkA80t_cROSsF4y2jQQ@mail.gmail.com>
Michel Pelletier <[email protected]> writes:
> On Sun, Oct 20, 2024 at 10:13 AM Tom Lane <[email protected]> wrote:
>> But it seems like we could get an easy win by adjusting
>> plpgsql_exec_function along the lines of
>> ...
> I tried this change and couldn't get it to work, on the next line:
> if (VARATT_IS_EXTERNAL_EXPANDED_RW(DatumGetPointer(var->value)))
> var->value might not be a pointer, as it seems at least from my gdb
> scratching, but say an integer. This segfaults on non-array but
> non-expandable datum.
Oh, duh --- the typisarray test serves to eliminate pass-by-value
types. We need the same test that exec_assign_value makes,
!var->datatype->typbyval, before it's safe to apply DatumGetPointer.
So line 549 needs to be more like
- if (!var->isnull && var->datatype->typisarray)
+ if (!var->isnull && !var->datatype->typbyval)
> Another comment that caught my eye was this one:
> https://github.com/postgres/postgres/blob/master/src/pl/plpgsql/src/pl_exec.c#L8304
> Not sure what the implication is there.
Yeah, that's some more unfinished business. I'm not sure if it
matters to your use-case or not.
BTW, we probably should move this thread to pgsql-hackers.
regards, tom lane
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Using Expanded Objects other than Arrays from plpgsql
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox