Re: FmgrInfo allocation patterns (and PL handling as staged programming)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chapman Flack <jcflack(at)acm(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: FmgrInfo allocation patterns (and PL handling as staged programming)
Date: 2025-04-07 02:37:41
Message-ID: 3291225.1743993461@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chapman Flack <jcflack(at)acm(dot)org> writes:
> On 04/06/25 20:01, Tom Lane wrote:
>> Looking more closely at ProcedureCreate(), it makes a dependency
>> if a transform *exists* for the argument or result type, whether
>> a TRANSFORM clause is present or not. Surely this is completely
>> bogus? We should be depending on the OIDs mentioned in protrftypes,

> I think that's it. I tested by creating a function like
> create function foo() returns text transform for type circle
> that is, with the transform type not appearing as an argument or
> return type.
> As far as I know, that's still a cromulent usage, as I could be saying
> I want the function to apply that transform to circles it uses or retrieves
> in queries it makes.

Oh, interesting interpretation. The in-core PLs only consider the
transform list in relation to parameters and results, but I suppose
that's just because they have no use for internal conversions ...
and even then, you could argue that that's wrong and they should
apply the specified conversions when invoking, say, SQL queries
via SPI. Something to think about another day.

Here's a draft patch to fix the bogus dependencies. As given this'd
only be okay for HEAD, since I doubt we can get away with changing
ProcedureCreate()'s signature in stable branches. Given the lack of
prior complaints, I'm content to fix this only in HEAD --- but maybe
somebody will think differently? In the back branches we could make
ProcedureCreate() deconstruct the OID array it's given and then repeat
the transform lookups, but ugh. I guess a "ProcedureCreateExt"
alternate entry point would do the trick too.

BTW, I feel a little uncomfortable with the idea that we're adding
dependencies on objects that are explicitly mentioned nowhere in the
pg_proc entry. I suppose it's okay, and the preceding code did that
too, but still.

regards, tom lane

Attachment Content-Type Size
v1-fix-bogus-transform-dependencies.patch text/x-diff 9.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2025-04-07 02:59:12 Re: Reduce "Var IS [NOT] NULL" quals during constant folding
Previous Message Zhijie Hou (Fujitsu) 2025-04-07 02:18:58 RE: pg_recvlogical cannot create slots with failover=true