Re: Why does load_external_function() return PGFunction?

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why does load_external_function() return PGFunction?
Date: 2018-02-10 16:13:45
Message-ID: fbedf006-d77a-024e-7ae4-4e99499badbf@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2/7/18 09:35, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
>> On 2018-02-06 15:43:29 -0500, Tom Lane wrote:
>>> void* isn't necessarily compatible with function pointers --- there are
>>> platforms where they're physically different widths, though possibly
>>> you'd never get PG to run on such hardware anyway.
>
>> Fair point. Although we're relying on dlsym like infrastructure, which
>> returns just a void *.
>
> Yeah. Presumably, a platform where they were really different would have
> to provide some unstandardized variant of dlsym for fetching function
> pointers. We could cope with that fairly easily as things stand, since
> we have platform-specific wrappers for dlsym anyway. But if we made the
> API for the wrappers dependent on data and code pointers being the same,
> we'd be in trouble.

Some years ago, this issue was identified as a defect in the POSIX
standard. At the time, it seemed they were moving in the direction of
changing the dlsym() signature to return an opaque function pointer.
However, it seems the latest version published by the Open Group says
effectively, while this is not required to work in ISO C, this standard
requires it to work.

FreeBSD has added a dlfunc() function as a workaround, but it apparently
hasn't spread anywhere else.

So, um, I don't know. Carry on. ;-)

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-02-10 17:12:28 Re: CALL stmt, ERROR: unrecognized node type: 113 bug
Previous Message Andrey Borodin 2018-02-10 15:45:40 Re: [HACKERS] Can ICU be used for a database's default sort order?