session_variable
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
session_variable | 3.6 | SIM | GPL-3.0 | C |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 9120 | session_variable | 否 | 是 | 否 | 是 | 否 | 否 | session_variable |
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PIGSTY | 3.6 | 1817161514 | session_variable | - |
| RPM | PIGSTY | 3.6 | 1817161514 | session_variable_$v | - |
| DEB | PIGSTY | 3.6 | 1817161514 | postgresql-$v-session-variable | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 3.6 el8.x86_64.pg18 : session_variable_18 session_variable_18-3.6-1PGSTY.el8.x86_64.rpm
| PIGSTY 3.6 el8.x86_64.pg17 : session_variable_17 session_variable_17-3.6-1PGSTY.el8.x86_64.rpm
| PIGSTY 3.6 el8.x86_64.pg16 : session_variable_16 session_variable_16-3.6-1PGSTY.el8.x86_64.rpm
| PIGSTY 3.6 el8.x86_64.pg15 : session_variable_15 session_variable_15-3.6-1PGSTY.el8.x86_64.rpm
| PIGSTY 3.6 el8.x86_64.pg14 : session_variable_14 session_variable_14-3.6-1PGSTY.el8.x86_64.rpm
|
| el8.aarch64 | PIGSTY 3.6 el8.aarch64.pg18 : session_variable_18 session_variable_18-3.6-1PGSTY.el8.aarch64.rpm
| PIGSTY 3.6 el8.aarch64.pg17 : session_variable_17 session_variable_17-3.6-1PGSTY.el8.aarch64.rpm
| PIGSTY 3.6 el8.aarch64.pg16 : session_variable_16 session_variable_16-3.6-1PGSTY.el8.aarch64.rpm
| PIGSTY 3.6 el8.aarch64.pg15 : session_variable_15 session_variable_15-3.6-1PGSTY.el8.aarch64.rpm
| PIGSTY 3.6 el8.aarch64.pg14 : session_variable_14 session_variable_14-3.6-1PGSTY.el8.aarch64.rpm
|
| el9.x86_64 | PIGSTY 3.6 el9.x86_64.pg18 : session_variable_18 session_variable_18-3.6-1PGSTY.el9.x86_64.rpm
| PIGSTY 3.6 el9.x86_64.pg17 : session_variable_17 session_variable_17-3.6-1PGSTY.el9.x86_64.rpm
| PIGSTY 3.6 el9.x86_64.pg16 : session_variable_16 session_variable_16-3.6-1PGSTY.el9.x86_64.rpm
| PIGSTY 3.6 el9.x86_64.pg15 : session_variable_15 session_variable_15-3.6-1PGSTY.el9.x86_64.rpm
| PIGSTY 3.6 el9.x86_64.pg14 : session_variable_14 session_variable_14-3.6-1PGSTY.el9.x86_64.rpm
|
| el9.aarch64 | PIGSTY 3.6 el9.aarch64.pg18 : session_variable_18 session_variable_18-3.6-1PGSTY.el9.aarch64.rpm
| PIGSTY 3.6 el9.aarch64.pg17 : session_variable_17 session_variable_17-3.6-1PGSTY.el9.aarch64.rpm
| PIGSTY 3.6 el9.aarch64.pg16 : session_variable_16 session_variable_16-3.6-1PGSTY.el9.aarch64.rpm
| PIGSTY 3.6 el9.aarch64.pg15 : session_variable_15 session_variable_15-3.6-1PGSTY.el9.aarch64.rpm
| PIGSTY 3.6 el9.aarch64.pg14 : session_variable_14 session_variable_14-3.6-1PGSTY.el9.aarch64.rpm
|
| el10.x86_64 | PIGSTY 3.6 el10.x86_64.pg18 : session_variable_18 session_variable_18-3.6-1PGSTY.el10.x86_64.rpm
| PIGSTY 3.6 el10.x86_64.pg17 : session_variable_17 session_variable_17-3.6-1PGSTY.el10.x86_64.rpm
| PIGSTY 3.6 el10.x86_64.pg16 : session_variable_16 session_variable_16-3.6-1PGSTY.el10.x86_64.rpm
| PIGSTY 3.6 el10.x86_64.pg15 : session_variable_15 session_variable_15-3.6-1PGSTY.el10.x86_64.rpm
| PIGSTY 3.6 el10.x86_64.pg14 : session_variable_14 session_variable_14-3.6-1PGSTY.el10.x86_64.rpm
|
| el10.aarch64 | PIGSTY 3.6 el10.aarch64.pg18 : session_variable_18 session_variable_18-3.6-1PGSTY.el10.aarch64.rpm
| PIGSTY 3.6 el10.aarch64.pg17 : session_variable_17 session_variable_17-3.6-1PGSTY.el10.aarch64.rpm
| PIGSTY 3.6 el10.aarch64.pg16 : session_variable_16 session_variable_16-3.6-1PGSTY.el10.aarch64.rpm
| PIGSTY 3.6 el10.aarch64.pg15 : session_variable_15 session_variable_15-3.6-1PGSTY.el10.aarch64.rpm
| PIGSTY 3.6 el10.aarch64.pg14 : session_variable_14 session_variable_14-3.6-1PGSTY.el10.aarch64.rpm
|
| d12.x86_64 | PIGSTY 3.6 d12.x86_64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~bookworm_amd64.deb
| PIGSTY 3.6 d12.x86_64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~bookworm_amd64.deb
| PIGSTY 3.6 d12.x86_64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~bookworm_amd64.deb
| PIGSTY 3.6 d12.x86_64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~bookworm_amd64.deb
| PIGSTY 3.6 d12.x86_64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~bookworm_amd64.deb
|
| d12.aarch64 | PIGSTY 3.6 d12.aarch64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~bookworm_arm64.deb
| PIGSTY 3.6 d12.aarch64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~bookworm_arm64.deb
| PIGSTY 3.6 d12.aarch64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~bookworm_arm64.deb
| PIGSTY 3.6 d12.aarch64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~bookworm_arm64.deb
| PIGSTY 3.6 d12.aarch64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~bookworm_arm64.deb
|
| d13.x86_64 | PIGSTY 3.6 d13.x86_64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~trixie_amd64.deb
| PIGSTY 3.6 d13.x86_64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~trixie_amd64.deb
| PIGSTY 3.6 d13.x86_64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~trixie_amd64.deb
| PIGSTY 3.6 d13.x86_64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~trixie_amd64.deb
| PIGSTY 3.6 d13.x86_64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~trixie_amd64.deb
|
| d13.aarch64 | PIGSTY 3.6 d13.aarch64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~trixie_arm64.deb
| PIGSTY 3.6 d13.aarch64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~trixie_arm64.deb
| PIGSTY 3.6 d13.aarch64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~trixie_arm64.deb
| PIGSTY 3.6 d13.aarch64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~trixie_arm64.deb
| PIGSTY 3.6 d13.aarch64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~trixie_arm64.deb
|
| u22.x86_64 | PIGSTY 3.6 u22.x86_64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~jammy_amd64.deb
| PIGSTY 3.6 u22.x86_64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~jammy_amd64.deb
| PIGSTY 3.6 u22.x86_64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~jammy_amd64.deb
| PIGSTY 3.6 u22.x86_64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~jammy_amd64.deb
| PIGSTY 3.6 u22.x86_64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~jammy_amd64.deb
|
| u22.aarch64 | PIGSTY 3.6 u22.aarch64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~jammy_arm64.deb
| PIGSTY 3.6 u22.aarch64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~jammy_arm64.deb
| PIGSTY 3.6 u22.aarch64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~jammy_arm64.deb
| PIGSTY 3.6 u22.aarch64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~jammy_arm64.deb
| PIGSTY 3.6 u22.aarch64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~jammy_arm64.deb
|
| u24.x86_64 | PIGSTY 3.6 u24.x86_64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~noble_amd64.deb
| PIGSTY 3.6 u24.x86_64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~noble_amd64.deb
| PIGSTY 3.6 u24.x86_64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~noble_amd64.deb
| PIGSTY 3.6 u24.x86_64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~noble_amd64.deb
| PIGSTY 3.6 u24.x86_64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~noble_amd64.deb
|
| u24.aarch64 | PIGSTY 3.6 u24.aarch64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~noble_arm64.deb
| PIGSTY 3.6 u24.aarch64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~noble_arm64.deb
| PIGSTY 3.6 u24.aarch64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~noble_arm64.deb
| PIGSTY 3.6 u24.aarch64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~noble_arm64.deb
| PIGSTY 3.6 u24.aarch64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~noble_arm64.deb
|
| u26.x86_64 | PIGSTY 3.6 u26.x86_64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~resolute_amd64.deb
| PIGSTY 3.6 u26.x86_64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~resolute_amd64.deb
| PIGSTY 3.6 u26.x86_64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~resolute_amd64.deb
| PIGSTY 3.6 u26.x86_64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~resolute_amd64.deb
| PIGSTY 3.6 u26.x86_64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~resolute_amd64.deb
|
| u26.aarch64 | PIGSTY 3.6 u26.aarch64.pg18 : postgresql-18-session-variable postgresql-18-session-variable_3.6-1PGSTY~resolute_arm64.deb
| PIGSTY 3.6 u26.aarch64.pg17 : postgresql-17-session-variable postgresql-17-session-variable_3.6-1PGSTY~resolute_arm64.deb
| PIGSTY 3.6 u26.aarch64.pg16 : postgresql-16-session-variable postgresql-16-session-variable_3.6-1PGSTY~resolute_arm64.deb
| PIGSTY 3.6 u26.aarch64.pg15 : postgresql-15-session-variable postgresql-15-session-variable_3.6-1PGSTY~resolute_arm64.deb
| PIGSTY 3.6 u26.aarch64.pg14 : postgresql-14-session-variable postgresql-14-session-variable_3.6-1PGSTY~resolute_arm64.deb
|
构建
您可以使用 pig build 命令构建 session_variable 扩展的 RPM / DEB 包:
安装
您可以直接安装 session_variable 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
使用 pig 或者是 apt/yum/dnf 安装扩展:
创建扩展:
用法
来源:
session_variable 定义数据库级变量和常量,并为每个会话保存独立的值。修改会话本地值不会影响其他连接。
创建变量和常量
获取和设置值
在 PL/pgSQL 中使用
管理函数
关键行为
- 变量在数据库级别定义;每个会话获取本地副本
set()仅更改会话本地副本;其他会话不受影响alter_value()更改存储的值;新会话将看到它,现有会话需要init()来刷新- 常量不能通过
set()更改,只能通过alter_value() - 变量和常量名称在两种类型之间必须唯一
权限、读取与版本边界
由超级用户在 session_variable 模式中安装这个不可重定位的扩展;上述 SQL 工作流无需共享预加载或重启。管理定义应授予 session_variable_administrator_role,普通访问应授予 session_variable_user_role。管理员角色包含用户角色。
session_variable.set 和 session_variable.alter_value 成功时返回布尔值 true,不返回原值。成功修改存储定义后,调用者立即看到变化,提交后启动的会话也能看到变化;已有会话保留本地状态,直到 session_variable.init() 重置所有值。定义保存在 session_variable.variables 中,并纳入逻辑备份。
session_variable.get_stable 可能在语句执行期间缓存结果;如果触发器在同一语句中修改该值,应使用普通读取函数。session_variable.get_constant 标记为 IMMUTABLE,在管理员修改常量后可能返回缓存结果;修改期间应使用普通读取函数。
3.6 移除过时的版本 1 初始化支持。此前的 3.5 禁止为 collection 和 icollection 设置非空初始值,因为从文本初始化可能导致后端崩溃。使用这些类型时,应创建初始值为空的变量,并按源码中的初始化钩子 session_variable.variable_initialisation() 设置值;README 中另一个钩子名称与实现不一致。上游列出 PostgreSQL 14-18 支持,以及暂定的 PostgreSQL 19 支持。
这个页面对您有帮助吗?
感谢反馈,我们会据此改进这篇文档。
哪里没有解决?(可选)