proposal: allow to specify result tupdesc and mode in SPI API

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: proposal: allow to specify result tupdesc and mode in SPI API
Date: 2014-08-14 04:29:19
Message-ID: CAFj8pRAgboSSD-W1gKg3jKVV7s1Zhvf8==gm5+PV6ndR34v-bQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

we have not possibility to simple specify result types in SPI API
functions. Planner has this functionality - see transformInsertRow
function, but it is not visible from SPI.

A new function should to look like:

SPIPlanPtr
SPI_prepare_params_rettupdesc(const char *src,
ParserSetupHook parserSetup,
void *parserSetupArg,
int cursorOptions,
TupDesc *retTupDesc,
int CoercionMode)

CoercionMode should be:

COERCION_MODE_SQL .. same as INSERT or UPDATE does
COERCION_MODE_SQL_NOERROR .. same as above with possible IO cast
COERCION_MODE_EXPLICIT .. same as using explicit casting
COERCION_MODE_EXPLICIT_NOERROR .. same as previous with possible IO cast

Benefits:

* simplify life to SPI users - no necessary late casting

* possible small simplification of plpgsql with two benefits:

** reduce performance impact of hidden IO cast

** reduce possible issues with type transformation via hidden IO cast

Comments, notes?

Regards

Pavel Stehule

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2014-08-14 04:35:46 Compute attr_needed for child relations (was Re: inherit support for foreign tables)
Previous Message Noah Misch 2014-08-14 04:13:21 Re: strncpy is not a safe version of strcpy