SPI_cursor_open_with_args

SPI_cursor_open_with_args —使用查询和参数设置游标

Synopsis

Portal SPI_cursor_open_with_args(const char *name,
                                 const char *command,
                                 int nargs, Oid *argtypes,
                                 Datum *values, const char *nulls,
                                 bool read_only, int cursorOptions)

Description

SPI_cursor_open_with_args设置一个游标(内部是门户),它将执行指定的查询。大多数参数与SPI_prepare_cursorSPI_cursor_open的相应参数具有相同的含义。

对于一次性查询执行,应优先于SPI_prepare_cursorSPI_cursor_open优先使用此功能。如果要使用许多不同的参数执行同一命令,则根据重新计划的成本与自定义计划的优势,这两种方法可能会更快。

传入的参数数据将被复制到游标的门户中,因此可以在游标仍然存在时将其释放。

Arguments

  • const char * name

    • 门户的名称,或NULL以让系统选择名称
  • const char * command

    • command string
  • int nargs

    • Importing 参数的数量($1$2等)
  • Oid * argtypes

    • 长度* nargs *的数组,其中包含参数的数据类型的 OID
  • Datum * values

    • 一个长度* nargs *的数组,其中包含实际参数值
  • const char * nulls

    • 长度* nargs *的数组,描述哪些参数为空

如果* nulls NULL,则SPI_cursor_open_with_args假定没有参数为空。否则,如果相应的参数值非空,则 nulls 数组的每个条目应为' ',如果相应的参数值为空,则应为'n'。 (在后一种情况下,相应的 values 条目中的实际值无关紧要.)请注意, nulls *不是文本字符串,而只是数组:它不需要'\0'终止符。

  • bool read_only

    • true用于只读执行
  • int cursorOptions

    • 游标选项的整数位掩码;零产生默认行为

Return Value

指向包含光标的门户的指针。注意没有错误返回约定。任何错误将通过elog报告。