Re: Why does load_external_function() return PGFunction?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Why does load_external_function() return PGFunction?
Date: 2018-05-13 15:05:50
Message-ID: 21121.1526223950@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Thu, May 10, 2018 at 4:45 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
>> IMO the important
>> part isn't that the parameters fit exactly - we'll have to cast for the
>> return type anyway - but that it's declared as a pointer-to-function for
>> the hyptothetical supported platform that has different pointers to
>> functions than to other objects.

> Probably the more relevant concern is what's going to compile
> warning-free on all supported compilers.

+1

> I think it's unlikely that
> such a hypothetical supported platform actually exists, although maybe
> I'm wrong.

Such platforms certainly used to exist, and not that long ago either.
I think the last common example was that Intel compilers used to let
you choose the size of data pointers separately from the size of code
pointers, cf
https://en.wikipedia.org/wiki/Intel_Memory_Model

There's some other entertaining reading here:
https://en.wikipedia.org/wiki/Harvard_architecture

Those sorts of pushups have fallen into disfavor with the availability
of larger address spaces, and these days it's a bit hard to imagine
anybody porting PG to a new platform that works like that. But that's
why the C standard discourages considering code and data pointers as
being interchangeable.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Muller 2018-05-13 22:18:38 Allow COPY's 'text' format to output a header
Previous Message Robert Haas 2018-05-13 13:01:10 Re: Why does load_external_function() return PGFunction?