In the event that my plpython3 patch does not make it, it seems prudent to try 
and get a *much* smaller patch in to allow the 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() function for 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 other execution functions, the RPT loop 
plans and executes the statement before planning and executing the next in 
order to allow subsequent statements to see the effects of all the formers. The 
read only argument is "omitted" as it should only be 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 the information 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 some additional management.



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

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

cheers


Attachment: spi.diff
Description: Binary data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to