

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 支援的 PostgreSQL 擴充功能版本
<a name="PostgreSQL.Concepts.General.FeatureSupport.Extensions"></a>

RDS for PostgreSQL 支援許多 PostgreSQL 擴充功能。PostgreSQL 社群有時會將這些稱為模組。擴充功能可以擴充 PostgreSQL 引擎所提供的功能。您可以在該 PostgreSQL 版本的預設資料庫參數群組中找到 Amazon RDS 支援的延伸清單。您也可以使用 `psql` 來顯示 `rds.extensions` 參數，即可看到目前的延伸清單，如下列範例所示。

```
SHOW rds.extensions; 
```

**注意**  
在 `rds.extensions` 中使用 `psql` 參數時，次要版本中新增的參數可能不會正確顯示。

從 RDS for PostgreSQL 13 開始，某些擴充功能可由資料庫使用者安裝，而不是 `rds_superuser`。這些稱為*受信任的擴充功能*。如需詳細資訊，請參閱 [PostgreSQL 可信任延伸](#PostgreSQL.Concepts.General.Extensions.Trusted)。

特定 RDS for PostgreSQL 版本支援 `rds.allowed_extensions` 參數。此參數可讓 `rds_superuser` 限制 RDS for PostgreSQL 資料庫執行個體中安裝的擴充功能。如需詳細資訊，請參閱[限制安裝 PostgreSQL 擴充功能](#PostgreSQL.Concepts.General.FeatureSupport.Extensions.Restriction)。

如需有關 Amazon RDS 支援的 PostgreSQL 擴充功能的詳細清單，請參閱 *Amazon RDS for PostgreSQL 版本備註*中的 [Amazon RDS 上支援的 PostgreSQL 擴充功能](https://docs.aws.amazon.com/AmazonRDS/latest/PostgreSQLReleaseNotes/postgresql-extensions.html)。

## 限制安裝 PostgreSQL 擴充功能
<a name="PostgreSQL.Concepts.General.FeatureSupport.Extensions.Restriction"></a>

您可以限制 PostgreSQL 資料庫執行個體上能安裝哪些擴充功能。依預設，並未設定此參數，因此若使用者具有許可權限，則可新增任何受支援的擴充功能。若要執行這項操作，請將 `rds.allowed_extensions` 參數設定為逗號分隔的副檔名字串。將擴充功能清單新增至此參數，可明確識別 RDS for PostgreSQL 資料庫執行個體可使用的擴充功能。然後，只有這些擴充功能才能安裝在 PostgreSQL 資料庫執行個體中。

`rds.allowed_extensions` 參數的預設字串是 '\$1'，這表示可以安裝引擎版本可用的任何擴充功能。變更 `rds.allowed_extensions` 參數不需要重新啟動資料庫，因為它是動態參數。

PostgreSQL 資料庫執行個體引擎必須是下列其中一個版本，才能使用 `rds.allowed_extensions` 參數：
+ 所有 PostgreSQL 16 版本
+ PostgreSQL 15 和所有更高的版本
+ PostgreSQL 14 和所有更高的版本
+ PostgreSQL 13.3 和更高的次要版本
+ PostgreSQL 12.7 和更高的次要版本

 若要查看允許安裝哪些擴充功能，請使用下列 psql 命令。

```
postgres=> SHOW rds.allowed_extensions;
 rds.allowed_extensions
------------------------
 *
```

如果在將其排除於 `rds.allowed_extensions` 參數清單外之前已經安裝擴充功能，則擴充功能仍然可以正常使用，而且 `ALTER EXTENSION` 和 `DROP EXTENSION` 等命令將繼續運作。但是，在限制擴充功能之後，限制擴充功能的 `CREATE EXTENSION` 命令將會失敗。

`CREATE EXTENSION CASCADE` 擴充功能相依性的安裝也會受到限制。必須在 `rds.allowed_extensions` 中指定擴充功能及其相依性。如果擴充功能相依性安裝失敗，整個 `CREATE EXTENSION CASCADE` 陳述式將會失敗。

如果 `rds.allowed_extensions` 參數中未包含擴充功能，您會在嘗試安裝擴充功能時看到下列錯誤。

```
ERROR: permission denied to create extension "extension-name" 
HINT: This extension is not specified in "rds.allowed_extensions".
```

## PostgreSQL 可信任延伸
<a name="PostgreSQL.Concepts.General.Extensions.Trusted"></a>

若要安裝大多數 PostgreSQL 延伸，需要 `rds_superuser` 權限。PostgreSQL 13 推出了可信任擴充功能，這減少了向普通使用者授予 `rds_superuser` 權限的需求。使用此功能，使用者可以安裝許多延伸 (如果他們具有目前資料庫的 `CREATE` 權限而不是 `rds_superuser` 角色)。如需詳細資訊，請參閱 PostgreSQL 文件中的 SQL [CREATE EXTENSION](https://www.postgresql.org/docs/current/sql-createextension.html) 命令。

下面列出了具有目前資料庫 `CREATE` 權限但不需要 `rds_superuser` 角色的使用者可以安裝的延伸：
+ bool\$1plperl
+ [btree\$1gin](http://www.postgresql.org/docs/current/btree-gin.html)
+ [btree\$1gist](http://www.postgresql.org/docs/current/btree-gist.html)
+ [citext ](http://www.postgresql.org/docs/current/citext.html)
+ [cube ](http://www.postgresql.org/docs/current/cube.html)
+ [ dict\$1int ](http://www.postgresql.org/docs/current/dict-int.html)
+ [fuzzystrmatch](http://www.postgresql.org/docs/current/fuzzystrmatch.html)
+  [hstore](http://www.postgresql.org/docs/current/hstore.html)
+ [ intarray](http://www.postgresql.org/docs/current/intarray.html)
+ [isn ](http://www.postgresql.org/docs/current/isn.html)
+ jsonb\$1plperl
+ [ltree ](http://www.postgresql.org/docs/current/ltree.html)
+ [pg\$1trgm](http://www.postgresql.org/docs/current/pgtrgm.html)
+ [pgcrypto](http://www.postgresql.org/docs/current/pgcrypto.html)
+ [ plperl](https://www.postgresql.org/docs/current/plperl.html)
+ [ plpgsql](https://www.postgresql.org/docs/current/plpgsql.html)
+ [ pltcl](https://www.postgresql.org/docs/current/pltcl-overview.html)
+ [tablefunc](http://www.postgresql.org/docs/current/tablefunc.html) 
+ [ tsm\$1system\$1rows](https://www.postgresql.org/docs/current/tsm-system-rows.html)
+ [ tsm\$1system\$1time](https://www.postgresql.org/docs/current/tsm-system-time.html)
+ [unaccent ](http://www.postgresql.org/docs/current/unaccent.html)
+ [uuid-ossp](http://www.postgresql.org/docs/current/uuid-ossp.html)

如需有關 Amazon RDS 支援的 PostgreSQL 擴充功能的詳細清單，請參閱 *Amazon RDS for PostgreSQL 版本備註*中的 [Amazon RDS 上支援的 PostgreSQL 擴充功能](https://docs.aws.amazon.com/AmazonRDS/latest/PostgreSQLReleaseNotes/postgresql-extensions.html)。