> 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/internals/catalogs/catalog-pg-proc.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 52.39. pg\_proc \#

### 52.39. `pg_proc` [#](#catalog-pg-proc) <a href="#catalog-pg-proc" id="catalog-pg-proc"></a>

目錄 `pg_proc` 儲存函式、程序、彙總函式與視窗函式 （也統稱為常式）的相關資訊。更多資訊請參閱 [CREATE FUNCTION](https://docs.postgresql.tw/19/reference/sql-commands/sql-createfunction.md)、[CREATE PROCEDURE](https://docs.postgresql.tw/19/reference/sql-commands/sql-createprocedure.md) 與 [第 36.3 節](https://docs.postgresql.tw/19/server-programming/extend/xfunc.md)。

若 `prokind` 指出該項目是彙總函式，則 [`pg_aggregate`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-aggregate.md) 中應該有一筆相符的資料列。

#### 表 52.39. `pg_proc` 欄位 [#](#catalog-pg-proc-columns) <a href="#catalog-pg-proc-columns" id="catalog-pg-proc-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>oid</code> <code>oid</code></p><p>資料列識別碼</p>                                                                                                                                                                                                                                                                                                                                                      |
| <p><code>proname</code> <code>name</code></p><p>函式名稱</p>                                                                                                                                                                                                                                                                                                                                                   |
| <p><code>pronamespace</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-namespace.md"><code>pg\_namespace</code></a>.<code>oid</code>）</p><p>包含此函式之命名空間的 OID</p>                                                                                                                                                                                            |
| <p><code>proowner</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-authid.md"><code>pg\_authid</code></a>.<code>oid</code>）</p><p>此函式的擁有者</p>                                                                                                                                                                                                              |
| <p><code>prolang</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-language.md"><code>pg\_language</code></a>.<code>oid</code>）</p><p>此函式的實作語言或呼叫介面</p>                                                                                                                                                                                                     |
| <p><code>procost</code> <code>float4</code></p><p>估計的執行成本（以 <a href="https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-query.md#GUC-CPU-OPERATOR-COST">cpu\_operator\_cost</a> 為單位）；若為 <code>proretset</code>， 則為每個傳回資料列的成本</p>                                                                                                                                            |
| <p><code>prorows</code> <code>float4</code></p><p>估計的結果資料列數（若非 <code>proretset</code> 則為零）</p>                                                                                                                                                                                                                                                                                                             |
| <p><code>provariadic</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-type.md"><code>pg\_type</code></a>.<code>oid</code>）</p><p>可變參數陣列參數之元素的資料型別； 若函式沒有可變參數，則為零</p>                                                                                                                                                                                       |
| <p><code>prosupport</code> <code>regproc</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-proc.md"><code>pg\_proc</code></a>.<code>oid</code>）</p><p>此函式的規劃器支援函式 （請參閱<a href="https://docs.postgresql.tw/19/server-programming/extend/xfunc-optimization.md">第 36.11 節</a>）；若無則為零</p>                                                                                       |
| <p><code>prokind</code> <code>char</code></p><p><code>f</code> 表示一般函式，<code>p</code> 表示程序，<code>a</code> 表示彙總函式，或 <code>w</code> 表示視窗函式</p>                                                                                                                                                                                                                                                                |
| <p><code>prosecdef</code> <code>bool</code></p><p>函式是安全性定義者（security definer，即 “setuid” 函式）</p>                                                                                                                                                                                                                                                                                                            |
| <p><code>proleakproof</code> <code>bool</code></p><p>此函式沒有副作用。除了透過傳回值之外，不會傳遞任何關於 引數的資訊。任何可能依其引數的值而擲出錯誤的函式 都不是 leakproof（防洩漏）的。</p>                                                                                                                                                                                                                                                                         |
| <p><code>proisstrict</code> <code>bool</code></p><p>若任何呼叫引數為 null，函式即傳回 null。在這種情況下， 函式實際上完全不會被呼叫。不是 “strict” 的函式 必須能夠處理 null 輸入。</p>                                                                                                                                                                                                                                                                      |
| <p><code>proretset</code> <code>bool</code></p><p>函式傳回一個集合（即指定資料型別的多個值）</p>                                                                                                                                                                                                                                                                                                                                |
| <p><code>provolatile</code> <code>char</code></p><p><code>provolatile</code> 指出函式的結果是只取決於 其輸入引數，還是會受外部因素影響。 <code>i</code> 表示 “immutable” 函式， 對相同的輸入一律產生相同的結果。 <code>s</code> 表示 “stable” 函式， 其結果（在輸入固定時）在單次掃描內不會改變。 <code>v</code> 表示 “volatile” 函式， 其結果可能隨時改變。（有副作用的函式也請使用 <code>v</code>， 使對它們的呼叫不會被最佳化掉。）</p>                                                                                          |
| <p><code>proparallel</code> <code>char</code></p><p><code>proparallel</code> 指出函式 是否可以在平行模式下安全執行。 <code>s</code> 表示可在平行模式下 不受限制地安全執行的函式。 <code>r</code> 表示可在平行模式下執行、 但其執行僅限於平行群組領導程序的函式； 平行工作程序不能呼叫這些函式。 <code>u</code> 表示在平行模式下不安全的函式； 只要存在這類函式，就會強制採用序列執行計畫。</p>                                                                                                                                         |
| <p><code>pronargs</code> <code>int2</code></p><p>輸入引數的數量</p>                                                                                                                                                                                                                                                                                                                                               |
| <p><code>pronargdefaults</code> <code>int2</code></p><p>具有預設值的引數數量</p>                                                                                                                                                                                                                                                                                                                                     |
| <p><code>prorettype</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-type.md"><code>pg\_type</code></a>.<code>oid</code>）</p><p>傳回值的資料型別</p>                                                                                                                                                                                                               |
| <p><code>proargtypes</code> <code>oidvector</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-type.md"><code>pg\_type</code></a>.<code>oid</code>）</p><p>函式引數資料型別的陣列。此陣列只包含 輸入引數（包括 <code>INOUT</code> 與 <code>VARIADIC</code> 引數），因此代表 函式的呼叫簽章。</p>                                                                                                                         |
| <p><code>proallargtypes</code> <code>oid\[]</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-type.md"><code>pg\_type</code></a>.<code>oid</code>）</p><p>函式引數資料型別的陣列。此陣列包含 所有引數（包括 <code>OUT</code> 與 <code>INOUT</code> 引數）；不過，若所有 引數都是 <code>IN</code> 引數，此欄位為 null。 請注意，此陣列的下標從 1 起算，而因歷史因素， <code>proargtypes</code> 的下標從 0 起算。</p>                                      |
| <p><code>proargmodes</code> <code>char\[]</code></p><p>函式引數模式的陣列，編碼方式為： <code>i</code> 表示 <code>IN</code> 引數、 <code>o</code> 表示 <code>OUT</code> 引數、 <code>b</code> 表示 <code>INOUT</code> 引數、 <code>v</code> 表示 <code>VARIADIC</code> 引數、 <code>t</code> 表示 <code>TABLE</code> 引數。 若所有引數都是 <code>IN</code> 引數， 此欄位為 null。 請注意，下標對應的是 <code>proallargtypes</code> 的位置，而不是 <code>proargtypes</code> 的位置。</p> |
| <p><code>proargnames</code> <code>text\[]</code></p><p>函式引數名稱的陣列。 沒有名稱的引數在陣列中設為空字串。 若所有引數都沒有名稱，此欄位為 null。 請注意，下標對應的是 <code>proallargtypes</code> 的位置，而不是 <code>proargtypes</code> 的位置。</p>                                                                                                                                                                                                                 |
| <p><code>proargdefaults</code> <code>pg\_node\_tree</code></p><p>預設值的運算式樹（以 <code>nodeToString()</code> 表示法呈現）。 這是一個含有 <code>pronargdefaults</code> 個元素的串列，對應最後 <em><code>N</code></em> 個<em>輸入</em>引數（即最後 <em><code>N</code></em> 個 <code>proargtypes</code> 位置）。 若所有引數都沒有預設值，此欄位為 null。</p>                                                                                                              |
| <p><code>protrftypes</code> <code>oid\[]</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-type.md"><code>pg\_type</code></a>.<code>oid</code>）</p><p>要套用轉換（transform）的引數／結果資料型別陣列 （取自函式的 <code>TRANSFORM</code> 子句）。若無則為 null。</p>                                                                                                                                          |
| <p><code>prosrc</code> <code>text</code></p><p>此欄位告訴函式處理器如何呼叫該函式。依實作語言／呼叫慣例而定， 它可能是直譯式語言中函式的實際原始碼、連結符號、檔案名稱， 或幾乎任何其他內容。</p>                                                                                                                                                                                                                                                                                |
| <p><code>probin</code> <code>text</code></p><p>關於如何呼叫該函式的附加資訊。 同樣地，其解讀方式取決於語言。</p>                                                                                                                                                                                                                                                                                                                         |
| <p><code>prosqlbody</code> <code>pg\_node\_tree</code></p><p>預先剖析的 SQL 函式主體。當 SQL 語言函式的主體 以 SQL 標準寫法提供、而不是以字串常值提供時， 會使用此欄位。其他情況下為 null。</p>                                                                                                                                                                                                                                                                |
| <p><code>proconfig</code> <code>text\[]</code></p><p>函式針對執行期設定變數的區域設定值</p>                                                                                                                                                                                                                                                                                                                                 |
| <p><code>proacl</code> <code>aclitem\[]</code></p><p>存取權限；詳細資訊請參閱<a href="https://docs.postgresql.tw/19/the-sql-language/ddl/ddl-priv.md">第 5.8 節</a></p>                                                                                                                                                                                                                                                  |

<br>

對於編譯式函式（包括內建與動態載入的函式）， `prosrc` 包含函式的 C 語言 名稱（連結符號）。 對於 SQL 語言函式，若原始碼是以字串常值指定，`prosrc` 包含 函式的原始碼文字； 但若函式主體是以 SQL 標準風格指定，則不使用 `prosrc`（通常為空字串），而由 `prosqlbody` 包含 預先剖析的定義。 對於其他所有目前已知的語言類型， `prosrc` 包含函式的原始碼 文字。除了動態載入的 C 函式之外，`probin` 都是 null； 對於動態載入的 C 函式，它提供包含該函式的 共享程式庫檔案名稱。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/catalog-pg-proc.html)（原文版本：18.6；核對日期：2026-10-17）


---

# 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/internals/catalogs/catalog-pg-proc.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.
