SPI_execute_plan_with_receiver

SPI_execute_plan_with_receiver — execute a statement prepared by SPI_prepare

Synopsis

int SPI_execute_plan_with_receiver(SPIPlanPtr plan,
                                   ParamListInfo params,
                                   bool read_only,
                                   long count,
                                   DestReceiver *dest)

Description

SPI_execute_plan_with_receiver executes a statement prepared by SPI_prepare. This function is equivalent to SPI_execute_plan_with_paramlist except that, instead of always accumulating the result tuples into a SPI_tuptable structure, tuples can be passed to a caller-supplied DestReceiver object as they are generated by the executor. This is particularly helpful for queries that might generate many tuples, since the data can be processed on-the-fly instead of being accumulated in memory.

Arguments

SPIPlanPtr plan

prepared statement (returned by SPI_prepare)

ParamListInfo params

data structure containing parameter types and values; NULL if none

bool read_only

true for read-only execution

long count

maximum number of rows to return, or 0 for no limit

DestReceiver * dest

DestReceiver object that will receive any tuples emitted by the query; if NULL, this function is exactly equivalent to SPI_execute_plan_with_paramlist

Return Value

The return value is the same as for SPI_execute_plan.

When dest is NULL, SPI_processed and SPI_tuptable are set as in SPI_execute_plan. When dest is not NULL, SPI_processed is set to zero and SPI_tuptable is set to NULL. If a tuple count is required, the caller's DestReceiver object must calculate it.