pg_isok

基于查询的数据完整性管理与软告警扩展

概览

扩展包名版本分类许可证语言
pg_isok1.4.1UTILAGPL-3.0SQL
ID扩展名BinLibLoadCreateTrustReloc模式
4340pg_isok-

superuser=false, but this is not a trusted extension.

版本

类型仓库版本PG 大版本包名依赖
EXTPIGSTY1.4.11817161514pg_isok-
RPMPIGSTY1.4.11817161514pg_isok_$v-
DEBPIGSTY1.4.11817161514postgresql-$v-pg-isok-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
u22.x86_64
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
u22.aarch64
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
u24.x86_64
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
u24.aarch64
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
PIGSTY 1.4.1
u26.x86_64
u26.aarch64

构建

您可以使用 pig build 命令构建 pg_isok 扩展的 RPM / DEB 包:

pig build pkg pg_isok         # 构建 RPM / DEB 包

安装

您可以直接安装 pg_isok 扩展包的预置二进制包,首先确保 PGDGPIGSTY 仓库已经添加并启用:

pig repo add pgsql -u          # 添加仓库并更新缓存

使用 pig 或者是 apt/yum/dnf 安装扩展:

pig install pg_isok;          # 当前活跃 PG 版本安装
pig ext install -y pg_isok -v 18  # PG 18
pig ext install -y pg_isok -v 17  # PG 17
pig ext install -y pg_isok -v 16  # PG 16
pig ext install -y pg_isok -v 15  # PG 15
pig ext install -y pg_isok -v 14  # PG 14
dnf install -y pg_isok_18       # PG 18
dnf install -y pg_isok_17       # PG 17
dnf install -y pg_isok_16       # PG 16
dnf install -y pg_isok_15       # PG 15
dnf install -y pg_isok_14       # PG 14
apt install -y postgresql-18-pg-isok   # PG 18
apt install -y postgresql-17-pg-isok   # PG 17
apt install -y postgresql-16-pg-isok   # PG 16
apt install -y postgresql-15-pg-isok   # PG 15
apt install -y postgresql-14-pg-isok   # PG 14

创建扩展

CREATE EXTENSION pg_isok;

用法

来源: official repo, official docs home, official reference source

pg_isok 是一个基于查询的数据完整性与监控扩展。它不会只报告当前看起来可疑的行,而是保存先前结果,并在后续运行时聚焦于尚未解决或尚未延期的变化。

CREATE SCHEMA isok;
CREATE EXTENSION pg_isok SCHEMA isok;

SELECT *
FROM isok.run_isok_queries()
AS problems;

核心对象

  • ISOK_QUERIES:存储监控查询及其执行设置。
  • ISOK_RESULTS:存储被报告的行,以及它们是否已解决或已延期。
  • run_isok_queries():运行所有启用的检查。
  • run_isok_queries($$VALUES ('check_name')$$):只运行指定的检查。

典型流程

运行一个具名检查:

SELECT *
FROM isok.run_isok_queries($$VALUES ('new_countries')$$)
AS problems;

通过更新 ISOK_RESULTS 接受或推迟一个已知告警:

UPDATE isok.isok_results
SET deferred_to = 'infinity'
WHERE iqname = 'new_countries';

当某个条件不再需要关注时使用 resolved;当它应该隐藏到将来某个时间时使用 deferred_to

适用场景

  • 导入后的数据清理
  • 监控不常见但有时可接受的模式
  • “软触发器”式的审查流程,即硬约束过于严格时的替代方案

注意事项

  • 上游建议将它安装在独立 schema 中,并在调用时显式带上 schema。
  • 文档将其描述为纯 SQL 扩展,这在受管 PostgreSQL 服务限制 C 扩展时很有价值。
  • 本仓库的包元数据显示 superuser=false,但上游并未把它记录为 trusted extension;应保守对待安装权限。

最后修改 2026-05-01: update extension data (e399d22)