pg_variables
提供标量、数组和记录类型的会话变量
pg_variables · 提供标量、数组和记录类型的会话变量
概览
| ID | 扩展 | 软件包 | 版本 | 类别 | 许可证 | 编程语言 |
|---|---|---|---|---|---|---|
| 2820 | pg_variables | pg_variables | 1.2.5 | FEAT | PostgreSQL | C |
| 属性 | 可执行文件 | 动态库 | 需要预加载 | 需要建扩展 | 可迁移 | 可信 |
|---|---|---|---|---|---|---|
| --s-d-r | 否 | 是 | 否 | 是 | 是 | 否 |
SQL 1.2. PG19 RPM uses a patch.
软件包
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| el8.aarch64 | N/A | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| el9.x86_64 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| el9.aarch64 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| el10.x86_64 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| el10.aarch64 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| d12.x86_64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| d12.aarch64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| d13.x86_64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| d13.aarch64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| u22.x86_64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| u22.aarch64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| u24.x86_64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| u24.aarch64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| u26.x86_64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| u26.aarch64 | MISS | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 | PIGSTY 1.2.5 |
| 软件包 | 版本 | 平台 | 仓库 | 大小 | 下载 |
|---|---|---|---|---|---|
pg_variables_19 | 1.2.5 | el9.x86_64 | pigsty | 72.7 KiB | pg_variables_19-1.2.5-2PGSTY.el9.x86_64.rpm |
pg_variables_19 | 1.2.5 | el9.aarch64 | pigsty | 72.1 KiB | pg_variables_19-1.2.5-2PGSTY.el9.aarch64.rpm |
pg_variables_19 | 1.2.5 | el10.x86_64 | pigsty | 73.4 KiB | pg_variables_19-1.2.5-2PGSTY.el10.x86_64.rpm |
pg_variables_19 | 1.2.5 | el10.aarch64 | pigsty | 73.0 KiB | pg_variables_19-1.2.5-2PGSTY.el10.aarch64.rpm |
源码
安装
在数据库中创建扩展。
用法
pg_variables 提供按名称 package 分组的会话级变量。变量只存在于当前 session;除非创建时指定 is_transactional := true,否则默认不参与事务。
基本读写
事务性变量会参与 savepoint 和 rollback:
核心 API
README 记录了通用标量与数组 API:
pgv_set(package, name, value, is_transactional default false)pgv_get(package, name, NULL::type, strict default true)
同时也记录了面向 record 的 API:
pgv_insert()pgv_update()pgv_delete()pgv_select()
常用的管理辅助函数包括 pgv_exists()、pgv_remove()、pgv_free()、pgv_list() 和 pgv_stats()。
错误与 strict 行为
pgv_get() 会同时检查变量是否存在以及类型是否匹配。README 展示了 package 不存在、变量不存在或类型不匹配时会抛错;如果指定 strict := false,则在值缺失时返回 NULL。
已废弃辅助函数与版本说明
上游仍然提供一些已废弃的类型专用辅助函数,例如 pgv_set_int() / pgv_get_int() 和 pgv_set_jsonb() / pgv_get_jsonb(),但推荐使用通用的 pgv_set() / pgv_get()。
仓库 tag 已到 v1.2.5,而当前 pg_variables.control 仍声明 default_version = '1.2'。这与打包说明一致,即 release tag 已前进,但 SQL 扩展版本字符串没有同步变更。