Re: Why does load_external_function() return PGFunction?

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why does load_external_function() return PGFunction?
Date: 2018-03-24 20:33:21
Message-ID: 20180324203320.fsdm2qsibfcvgpsb@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018-02-06 15:43:29 -0500, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > We've several callers to load_external_function() that do not use the
> > returned value as a PGFunction. I'd vote for changing the return type to
> > void * and have fmgr.c cast it to PGFunction after verifying the
> > function's magic.
>
> 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.
>
> I'd be OK with declaring it as a more generic function pointer type,
> perhaps "void (*funcptr) ()".
>
> However, given that a cast is going to be necessary anyway, it seems
> like this is mostly useless churn...

I don't think it really changes the need, but it's worthwhile to note
that gcc-8 warns about this now:
/home/andres/src/postgresql/src/backend/postmaster/bgworker.c: In function ‘LookupBackgroundWorkerFunction’:
/home/andres/src/postgresql/src/backend/postmaster/bgworker.c:1246:9: warning: cast between incompatible function types from ‘PGFunction’ {aka ‘long unsigned int (*)(struct FunctionCallInfoData *)’} to ‘void (*)(Datum)’ {aka ‘void (*)(long unsigned int)’} [-Wcast-function-type]
return (bgworker_main_type)

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-03-24 20:36:55 Re: Undesirable entries in typedefs list
Previous Message Alexander Korotkov 2018-03-24 19:39:20 Re: WIP: Covering + unique indexes.