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