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;

Comments, objections?

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to