Additional SPI functions - Mailing list pgsql-hackers

From James William Pye
Subject Additional SPI functions
Date
Msg-id 5B8B33BF-4FE1-410A-AE75-9AA1E341DD0C@jwp.name
Whole thread Raw
Responses Re: Additional SPI functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
In the event that my plpython3 patch does not make it, it seems prudent to try and get a *much* smaller patch in to
allowthe PL to easily exist out of core. 

I added a couple SPI functions in order to support the database access functionality in plpython3u. Also, a getelevel()
functionfor conditionally including context information due to error trapping awkwardness: 


extern int SPI_execute_statements(const char *src);

Execute multiple statements. Intended, primarily, for executing one or more DDL or DML statements. In contrast with the
otherexecution functions, the RPT loop plans and executes the statement before planning and executing the next in order
toallow subsequent statements to see the effects of all the formers. The read only argument is "omitted" as it should
onlybe used in read-write cases(you can't read anything out of it). 


extern SPIPlanPtr SPI_prepare_statement(
 const char *src, int cursorOptions,
 SPIParamCallback pcb, void *pcb_arg,
 TupleDesc *resultDesc);

Prepare a *single* statement and call the SPIParamCallback with the parameter information allowing the caller to store
theinformation and supply constant parameters based on the identified parameter types, if need be. Also, if it returns
rows,return the TupleDesc via *resultDesc. 

typedef void (*SPIParamCallback)(
 void *cb_data, const char *commandTag,
 int nargs, Oid *typoids, Datum **param_values, char **param_nulls);

Not at all in love with the callback, but it seemed desirable over using an intermediate structure that would require
someadditional management. 



Certainly, docs and tests will be necessary for this, but I'm sending it out now with the hopes of getting some
feedbackbefore sweating those tasks. 

The patch is attached for easy reference.
Any help would, of course, be greatly appreciated.

cheers



Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: LATERAL
Next
From: Tom Lane
Date:
Subject: Re: Additional SPI functions