proposal: allow to specify result tupdesc and mode in SPI API - Mailing list pgsql-hackers

From Pavel Stehule
Subject proposal: allow to specify result tupdesc and mode in SPI API
Date
Msg-id CAFj8pRAgboSSD-W1gKg3jKVV7s1Zhvf8==gm5+PV6ndR34v-bQ@mail.gmail.com
Whole thread Raw
List 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

pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: strncpy is not a safe version of strcpy
Next
From: Etsuro Fujita
Date:
Subject: Compute attr_needed for child relations (was Re: inherit support for foreign tables)