Proposal: minor SPI interface change

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Proposal: minor SPI interface change
Date: 2007-03-15 18:09:57
Message-ID: 12916.1173982197@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Dawid Kuroczko 2007-03-15 19:49:28 Re: [RFC] CLUSTER VERBOSE
Previous Message Andrew Dunstan 2007-03-15 16:49:10 Re: My honours project - databases using dynamically attached entity-properties