> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/server-programming/spi/spi-interface.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 45.1. 介面函式 \#

### 45.1. 介面函式 [#](#spi-interface) <a href="#spi-interface" id="spi-interface"></a>

[SPI\_connect](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-connect.md) — 將 C 函式連線到 SPI 管理器

[SPI\_finish](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-finish.md) — 中斷 C 函式與 SPI 管理器的連線

[SPI\_execute](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-execute.md) — 執行一個指令

[SPI\_exec](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-exec.md) — 執行一個讀寫指令

[SPI\_execute\_extended](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-execute-extended.md) — 以外部（out-of-line）參數執行指令

[SPI\_execute\_with\_args](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-execute-with-args.md) — 以外部（out-of-line）參數執行指令

[SPI\_prepare](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-prepare.md) — 預備一個陳述式，但尚未執行它

[SPI\_prepare\_cursor](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-prepare-cursor.md) — 預備一個陳述式，但尚未執行它

[SPI\_prepare\_extended](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-prepare-extended.md) — 預備一個陳述式，但尚未執行它

[SPI\_prepare\_params](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-prepare-params.md) — 預備一個陳述式，但尚未執行它

[SPI\_getargcount](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-getargcount.md) — 回傳由 `SPI_prepare` 所預備之陳述式需要的引數個數

[SPI\_getargtypeid](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-getargtypeid.md) — 回傳由 `SPI_prepare` 所預備之陳述式某個引數的資料型別 OID

[SPI\_is\_cursor\_plan](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-is-cursor-plan.md) — 若由 `SPI_prepare` 所預備的陳述式可搭配 `SPI_cursor_open` 使用，則回傳 `true`

[SPI\_execute\_plan](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-execute-plan.md) — 執行由 `SPI_prepare` 預備好的陳述式

[SPI\_execute\_plan\_extended](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-execute-plan-extended.md) — 執行由 `SPI_prepare` 預備好的陳述式

[SPI\_execute\_plan\_with\_paramlist](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-execute-plan-with-paramlist.md) — 執行由 `SPI_prepare` 預備好的陳述式

[SPI\_execp](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-execp.md) — 以讀寫模式執行陳述式

[SPI\_cursor\_open](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-cursor-open.md) — 使用以 `SPI_prepare` 建立的陳述式設定一個游標

[SPI\_cursor\_open\_with\_args](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-cursor-open-with-args.md) — 使用一個查詢與參數設定一個游標

[SPI\_cursor\_open\_with\_paramlist](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-cursor-open-with-paramlist.md) — 使用參數設定一個游標

[SPI\_cursor\_parse\_open](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-cursor-parse-open.md) — 使用一個查詢字串與參數設定一個游標

[SPI\_cursor\_find](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-cursor-find.md) — 依名稱尋找既有的游標

[SPI\_cursor\_fetch](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-cursor-fetch.md) — 從游標取回若干資料列

[SPI\_cursor\_move](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-cursor-move.md) — 移動游標

[SPI\_scroll\_cursor\_fetch](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-scroll-cursor-fetch.md) — 從游標取回若干資料列

[SPI\_scroll\_cursor\_move](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-scroll-cursor-move.md) — 移動游標

[SPI\_cursor\_close](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-cursor-close.md) — 關閉一個游標

[SPI\_keepplan](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-keepplan.md) — 儲存一個預備陳述式

[SPI\_saveplan](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-saveplan.md) — 儲存一個預備陳述式

[SPI\_register\_relation](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-register-relation.md) — 讓一個暫時性具名關聯可在 SPI 查詢中以名稱使用

[SPI\_unregister\_relation](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-unregister-relation.md) — 將一個暫時性具名關聯從註冊表中移除

[SPI\_register\_trigger\_data](https://docs.postgresql.tw/19/server-programming/spi/spi-interface/spi-spi-register-trigger-data.md) — 讓暫時性的觸發程序資料可在 SPI 查詢中使用

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/spi-interface.html)（原文版本：18.6；核對日期：2026-09-13）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/server-programming/spi/spi-interface.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
