Postgresql 中文操作指南
Description
DROP SUBSCRIPTION 从数据库集群中删除订阅。
DROP SUBSCRIPTION removes a subscription from the database cluster.
要执行此命令,用户必须是订阅的所有者。
To execute this command the user must be the owner of the subscription.
如果订阅与复制槽关联,则无法在事务块内执行 DROP SUBSCRIPTION 。(可以使用 ALTER SUBSCRIPTION 取消设置槽。)
DROP SUBSCRIPTION cannot be executed inside a transaction block if the subscription is associated with a replication slot. (You can use ALTER SUBSCRIPTION to unset the slot.)
Parameters
-
name
-
The name of a subscription to be dropped.
-
-
CASCADE__RESTRICT
-
These key words do not have any effect, since there are no dependencies on subscriptions.
-
Notes
在删除与远程主机的复制槽关联的订阅时(正常状态), DROP SUBSCRIPTION 会连接到远程主机并尝试在其操作过程中删除复制槽(以及任何剩余的表同步槽)。这样做是为了释放为远程主机上的订阅分配的资源。如果由于无法连接远程主机或无法删除或不存在远程复制槽或从来没有这个远程复制槽,则 DROP SUBSCRIPTION 命令将失败。要继续这种情况,首先通过执行 ALTER SUBSCRIPTION … DISABLE 禁用订阅,然后通过执行 ALTER SUBSCRIPTION … SET (slot_name = NONE) 取消其与复制槽关联。之后, DROP SUBSCRIPTION 将不再尝试在远程主机上执行任何操作。请注意,如果远程复制槽仍然存在,则应手动删除它(以及任何相关的表同步槽);否则,它/它们将继续保留 WAL 并最终可能会导致磁盘被填满。另请参见 Section 31.2.1 。
When dropping a subscription that is associated with a replication slot on the remote host (the normal state), DROP SUBSCRIPTION will connect to the remote host and try to drop the replication slot (and any remaining table synchronization slots) as part of its operation. This is necessary so that the resources allocated for the subscription on the remote host are released. If this fails, either because the remote host is not reachable or because the remote replication slot cannot be dropped or does not exist or never existed, the DROP SUBSCRIPTION command will fail. To proceed in this situation, first disable the subscription by executing ALTER SUBSCRIPTION … DISABLE, and then disassociate it from the replication slot by executing ALTER SUBSCRIPTION … SET (slot_name = NONE). After that, DROP SUBSCRIPTION will no longer attempt any actions on a remote host. Note that if the remote replication slot still exists, it (and any related table synchronization slots) should then be dropped manually; otherwise it/they will continue to reserve WAL and might eventually cause the disk to fill up. See also Section 31.2.1.
如果订阅与复制槽关联,则无法在事务块内执行 DROP SUBSCRIPTION 。
If a subscription is associated with a replication slot, then DROP SUBSCRIPTION cannot be executed inside a transaction block.