SPI_execute_plan — 执行由 SPI_prepare
准备的语句
int SPI_execute_plan(SPIPlanPtrplan
, Datum *values
, const char *nulls
, boolread_only
, longcount
)
SPI_execute_plan
执行由 SPI_prepare
或其相邻函数准备的语句。read_only
和 count
具有与 SPI_execute
相同的解释。
SPIPlanPtr plan
准备好的语句(由 SPI_prepare
返回)
Datum * values
实际参数值的数组。必须与语句参数数量相同。
const char * nulls
描述哪个参数为 null 的数组。必须与语句参数数量相同。
如果 nulls
为 NULL
,则 SPI_execute_plan
假设没有 null 参数。否则,nulls
数组的各个条目应为 ' '
(如果相应的参数值非 null)或 'n'
(如果相应的参数值 null)。(在后一种情况下,values
条目中实际的值无关紧要。)请注意,nulls
不是文本字符串,而仅仅是一个数组:它不需要 '\0'
结束符。
bool read_only
true
适用于只读执行
long count
要返回的最大行数,或 0
表示无限制
返回值与 SPI_execute
相同,有以下可能的错误(负值)结果
SPI_ERROR_ARGUMENT
如果 plan
为 NULL
或无效,或 count
小于 0
SPI_ERROR_PARAM
如果 values
为 NULL
而 plan
是用某些参数准备的
如果成功,SPI_processed 和 SPI_tuptable 会像在 SPI_execute
中一样设置。