pg_circuit
针对危险 SQL 语句提供运行时观察、告警和拦截
仓库
PG-Circuit/pg-circuit
https://github.com/PG-Circuit/pg-circuit
源码
pg_circuit-0.1.0.tar.gz
pg_circuit-0.1.0.tar.gz
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
pg_circuit | 0.1.0 | ADMIN | Apache-2.0 | C |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 5815 | pg_circuit | 否 | 是 | 是 | 是 | 否 | 否 | - |
Requires shared_preload_libraries and restart; Community runtime pressure is informational.
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.0 | 1817161514 | pg_circuit | - |
| RPM | PIGSTY | 0.1.0 | 1817161514 | pg_circuit_$v | - |
| DEB | PIGSTY | 0.1.0 | 1817161514 | postgresql-$v-pg-circuit | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.1.0 el8.x86_64.pg18 : pg_circuit_18 pg_circuit_18-0.1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.1.0 el8.x86_64.pg17 : pg_circuit_17 pg_circuit_17-0.1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.1.0 el8.x86_64.pg16 : pg_circuit_16 pg_circuit_16-0.1.0-1PGSTY.el8.x86_64.rpm
| N/A | N/A |
| el8.aarch64 | PIGSTY 0.1.0 el8.aarch64.pg18 : pg_circuit_18 pg_circuit_18-0.1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.1.0 el8.aarch64.pg17 : pg_circuit_17 pg_circuit_17-0.1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.1.0 el8.aarch64.pg16 : pg_circuit_16 pg_circuit_16-0.1.0-1PGSTY.el8.aarch64.rpm
| N/A | N/A |
| el9.x86_64 | PIGSTY 0.1.0 el9.x86_64.pg18 : pg_circuit_18 pg_circuit_18-0.1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.1.0 el9.x86_64.pg17 : pg_circuit_17 pg_circuit_17-0.1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.1.0 el9.x86_64.pg16 : pg_circuit_16 pg_circuit_16-0.1.0-1PGSTY.el9.x86_64.rpm
| N/A | N/A |
| el9.aarch64 | PIGSTY 0.1.0 el9.aarch64.pg18 : pg_circuit_18 pg_circuit_18-0.1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.1.0 el9.aarch64.pg17 : pg_circuit_17 pg_circuit_17-0.1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.1.0 el9.aarch64.pg16 : pg_circuit_16 pg_circuit_16-0.1.0-1PGSTY.el9.aarch64.rpm
| N/A | N/A |
| el10.x86_64 | PIGSTY 0.1.0 el10.x86_64.pg18 : pg_circuit_18 pg_circuit_18-0.1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.1.0 el10.x86_64.pg17 : pg_circuit_17 pg_circuit_17-0.1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.1.0 el10.x86_64.pg16 : pg_circuit_16 pg_circuit_16-0.1.0-1PGSTY.el10.x86_64.rpm
| N/A | N/A |
| el10.aarch64 | PIGSTY 0.1.0 el10.aarch64.pg18 : pg_circuit_18 pg_circuit_18-0.1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.1.0 el10.aarch64.pg17 : pg_circuit_17 pg_circuit_17-0.1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.1.0 el10.aarch64.pg16 : pg_circuit_16 pg_circuit_16-0.1.0-1PGSTY.el10.aarch64.rpm
| N/A | N/A |
| d12.x86_64 | PIGSTY 0.1.0 d12.x86_64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.1.0 d12.x86_64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.1.0 d12.x86_64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~bookworm_amd64.deb
| N/A | N/A |
| d12.aarch64 | PIGSTY 0.1.0 d12.aarch64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.1.0 d12.aarch64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.1.0 d12.aarch64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~bookworm_arm64.deb
| N/A | N/A |
| d13.x86_64 | PIGSTY 0.1.0 d13.x86_64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 0.1.0 d13.x86_64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 0.1.0 d13.x86_64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~trixie_amd64.deb
| N/A | N/A |
| d13.aarch64 | PIGSTY 0.1.0 d13.aarch64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 0.1.0 d13.aarch64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 0.1.0 d13.aarch64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~trixie_arm64.deb
| N/A | N/A |
| u22.x86_64 | PIGSTY 0.1.0 u22.x86_64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 0.1.0 u22.x86_64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 0.1.0 u22.x86_64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~jammy_amd64.deb
| N/A | N/A |
| u22.aarch64 | PIGSTY 0.1.0 u22.aarch64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 0.1.0 u22.aarch64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 0.1.0 u22.aarch64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~jammy_arm64.deb
| N/A | N/A |
| u24.x86_64 | PIGSTY 0.1.0 u24.x86_64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~noble_amd64.deb
| PIGSTY 0.1.0 u24.x86_64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~noble_amd64.deb
| PIGSTY 0.1.0 u24.x86_64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~noble_amd64.deb
| N/A | N/A |
| u24.aarch64 | PIGSTY 0.1.0 u24.aarch64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~noble_arm64.deb
| PIGSTY 0.1.0 u24.aarch64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~noble_arm64.deb
| PIGSTY 0.1.0 u24.aarch64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~noble_arm64.deb
| N/A | N/A |
| u26.x86_64 | PIGSTY 0.1.0 u26.x86_64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 0.1.0 u26.x86_64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 0.1.0 u26.x86_64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~resolute_amd64.deb
| N/A | N/A |
| u26.aarch64 | PIGSTY 0.1.0 u26.aarch64.pg18 : postgresql-18-pg-circuit postgresql-18-pg-circuit_0.1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 0.1.0 u26.aarch64.pg17 : postgresql-17-pg-circuit postgresql-17-pg-circuit_0.1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 0.1.0 u26.aarch64.pg16 : postgresql-16-pg-circuit postgresql-16-pg-circuit_0.1.0-1PGSTY~resolute_arm64.deb
| N/A | N/A |
构建
您可以使用 pig build 命令构建 pg_circuit 扩展的 RPM / DEB 包:
安装
您可以直接安装 pg_circuit 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
使用 pig 或者是 apt/yum/dnf 安装扩展:
安装
pig
dnf
apt
预加载配置:
创建扩展:
用法
来源:
pg_circuit 在 PostgreSQL 16–18 中检查有风险的 DML 和 DDL。社区版可以观察、告警或阻止语句。先将其加入 shared_preload_libraries 并重启 PostgreSQL,再以超级用户创建扩展。
基础保护
配置与诊断
pg_circuit.mode 默认为告警模式;观察模式只计算风险,强制模式阻止评分达到配置阈值的语句。pg_circuit_runtime_state() 报告压力信号,pg_circuit_events() 展示近期事件。
社区版的有效运行模式始终为 NORMAL,压力读数不会自动提升拦截力度。扩展是策略辅助工具,数据保护仍取决于应用事务、授权和备份。启用强制模式前应使用代表性查询检查规则和阈值。
这个页面对您有帮助吗?
感谢反馈,我们会据此改进这篇文档。
哪里没有解决?(可选)