Proposal: minor SPI interface change - Mailing list pgsql-hackers

From Tom Lane
Subject Proposal: minor SPI interface change
Date
Msg-id 12916.1173982197@sss.pgh.pa.us
Whole thread Raw
List pgsql-hackers
While fooling with getting SPI to use the plancache, I got annoyed again
about how SPI_prepare() and related functions refer to SPI plan pointers
as "void *".  I'm all for having the structure be opaque to callers, but
to me "void *" means "any old pointer", which this surely is not.  I'd
like to change things so that spi.h does
typedef struct _SPI_plan *SPIPlanPtr;

and then SPI_prepare is declared to return SPIPlanPtr not void *, and
likewise for the other SPI functions dealing with plans.

AFAICS this does not break code that refers to plan pointers as "void *"
because C compilers will allow implicit casts between void * and
SPIPlanPtr.  However, for code that we feel like updating, the result
is more readable and less error-prone.

There are people out there who want their code to compile against
multiple PG versions.  To use the improved notation and still compile
against pre-8.3 headers, they could do

#if CATALOG_VERSION_NO < whatever
typedef void *SPIPlanPtr;
#endif

Comments, objections?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: My honours project - databases using dynamically attached entity-properties
Next
From: "Dawid Kuroczko"
Date:
Subject: Re: [RFC] CLUSTER VERBOSE