DROP_SUBSCRIPTION(7pg14)
π DROP_SUBSCRIPTION β bestie, we're removing a subscription
okay so this is the DROP SUBSCRIPTION page from the PostgreSQL 14.24 Documentation, manual section 7 (that's the (7) in DROP_SUBSCRIPTION(7), iykyk). buckle up π
β¨ NAME β¨
DROP_SUBSCRIPTION β remove a subscription
π¦ SYNOPSIS π¦
DROP SUBSCRIPTION [ IF EXISTS ] name [ CASCADE | RESTRICT ]
π DESCRIPTION π
DROP SUBSCRIPTION removes a subscription from the database cluster. literally just yeets it out π
A subscription can only be dropped by a superuser. no superuser, no drop, periodt.
And here's the spicy bit π₯ β 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, though β that's the escape hatch π«Ά)
πΈ PARAMETERS πΈ
IF EXISTSβ do not throw an error if the subscription does not exist. a notice is issued in this case instead. very "no drama" of it β¨nameβ the name of a subscription to be dropped.CASCADERESTRICTβ these key words do not have any effect, since there are no dependencies on subscriptions. so cute, so useless, we stan anyway π
π NOTES π
okay this is the part where you actually pay attention, bestie, because this is where things get real π
When dropping a subscription that is associated with a replication slot on the remote host (which is 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. it's giving responsible queen energy π
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. π
so to proceed in this situation: first disable the subscription by executingALTER SUBSCRIPTION ... DISABLE, and then disassociate it from the replication slot by executingALTER SUBSCRIPTION ... SET (slot_name = NONE).
After that, DROP SUBSCRIPTION will not attempt to drop the subscription's own replication slot. It may still connect to the publisher to drop internally-created table synchronization slots if some table synchronization is left unfinished; if the publisher is unreachable, those slots (and the main slot, if it still exists) must 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.
Also, reiterating because it matters fr fr: if a subscription is associated with a replication slot, then DROP SUBSCRIPTION cannot be executed inside a transaction block.
π EXAMPLES π
Drop a subscription:
DROP SUBSCRIPTION mysub;
that's it. that's the example. slay π
π COMPATIBILITY π
DROP SUBSCRIPTION is a PostgreSQL extension. not standard SQL, it's our thing π
β SEE ALSO β
CREATE SUBSCRIPTION(CREATE_SUBSCRIPTION(7))ALTER SUBSCRIPTION(ALTER_SUBSCRIPTION(7))
k that's the whole page, you're literally a subscription-dropping icon now π§ββοΈβ¨ this was PostgreSQL 14.24, dated 2026, and yes the footer said DROP SUBSCRIPTION(7) too β same girl, different line. bye bestie, go drop responsibly π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms