Additional SPI functions

From: James William Pye <lists(at)jwp(dot)name>
To: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Additional SPI functions
Date: 2009-12-20 06:45:07
Message-ID: 5B8B33BF-4FE1-410A-AE75-9AA1E341DD0C@jwp.name
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 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 Content-Type Size
spi.diff application/octet-stream 11.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-12-20 07:03:14 Re: Additional SPI functions
Previous Message Tom Lane 2009-12-20 05:45:00 Re: LATERAL