From 093cbf519296ff262a534bbe912cafac477f5692 Mon Sep 17 00:00:00 2001 From: Jim Nasby Date: Wed, 5 Apr 2017 22:42:13 -0500 Subject: [PATCH 2/3] Add documentation for SPI_execute_callback --- doc/src/sgml/spi.sgml | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml index 86be87c0fd..901bb9cbb1 100644 --- a/doc/src/sgml/spi.sgml +++ b/doc/src/sgml/spi.sgml @@ -600,6 +600,124 @@ int SPI_exec(const char * command, long count< + + SPI_exececute_callback + + + SPI_execute_callback + 3 + + + + SPI_execute_callback + execute a read/write command + + + + +int SPI_execute_callback(const char * command, bool read_only, + long count, DestReceiver * callback) + + + + + Description + + + SPI_execute_callback is the same as + SPI_execute, except that instead of returning results + via SPITupleTable, the user-supplied callback + is used. Unlike + SPI_execute, + SPI_execute_callback + will run the callback for every SQL command passed in to command. + + + + The structure DestReceiver is defined + as: + +typedef struct _DestReceiver DestReceiver; + +struct _DestReceiver +{ + /* Called for each tuple to be output: */ + bool (*receiveSlot) (TupleTableSlot *slot, + DestReceiver *self); + /* Per-executor-run initialization and shutdown: */ + void (*rStartup) (DestReceiver *self, + int operation, + TupleDesc typeinfo); + void (*rShutdown) (DestReceiver *self); + /* Destroy the receiver object itself (if dynamically allocated) */ + void (*rDestroy) (DestReceiver *self); + /* CommandDest code for this receiver */ + CommandDest mydest; + /* Private fields might appear beyond this point... */ +}; + + + (*receiveSlot) is a function that is called for + every tuple generated. + + (*rStartup) and + (*rShutdown) are called when query execution + starts and finishes. Their use is optional. + + (*rDestroy) is called when the query execution + context is freed. If your DestReceiver dynamically + allocates memory, you can use (*rDestroy) to free + that memory. You should do this if DestReceiver is + created in a long-lived memory context. + + + + + Arguments + + + + const char * command + + + string containing command to execute + + + + + + long count + + + maximum number of rows to return, + or 0 for no limit + + + + + + DestReceiver callback + + + callback to be executed for each tuple generated by + command + + + + + + + + Return Value + + + See SPI_execute. + + + + + + SPI_execute_with_args -- 2.11.1