跳转到主要内容

pg_living_assertions

保存可执行 SQL 检查、核验日期和断言变更历史

pg_living_assertions · 保存可执行 SQL 检查、核验日期和断言变更历史

概览

ID扩展软件包版本类别许可证编程语言
5300pg_living_assertionspg_living_assertions0.5.11ADMINApache-2.0SQL
属性可执行文件动态库需要预加载需要建扩展可迁移可信
----d--否否否是否否
关联
模式living_assertions
被依赖pg_grammar_guard
On-demand SQL checks run in a read-only subtransaction that is always rolled back; not per-write SQL ASSERTION constraints.

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY0.5.1119 18 17 16 15pg_living_assertions-
RPMPIGSTY0.5.1119 18 17 16 15pg_living_assertions_$v-
DEBPIGSTY0.5.1119 18 17 16 15postgresql-$v-pg-living-assertions-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.5.10PIGSTY 0.5.10PIGSTY 0.5.10PIGSTY 0.5.10
el8.aarch64N/APIGSTY 0.5.10PIGSTY 0.5.10PIGSTY 0.5.10PIGSTY 0.5.10
el9.x86_64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
el9.aarch64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
el10.x86_64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
el10.aarch64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
d12.x86_64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
d12.aarch64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
d13.x86_64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
d13.aarch64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
u22.x86_64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
u22.aarch64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
u24.x86_64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
u24.aarch64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
u26.x86_64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
u26.aarch64PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11PIGSTY 0.5.11
软件包版本平台仓库大小下载
pg_living_assertions_190.5.11el9.x86_64pigsty45.4 KiBpg_living_assertions_19-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_190.5.11el9.aarch64pigsty45.4 KiBpg_living_assertions_19-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_190.5.11el10.x86_64pigsty45.5 KiBpg_living_assertions_19-0.5.11-1PGSTY.el10.noarch.rpm
pg_living_assertions_190.5.11el10.aarch64pigsty45.5 KiBpg_living_assertions_19-0.5.11-1PGSTY.el10.noarch.rpm
postgresql-19-pg-living-assertions0.5.11d12.x86_64pigsty40.1 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-19-pg-living-assertions0.5.11d12.aarch64pigsty40.1 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-19-pg-living-assertions0.5.11d13.x86_64pigsty40.1 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-19-pg-living-assertions0.5.11d13.aarch64pigsty40.1 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-19-pg-living-assertions0.5.11u22.x86_64pigsty36.7 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-19-pg-living-assertions0.5.11u22.aarch64pigsty36.7 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-19-pg-living-assertions0.5.11u24.x86_64pigsty36.5 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-19-pg-living-assertions0.5.11u24.aarch64pigsty36.5 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-19-pg-living-assertions0.5.11u26.x86_64pigsty36.5 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb
postgresql-19-pg-living-assertions0.5.11u26.aarch64pigsty36.5 KiBpostgresql-19-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
pg_living_assertions_180.5.10el8.x86_64pigsty45.9 KiBpg_living_assertions_18-0.5.10-1PGSTY.el8.noarch.rpm
pg_living_assertions_180.5.10el8.aarch64pigsty45.9 KiBpg_living_assertions_18-0.5.10-1PGSTY.el8.noarch.rpm
pg_living_assertions_180.5.11el9.x86_64pigsty45.4 KiBpg_living_assertions_18-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_180.5.11el9.aarch64pigsty45.4 KiBpg_living_assertions_18-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_180.5.11el10.x86_64pigsty45.5 KiBpg_living_assertions_18-0.5.11-1PGSTY.el10.noarch.rpm
pg_living_assertions_180.5.11el10.aarch64pigsty45.5 KiBpg_living_assertions_18-0.5.11-1PGSTY.el10.noarch.rpm
postgresql-18-pg-living-assertions0.5.11d12.x86_64pigsty40.1 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-18-pg-living-assertions0.5.11d12.aarch64pigsty40.1 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-18-pg-living-assertions0.5.11d13.x86_64pigsty40.1 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-18-pg-living-assertions0.5.11d13.aarch64pigsty40.1 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-18-pg-living-assertions0.5.11u22.x86_64pigsty36.7 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-18-pg-living-assertions0.5.11u22.aarch64pigsty36.7 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-18-pg-living-assertions0.5.11u24.x86_64pigsty36.5 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-18-pg-living-assertions0.5.11u24.aarch64pigsty36.5 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-18-pg-living-assertions0.5.11u26.x86_64pigsty36.5 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb
postgresql-18-pg-living-assertions0.5.11u26.aarch64pigsty36.5 KiBpostgresql-18-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
pg_living_assertions_170.5.10el8.x86_64pigsty45.9 KiBpg_living_assertions_17-0.5.10-1PGSTY.el8.noarch.rpm
pg_living_assertions_170.5.10el8.aarch64pigsty45.9 KiBpg_living_assertions_17-0.5.10-1PGSTY.el8.noarch.rpm
pg_living_assertions_170.5.11el9.x86_64pigsty45.4 KiBpg_living_assertions_17-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_170.5.11el9.aarch64pigsty45.4 KiBpg_living_assertions_17-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_170.5.11el10.x86_64pigsty45.5 KiBpg_living_assertions_17-0.5.11-1PGSTY.el10.noarch.rpm
pg_living_assertions_170.5.11el10.aarch64pigsty45.5 KiBpg_living_assertions_17-0.5.11-1PGSTY.el10.noarch.rpm
postgresql-17-pg-living-assertions0.5.11d12.x86_64pigsty40.1 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-17-pg-living-assertions0.5.11d12.aarch64pigsty40.1 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-17-pg-living-assertions0.5.11d13.x86_64pigsty40.1 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-17-pg-living-assertions0.5.11d13.aarch64pigsty40.1 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-17-pg-living-assertions0.5.11u22.x86_64pigsty36.7 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-17-pg-living-assertions0.5.11u22.aarch64pigsty36.7 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-17-pg-living-assertions0.5.11u24.x86_64pigsty36.5 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-17-pg-living-assertions0.5.11u24.aarch64pigsty36.5 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-17-pg-living-assertions0.5.11u26.x86_64pigsty36.5 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb
postgresql-17-pg-living-assertions0.5.11u26.aarch64pigsty36.5 KiBpostgresql-17-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
pg_living_assertions_160.5.10el8.x86_64pigsty45.9 KiBpg_living_assertions_16-0.5.10-1PGSTY.el8.noarch.rpm
pg_living_assertions_160.5.10el8.aarch64pigsty45.9 KiBpg_living_assertions_16-0.5.10-1PGSTY.el8.noarch.rpm
pg_living_assertions_160.5.11el9.x86_64pigsty45.4 KiBpg_living_assertions_16-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_160.5.11el9.aarch64pigsty45.4 KiBpg_living_assertions_16-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_160.5.11el10.x86_64pigsty45.5 KiBpg_living_assertions_16-0.5.11-1PGSTY.el10.noarch.rpm
pg_living_assertions_160.5.11el10.aarch64pigsty45.5 KiBpg_living_assertions_16-0.5.11-1PGSTY.el10.noarch.rpm
postgresql-16-pg-living-assertions0.5.11d12.x86_64pigsty40.1 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-16-pg-living-assertions0.5.11d12.aarch64pigsty40.1 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-16-pg-living-assertions0.5.11d13.x86_64pigsty40.1 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-16-pg-living-assertions0.5.11d13.aarch64pigsty40.1 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-16-pg-living-assertions0.5.11u22.x86_64pigsty36.7 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-16-pg-living-assertions0.5.11u22.aarch64pigsty36.7 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-16-pg-living-assertions0.5.11u24.x86_64pigsty36.5 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-16-pg-living-assertions0.5.11u24.aarch64pigsty36.5 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-16-pg-living-assertions0.5.11u26.x86_64pigsty36.5 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb
postgresql-16-pg-living-assertions0.5.11u26.aarch64pigsty36.5 KiBpostgresql-16-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
pg_living_assertions_150.5.10el8.x86_64pigsty45.9 KiBpg_living_assertions_15-0.5.10-1PGSTY.el8.noarch.rpm
pg_living_assertions_150.5.10el8.aarch64pigsty45.9 KiBpg_living_assertions_15-0.5.10-1PGSTY.el8.noarch.rpm
pg_living_assertions_150.5.11el9.x86_64pigsty45.4 KiBpg_living_assertions_15-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_150.5.11el9.aarch64pigsty45.4 KiBpg_living_assertions_15-0.5.11-1PGSTY.el9.noarch.rpm
pg_living_assertions_150.5.11el10.x86_64pigsty45.5 KiBpg_living_assertions_15-0.5.11-1PGSTY.el10.noarch.rpm
pg_living_assertions_150.5.11el10.aarch64pigsty45.5 KiBpg_living_assertions_15-0.5.11-1PGSTY.el10.noarch.rpm
postgresql-15-pg-living-assertions0.5.11d12.x86_64pigsty40.1 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-15-pg-living-assertions0.5.11d12.aarch64pigsty40.1 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~bookworm_all.deb
postgresql-15-pg-living-assertions0.5.11d13.x86_64pigsty40.1 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-15-pg-living-assertions0.5.11d13.aarch64pigsty40.1 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~trixie_all.deb
postgresql-15-pg-living-assertions0.5.11u22.x86_64pigsty36.7 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-15-pg-living-assertions0.5.11u22.aarch64pigsty36.7 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~jammy_all.deb
postgresql-15-pg-living-assertions0.5.11u24.x86_64pigsty36.5 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-15-pg-living-assertions0.5.11u24.aarch64pigsty36.5 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~noble_all.deb
postgresql-15-pg-living-assertions0.5.11u26.x86_64pigsty36.5 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb
postgresql-15-pg-living-assertions0.5.11u26.aarch64pigsty36.5 KiBpostgresql-15-pg-living-assertions_0.5.11-1PGSTY~resolute_all.deb

源码

github.com/Manuelreyesbravo/pg_living_assertions

pig build pkg pg_living_assertions;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

pig repo add pgsql -u   # add both repo and update cache

使用 pig 安装扩展。

pig install pg_living_assertions;		# install by package name

pig install pg_living_assertions -v 19;   # install for PG 19
pig install pg_living_assertions -v 18;   # install for PG 18
pig install pg_living_assertions -v 17;   # install for PG 17
pig install pg_living_assertions -v 16;   # install for PG 16
pig install pg_living_assertions -v 15;   # install for PG 15

在数据库中创建扩展。

CREATE EXTENSION pg_living_assertions;

用法

来源:

pg_living_assertions 0.5.11 保存具名 SQL 断言、结果与替换历史。检查按需运行,并非每次写入都执行的约束。这是无需预加载的纯 SQL 扩展。

核心用法

CREATE EXTENSION pg_living_assertions;
SELECT living_assertions.declare(
  'simple_check', 'one equals one',
  $$SELECT 1 = 1 AS holds, 'arithmetic check'::text AS detail$$);
SELECT living_assertions.run('simple_check');
SELECT name, state, age FROM living_assertions.status;

运行边界

检查返回一个布尔列 holds 和可选文本列 detail。living_assertions.run_all() 执行注册表中的检查;living_assertions.state()、living_assertions.status 和 living_assertions.stale() 区分失效、未知、报错,以及过期或未执行的检查。living_assertions.declare_unchanged() 对规范化表达式计算指纹,原有值变成 NULL 时判为失效。检查以记录的作者身份,在只读且回滚的子事务中执行,采用作者搜索路径并将临时模式放在最后。调用者须有权 SET ROLE 到该作者。求值时取得的会话咨询锁会被释放,但外部副作用和临时序列变化不在沙箱控制范围内,只有可信作者应登记 SQL。注册和检查时间由服务器确定,表拒绝 TRUNCATE,退役与替换仅限作者或有权代理的角色。升级须安装完整匹配的 SQL 链;旧断言保留原有指纹算法。当前版本采用 Apache-2.0,截至 0.5.3 的已发布版本仍保留原来的 PostgreSQL License。

0.5.10 的角色隔离

0.5.10 在需要角色隔离时,将检查放入由记录作者拥有的临时 SECURITY DEFINER 函数。PostgreSQL 会拒绝在该执行环境中重置角色或会话授权;函数与只读检查在同一子事务中创建并回滚。需要该执行环境时,作者必须拥有数据库的 TEMP 权限,调用者仍须有权代理该作者。SECURITY DEFINER 调用者现可凭此权限执行其他作者的检查。这修复了 0.5.8/0.5.9 中重置角色的逃逸路径,但不会使外部副作用变得安全。

当前兼容性

0.5.11 更新文档及已测试的兼容性,不改变 SQL 对象。上游记录的范围为 PostgreSQL 11–19。提供的 0.5.10 至 0.5.11 SQL 升级只推进扩展版本,上述角色权限与依赖要求继续适用。

表格阅读器