Re: Using Expanded Objects other than Arrays from plpgsql

From: Michel Pelletier <pelletier(dot)michel(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Using Expanded Objects other than Arrays from plpgsql
Date: 2024-10-21 03:29:13
Message-ID: CACxu=vLXvpzN4X3k+9jsMt6ujuOvFVUSkA80t_cROSsF4y2jQQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Sun, Oct 20, 2024 at 10:13 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

>
> I'm not sure. It seems certain that if the object is already expanded
> (either R/W or R/O), the paths for that in plpgsql_exec_function could
> be taken regardless of its specific type.
>

> But it seems like we could get an easy win by adjusting
> plpgsql_exec_function along the lines of
>
> l. 549:
> - if (!var->isnull && var->datatype->typisarray)
> + if (!var->isnull)
>
> l. 564:
> - else
> + else if (var->datatype->typisarray)
>
> How far does that improve matters for you?
>

I tried this change and couldn't get it to work, on the next line:

if (!var->isnull)
{
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.

I guess this gets back into knowing if a flat thing is expandable or not.
I'm going to spend some more time looking at it, I haven't been in this
corner of Postgres before.

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.

-Michel

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2024-10-21 03:46:44 Re: Using Expanded Objects other than Arrays from plpgsql
Previous Message Barry Walker 2024-10-20 23:21:27 Re: Help Resolving Compiler Errors With enable-dtrace Flag

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2024-10-21 03:37:21 Re: Pgoutput not capturing the generated columns
Previous Message Zhijie Hou (Fujitsu) 2024-10-21 03:09:59 RE: Conflict detection for update_deleted in logical replication