跳转到主要内容

logical_ddl

在 PostgreSQL 逻辑复制中复制受支持的 DDL 变更

logical_ddl · 在 PostgreSQL 逻辑复制中复制受支持的 DDL 变更

概览

ID扩展软件包版本类别许可证编程语言
9530logical_ddllogical_ddl0.1.0ETLMITC
属性可执行文件动态库需要预加载需要建扩展可迁移可信
--s-d--否是否是否否
关联
模式logical_ddl
相关扩展pglogical pgl_ddl_deploy spock pgactive mimeo pgoutput lolor
Pigsty carries the upstream RAISE WARNING typo fix for 0.1.0.

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY0.1.019 18 17 16 15logical_ddl-
RPMPIGSTY0.1.019 18 17 16 15logical_ddl_$v-
DEBPIGSTY0.1.019 18 17 16 15postgresql-$v-logical-ddl-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el8.aarch64N/APIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el9.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el9.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el10.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el10.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d12.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d12.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d13.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d13.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u22.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u22.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u24.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u24.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u26.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u26.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
软件包版本平台仓库大小下载
logical_ddl_190.1.0el9.x86_64pigsty24.5 KiBlogical_ddl_19-0.1.0-1PGSTY.el9.x86_64.rpm
logical_ddl_190.1.0el9.aarch64pigsty24.4 KiBlogical_ddl_19-0.1.0-1PGSTY.el9.aarch64.rpm
logical_ddl_190.1.0el10.x86_64pigsty24.4 KiBlogical_ddl_19-0.1.0-1PGSTY.el10.x86_64.rpm
logical_ddl_190.1.0el10.aarch64pigsty24.3 KiBlogical_ddl_19-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-19-logical-ddl0.1.0d12.x86_64pigsty15.5 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-logical-ddl0.1.0d12.aarch64pigsty15.4 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-logical-ddl0.1.0d13.x86_64pigsty15.5 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-19-logical-ddl0.1.0d13.aarch64pigsty15.4 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-19-logical-ddl0.1.0u22.x86_64pigsty16.2 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-19-logical-ddl0.1.0u22.aarch64pigsty16.2 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-19-logical-ddl0.1.0u24.x86_64pigsty16.1 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~noble_amd64.deb
postgresql-19-logical-ddl0.1.0u24.aarch64pigsty15.9 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~noble_arm64.deb
postgresql-19-logical-ddl0.1.0u26.x86_64pigsty16.2 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-19-logical-ddl0.1.0u26.aarch64pigsty16.0 KiBpostgresql-19-logical-ddl_0.1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
logical_ddl_180.1.0el8.x86_64pigsty24.0 KiBlogical_ddl_18-0.1.0-1PGSTY.el8.x86_64.rpm
logical_ddl_180.1.0el8.aarch64pigsty24.2 KiBlogical_ddl_18-0.1.0-1PGSTY.el8.aarch64.rpm
logical_ddl_180.1.0el9.x86_64pigsty24.4 KiBlogical_ddl_18-0.1.0-1PGSTY.el9.x86_64.rpm
logical_ddl_180.1.0el9.aarch64pigsty24.4 KiBlogical_ddl_18-0.1.0-1PGSTY.el9.aarch64.rpm
logical_ddl_180.1.0el10.x86_64pigsty24.4 KiBlogical_ddl_18-0.1.0-1PGSTY.el10.x86_64.rpm
logical_ddl_180.1.0el10.aarch64pigsty24.3 KiBlogical_ddl_18-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-logical-ddl0.1.0d12.x86_64pigsty15.5 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-logical-ddl0.1.0d12.aarch64pigsty15.4 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-logical-ddl0.1.0d13.x86_64pigsty15.4 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-18-logical-ddl0.1.0d13.aarch64pigsty15.4 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-18-logical-ddl0.1.0u22.x86_64pigsty16.1 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-18-logical-ddl0.1.0u22.aarch64pigsty16.2 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-18-logical-ddl0.1.0u24.x86_64pigsty16.1 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~noble_amd64.deb
postgresql-18-logical-ddl0.1.0u24.aarch64pigsty15.9 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~noble_arm64.deb
postgresql-18-logical-ddl0.1.0u26.x86_64pigsty16.2 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-18-logical-ddl0.1.0u26.aarch64pigsty16.0 KiBpostgresql-18-logical-ddl_0.1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
logical_ddl_170.1.0el8.x86_64pigsty24.0 KiBlogical_ddl_17-0.1.0-1PGSTY.el8.x86_64.rpm
logical_ddl_170.1.0el8.aarch64pigsty24.2 KiBlogical_ddl_17-0.1.0-1PGSTY.el8.aarch64.rpm
logical_ddl_170.1.0el9.x86_64pigsty24.4 KiBlogical_ddl_17-0.1.0-1PGSTY.el9.x86_64.rpm
logical_ddl_170.1.0el9.aarch64pigsty24.4 KiBlogical_ddl_17-0.1.0-1PGSTY.el9.aarch64.rpm
logical_ddl_170.1.0el10.x86_64pigsty24.4 KiBlogical_ddl_17-0.1.0-1PGSTY.el10.x86_64.rpm
logical_ddl_170.1.0el10.aarch64pigsty24.3 KiBlogical_ddl_17-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-logical-ddl0.1.0d12.x86_64pigsty15.4 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-logical-ddl0.1.0d12.aarch64pigsty15.4 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-logical-ddl0.1.0d13.x86_64pigsty15.4 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-17-logical-ddl0.1.0d13.aarch64pigsty15.4 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-17-logical-ddl0.1.0u22.x86_64pigsty18.7 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-17-logical-ddl0.1.0u22.aarch64pigsty18.8 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-17-logical-ddl0.1.0u24.x86_64pigsty16.1 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~noble_amd64.deb
postgresql-17-logical-ddl0.1.0u24.aarch64pigsty15.9 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~noble_arm64.deb
postgresql-17-logical-ddl0.1.0u26.x86_64pigsty16.2 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-17-logical-ddl0.1.0u26.aarch64pigsty16.0 KiBpostgresql-17-logical-ddl_0.1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
logical_ddl_160.1.0el8.x86_64pigsty24.0 KiBlogical_ddl_16-0.1.0-1PGSTY.el8.x86_64.rpm
logical_ddl_160.1.0el8.aarch64pigsty24.2 KiBlogical_ddl_16-0.1.0-1PGSTY.el8.aarch64.rpm
logical_ddl_160.1.0el9.x86_64pigsty24.4 KiBlogical_ddl_16-0.1.0-1PGSTY.el9.x86_64.rpm
logical_ddl_160.1.0el9.aarch64pigsty24.4 KiBlogical_ddl_16-0.1.0-1PGSTY.el9.aarch64.rpm
logical_ddl_160.1.0el10.x86_64pigsty24.4 KiBlogical_ddl_16-0.1.0-1PGSTY.el10.x86_64.rpm
logical_ddl_160.1.0el10.aarch64pigsty24.3 KiBlogical_ddl_16-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-logical-ddl0.1.0d12.x86_64pigsty15.4 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-logical-ddl0.1.0d12.aarch64pigsty15.4 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-logical-ddl0.1.0d13.x86_64pigsty15.4 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-16-logical-ddl0.1.0d13.aarch64pigsty15.4 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-16-logical-ddl0.1.0u22.x86_64pigsty18.6 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-16-logical-ddl0.1.0u22.aarch64pigsty18.7 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-16-logical-ddl0.1.0u24.x86_64pigsty16.1 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~noble_amd64.deb
postgresql-16-logical-ddl0.1.0u24.aarch64pigsty15.9 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~noble_arm64.deb
postgresql-16-logical-ddl0.1.0u26.x86_64pigsty16.2 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-16-logical-ddl0.1.0u26.aarch64pigsty16.0 KiBpostgresql-16-logical-ddl_0.1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
logical_ddl_150.1.0el8.x86_64pigsty24.0 KiBlogical_ddl_15-0.1.0-1PGSTY.el8.x86_64.rpm
logical_ddl_150.1.0el8.aarch64pigsty24.3 KiBlogical_ddl_15-0.1.0-1PGSTY.el8.aarch64.rpm
logical_ddl_150.1.0el9.x86_64pigsty24.5 KiBlogical_ddl_15-0.1.0-1PGSTY.el9.x86_64.rpm
logical_ddl_150.1.0el9.aarch64pigsty24.4 KiBlogical_ddl_15-0.1.0-1PGSTY.el9.aarch64.rpm
logical_ddl_150.1.0el10.x86_64pigsty24.4 KiBlogical_ddl_15-0.1.0-1PGSTY.el10.x86_64.rpm
logical_ddl_150.1.0el10.aarch64pigsty24.3 KiBlogical_ddl_15-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-logical-ddl0.1.0d12.x86_64pigsty15.4 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-logical-ddl0.1.0d12.aarch64pigsty15.4 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-logical-ddl0.1.0d13.x86_64pigsty15.5 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-15-logical-ddl0.1.0d13.aarch64pigsty15.4 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-15-logical-ddl0.1.0u22.x86_64pigsty18.6 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-15-logical-ddl0.1.0u22.aarch64pigsty18.7 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-15-logical-ddl0.1.0u24.x86_64pigsty16.1 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~noble_amd64.deb
postgresql-15-logical-ddl0.1.0u24.aarch64pigsty15.9 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~noble_arm64.deb
postgresql-15-logical-ddl0.1.0u26.x86_64pigsty16.2 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-15-logical-ddl0.1.0u26.aarch64pigsty16.0 KiBpostgresql-15-logical-ddl_0.1.0-1PGSTY~resolute_arm64.deb

源码

pig build pkg logical_ddl;		# build rpm/deb

安装

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

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

使用 pig 安装扩展。

pig install logical_ddl;		# install by package name

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

在数据库中创建扩展。

CREATE EXTENSION logical_ddl;

用法

来源:README

logical_ddl 会捕获一组受限的 ALTER TABLE 变更,将其写入可复制的 shadow table,并在 logical replication 的 subscriber 上回放等价 DDL。

支持的 DDL

  • ALTER TABLE ... RENAME TO ...
  • ALTER TABLE ... RENAME COLUMN ... TO ...
  • ALTER TABLE ... ADD COLUMN ...
  • ALTER TABLE ... ALTER COLUMN ... TYPE ...
  • ALTER TABLE ... DROP COLUMN ...

内建类型、arrays、composite types、domains 与 enums 可以作为列类型使用,但该扩展不会复制这些自定义类型本身的定义。

发布端与订阅端设置

CREATE EXTENSION logical_ddl;

-- Publisher
INSERT INTO logical_ddl.settings VALUES (true, 'source1');
INSERT INTO logical_ddl.publish_tablelist (relid) VALUES ('table1'::regclass);
ALTER PUBLICATION log_pub_1 ADD TABLE logical_ddl.shadow_table;

-- Subscriber
INSERT INTO logical_ddl.settings VALUES (false, 'source1');
INSERT INTO logical_ddl.subscribe_tablelist (source, relid)
VALUES ('source1', 'table1'::regclass);
ALTER SUBSCRIPTION log_sub_1 REFRESH PUBLICATION;

主要表

  • logical_ddl.settings:声明当前节点是 publisher 还是 subscriber,以及 source name。
  • logical_ddl.publish_tablelist:定义要捕获的表与命令类型。
  • logical_ddl.subscribe_tablelist:定义要回放的目标表与命令类型。
  • logical_ddl.shadow_table:复制用的命令日志。
  • logical_ddl.applied_commands:回放历史与失败跟踪。

注意事项

  • 该扩展在 superuser 权限下工作。
  • 类型变更的 USING 表达式、default expressions、constraints 与 indexes 均未实现。
  • Pigsty 提到上游在 0.1.0 修复了一个 RAISE WARNING 拼写错误,但这不影响这里记录的用户用法。

表格阅读器