Proposal: minor SPI interface change

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Proposal: minor SPI interface change
Дата
Msg-id 12916.1173982197@sss.pgh.pa.us
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: My honours project - databases using dynamically attached entity-properties
Следующее
От: "Dawid Kuroczko"
Дата:
Сообщение: Re: [RFC] CLUSTER VERBOSE