Postgresql 中文操作指南

SPI_prepare_extended

SPI_prepare_extended — 准备语句而不执行

SPI_prepare_extended — prepare a statement, without executing it yet

Synopsis

SPIPlanPtr SPI_prepare_extended(const char * command,
                                const SPIPrepareOptions * options)

Description

SPI_prepare_extended 针对指定命令创建并返回一个已准备的语句,但不会执行该命令。此函数相当于 SPI_prepare ,此外,调用方还可以指定选项来控制对外部参数引用的解析以及查询解析和规划的其他方面。

SPI_prepare_extended creates and returns a prepared statement for the specified command, but doesn’t execute the command. This function is equivalent to SPI_prepare, with the addition that the caller can specify options to control the parsing of external parameter references, as well as other facets of query parsing and planning.

Arguments

  • const char * _command_

    • command string

  • const SPIPrepareOptions * _options_

    • struct containing optional arguments

调用者应始终将整个 options 结构清零,然后填写任何他们想要设置的字段。这样可以确保代码的前向兼容性,因为将来添加到结构中的任何字段都被定义为在为零时向后兼容地工作。当前可用的 options 字段为:

Callers should always zero out the entire options struct, then fill whichever fields they want to set. This ensures forward compatibility of code, since any fields that are added to the struct in future will be defined to behave backwards-compatibly if they are zero. The currently available options fields are:

  • ParserSetupHook _parserSetup_

    • Parser hook setup function

  • void * _parserSetupArg_

    • pass-through argument for parserSetup

  • RawParseMode _parseMode_

    • mode for raw parsing; RAW_PARSE_DEFAULT (zero) produces default behavior

  • int _cursorOptions_

    • integer bit mask of cursor options; zero produces default behavior

Return Value

SPI_prepare_extended 具有与 SPI_prepare 相同的返回约定。

SPI_prepare_extended has the same return conventions as SPI_prepare.