SPI_cursor_open_with_args — 使用查詢和引數設定遊標
Portal SPI_cursor_open_with_args(const char *name
, const char *command
, intnargs
, Oid *argtypes
, Datum *values
, const char *nulls
, boolread_only
, intcursorOptions
)
SPI_cursor_open_with_args
設定一個遊標(內部稱為 portal),它將執行指定的查詢。大多數引數的含義與 SPI_prepare_cursor
和 SPI_cursor_open
的相應引數相同。
對於一次性查詢執行,此函式應優先於 SPI_prepare_cursor
後跟 SPI_cursor_open
。如果同一個命令要用許多不同的引數執行,則取決於重新規劃的成本與自定義計劃的好處,這兩種方法可能都更快。
傳入的引數資料將被複制到遊標的 portal 中,因此可以在遊標仍然存在時釋放這些資料。
此函式現已棄用,推薦使用 SPI_cursor_parse_open
,它使用更現代的引數查詢處理 API 提供等效功能。
const char * name
portal 的名稱,如果為 NULL
,則由系統選擇名稱
const char * command
command string
int nargs
輸入引數的數量($1
、$2
等)
Oid * argtypes
長度為 nargs
的陣列,包含OID引數的資料型別
Datum * values
長度為 nargs
的陣列,包含實際引數值
const char * nulls
長度為 nargs
的陣列,描述哪些引數為 null
如果 nulls
為 NULL
,則 SPI_cursor_open_with_args
假定沒有引數為 null。否則,nulls
陣列的每個條目都應該是 ' '
(如果相應的引數值非 null),或者 'n'
(如果相應的引數值是 null)。(後一種情況,values
條目中的實際值無關緊要。)請注意,nulls
不是文字字串,只是一個數組:它不需要 '\0'
終止符。
bool read_only
只讀執行時為 true
int cursorOptions
遊標選項的整數位掩碼;零會產生預設行為
指向包含遊標的 portal 的指標。請注意,沒有錯誤返回約定;任何錯誤都將透過 elog
報告。
如果您在文件中發現任何不正確、與您對特定功能的體驗不符或需要進一步說明的內容,請使用 此表格 報告文件問題。