pg_json_diff
JSONB 差异比较、JSON Patch 与 JSON Merge Patch 函数
仓库
KhaledSMQ/pg-jsondiff
https://github.com/KhaledSMQ/pg-jsondiff
源码
pg_json_diff-1.0-95cd668636ce.tar.gz
pg_json_diff-1.0-95cd668636ce.tar.gz
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
pg_json_diff | 1.0 | UTIL | MIT | C++ |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 4160 | pg_json_diff | 否 | 是 | 否 | 是 | 否 | 是 | - |
Source requires PostgreSQL 12+ and C++17. Packaging removes the unsupported control-file author field; no extension dependency.
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 | 1817161514 | pg_json_diff | - |
| RPM | PIGSTY | 1.0 | 1817161514 | pg_json_diff_$v | - |
| DEB | PIGSTY | 1.0 | 1817161514 | postgresql-$v-pg-json-diff | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.0 el8.x86_64.pg18 : pg_json_diff_18 pg_json_diff_18-1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 1.0 el8.x86_64.pg17 : pg_json_diff_17 pg_json_diff_17-1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 1.0 el8.x86_64.pg16 : pg_json_diff_16 pg_json_diff_16-1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 1.0 el8.x86_64.pg15 : pg_json_diff_15 pg_json_diff_15-1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 1.0 el8.x86_64.pg14 : pg_json_diff_14 pg_json_diff_14-1.0-1PGSTY.el8.x86_64.rpm
|
| el8.aarch64 | PIGSTY 1.0 el8.aarch64.pg18 : pg_json_diff_18 pg_json_diff_18-1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 1.0 el8.aarch64.pg17 : pg_json_diff_17 pg_json_diff_17-1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 1.0 el8.aarch64.pg16 : pg_json_diff_16 pg_json_diff_16-1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 1.0 el8.aarch64.pg15 : pg_json_diff_15 pg_json_diff_15-1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 1.0 el8.aarch64.pg14 : pg_json_diff_14 pg_json_diff_14-1.0-1PGSTY.el8.aarch64.rpm
|
| el9.x86_64 | PIGSTY 1.0 el9.x86_64.pg18 : pg_json_diff_18 pg_json_diff_18-1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 1.0 el9.x86_64.pg17 : pg_json_diff_17 pg_json_diff_17-1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 1.0 el9.x86_64.pg16 : pg_json_diff_16 pg_json_diff_16-1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 1.0 el9.x86_64.pg15 : pg_json_diff_15 pg_json_diff_15-1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 1.0 el9.x86_64.pg14 : pg_json_diff_14 pg_json_diff_14-1.0-1PGSTY.el9.x86_64.rpm
|
| el9.aarch64 | PIGSTY 1.0 el9.aarch64.pg18 : pg_json_diff_18 pg_json_diff_18-1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 1.0 el9.aarch64.pg17 : pg_json_diff_17 pg_json_diff_17-1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 1.0 el9.aarch64.pg16 : pg_json_diff_16 pg_json_diff_16-1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 1.0 el9.aarch64.pg15 : pg_json_diff_15 pg_json_diff_15-1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 1.0 el9.aarch64.pg14 : pg_json_diff_14 pg_json_diff_14-1.0-1PGSTY.el9.aarch64.rpm
|
| el10.x86_64 | PIGSTY 1.0 el10.x86_64.pg18 : pg_json_diff_18 pg_json_diff_18-1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 1.0 el10.x86_64.pg17 : pg_json_diff_17 pg_json_diff_17-1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 1.0 el10.x86_64.pg16 : pg_json_diff_16 pg_json_diff_16-1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 1.0 el10.x86_64.pg15 : pg_json_diff_15 pg_json_diff_15-1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 1.0 el10.x86_64.pg14 : pg_json_diff_14 pg_json_diff_14-1.0-1PGSTY.el10.x86_64.rpm
|
| el10.aarch64 | PIGSTY 1.0 el10.aarch64.pg18 : pg_json_diff_18 pg_json_diff_18-1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 1.0 el10.aarch64.pg17 : pg_json_diff_17 pg_json_diff_17-1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 1.0 el10.aarch64.pg16 : pg_json_diff_16 pg_json_diff_16-1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 1.0 el10.aarch64.pg15 : pg_json_diff_15 pg_json_diff_15-1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 1.0 el10.aarch64.pg14 : pg_json_diff_14 pg_json_diff_14-1.0-1PGSTY.el10.aarch64.rpm
|
| d12.x86_64 | PIGSTY 1.0 d12.x86_64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 1.0 d12.x86_64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 1.0 d12.x86_64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 1.0 d12.x86_64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 1.0 d12.x86_64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~bookworm_amd64.deb
|
| d12.aarch64 | PIGSTY 1.0 d12.aarch64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 1.0 d12.aarch64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 1.0 d12.aarch64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 1.0 d12.aarch64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 1.0 d12.aarch64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~bookworm_arm64.deb
|
| d13.x86_64 | PIGSTY 1.0 d13.x86_64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 1.0 d13.x86_64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 1.0 d13.x86_64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 1.0 d13.x86_64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 1.0 d13.x86_64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~trixie_amd64.deb
|
| d13.aarch64 | PIGSTY 1.0 d13.aarch64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 1.0 d13.aarch64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 1.0 d13.aarch64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 1.0 d13.aarch64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 1.0 d13.aarch64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~trixie_arm64.deb
|
| u22.x86_64 | PIGSTY 1.0 u22.x86_64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 1.0 u22.x86_64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 1.0 u22.x86_64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 1.0 u22.x86_64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 1.0 u22.x86_64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~jammy_amd64.deb
|
| u22.aarch64 | PIGSTY 1.0 u22.aarch64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 1.0 u22.aarch64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 1.0 u22.aarch64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 1.0 u22.aarch64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 1.0 u22.aarch64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~jammy_arm64.deb
|
| u24.x86_64 | PIGSTY 1.0 u24.x86_64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~noble_amd64.deb
| PIGSTY 1.0 u24.x86_64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~noble_amd64.deb
| PIGSTY 1.0 u24.x86_64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~noble_amd64.deb
| PIGSTY 1.0 u24.x86_64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~noble_amd64.deb
| PIGSTY 1.0 u24.x86_64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~noble_amd64.deb
|
| u24.aarch64 | PIGSTY 1.0 u24.aarch64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~noble_arm64.deb
| PIGSTY 1.0 u24.aarch64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~noble_arm64.deb
| PIGSTY 1.0 u24.aarch64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~noble_arm64.deb
| PIGSTY 1.0 u24.aarch64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~noble_arm64.deb
| PIGSTY 1.0 u24.aarch64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~noble_arm64.deb
|
| u26.x86_64 | PIGSTY 1.0 u26.x86_64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 1.0 u26.x86_64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 1.0 u26.x86_64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 1.0 u26.x86_64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 1.0 u26.x86_64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~resolute_amd64.deb
|
| u26.aarch64 | PIGSTY 1.0 u26.aarch64.pg18 : postgresql-18-pg-json-diff postgresql-18-pg-json-diff_1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 1.0 u26.aarch64.pg17 : postgresql-17-pg-json-diff postgresql-17-pg-json-diff_1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 1.0 u26.aarch64.pg16 : postgresql-16-pg-json-diff postgresql-16-pg-json-diff_1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 1.0 u26.aarch64.pg15 : postgresql-15-pg-json-diff postgresql-15-pg-json-diff_1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 1.0 u26.aarch64.pg14 : postgresql-14-pg-json-diff postgresql-14-pg-json-diff_1.0-1PGSTY~resolute_arm64.deb
|
构建
您可以使用 pig build 命令构建 pg_json_diff 扩展的 RPM / DEB 包:
安装
您可以直接安装 pg_json_diff 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
使用 pig 或者是 apt/yum/dnf 安装扩展:
安装
pig
dnf
apt
创建扩展:
用法
来源:
pg_json_diff 1.0 提供三个基于 nlohmann/json 的不可变 JSONB 转换函数:生成 RFC 6902 JSON Patch、应用这种补丁,或应用 RFC 7386 合并补丁。它适合明确的文档转换,不是自动冲突解决器,也不是稳定的审计差异格式。
核心流程
先生成补丁,保存或检查它,再验证应用补丁后是否得到预期目标:
应用外部提供的补丁前应先验证,并在事务及应用级授权保护下执行转换。
函数索引
generate_json_diff(source, target)返回 RFC 6902 操作数组。apply_patch(document, patch)支持添加、删除、替换、移动、复制与测试操作。merge_patch(document, patch)递归合并对象;空值成员删除键,数组则整体替换而不是合并。
三个函数都接受并返回 jsonb。
运维说明
每次调用都会把 PostgreSQL JSONB 序列化为文本,解析成 C++ JSON 值,执行操作,再次序列化并重新解析为 JSONB。因此,大型或深层嵌套文档会产生复制与解析开销。nlohmann/json 与 PostgreSQL JSONB 的数值模型不同,应测试超大整数和高精度小数的保真度。补丁错误会以通用内部错误返回;生成的操作顺序与路径也不应当作规范化的人类审计记录。
这个页面对您有帮助吗?
感谢反馈,我们会据此改进这篇文档。
哪里没有解决?(可选)