Debian Codegraph @

doc/src/sgml/ref/drop_subscription.sgml

raw
1 <!--
2 doc/src/sgml/ref/drop_subscription.sgml
3 PostgreSQL documentation
4 -->
5
6 <refentry id="sql-dropsubscription">
7 <indexterm zone="sql-dropsubscription">
8 <primary>DROP SUBSCRIPTION</primary>
9 </indexterm>
10
11 <refmeta>
12 <refentrytitle>DROP SUBSCRIPTION</refentrytitle>
13 <manvolnum>7</manvolnum>
14 <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
16
17 <refnamediv>
18 <refname>DROP SUBSCRIPTION</refname>
19 <refpurpose>remove a subscription</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23 <synopsis>
24 DROP SUBSCRIPTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
25 </synopsis>
26 </refsynopsisdiv>
27
28 <refsect1>
29 <title>Description</title>
30
31 <para>
32 <command>DROP SUBSCRIPTION</command> removes a subscription from the
33 database cluster.
34 </para>
35
36 <para>
37 To execute this command the user must be the owner of the subscription.
38 </para>
39
40 <para>
41 <command>DROP SUBSCRIPTION</command> cannot be executed inside a
42 transaction block if the subscription is associated with a replication
43 slot. (You can use <link linkend="sql-altersubscription"><command>ALTER SUBSCRIPTION</command></link> to unset the
44 slot.)
45 </para>
46 </refsect1>
47
48 <refsect1>
49 <title>Parameters</title>
50
51 <variablelist>
52 <varlistentry>
53 <term><literal>IF EXISTS</literal></term>
54 <listitem>
55 <para>
56 Do not throw an error if the subscription does not exist. A notice is
57 issued in this case.
58 </para>
59 </listitem>
60 </varlistentry>
61
62 <varlistentry>
63 <term><replaceable class="parameter">name</replaceable></term>
64 <listitem>
65 <para>
66 The name of a subscription to be dropped.
67 </para>
68 </listitem>
69 </varlistentry>
70
71 <varlistentry>
72 <term><literal>CASCADE</literal></term>
73 <term><literal>RESTRICT</literal></term>
74
75 <listitem>
76 <para>
77 These key words do not have any effect, since there are no dependencies
78 on subscriptions.
79 </para>
80 </listitem>
81 </varlistentry>
82
83 </variablelist>
84 </refsect1>
85
86 <refsect1>
87 <title>Notes</title>
88
89 <para>
90 When dropping a subscription that is associated with a replication slot on
91 the remote host (the normal state), <command>DROP SUBSCRIPTION</command>
92 will connect to the remote host and try to drop the replication slot (and
93 any remaining table synchronization slots) as
94 part of its operation. This is necessary so that the resources allocated
95 for the subscription on the remote host are released. If this fails,
96 either because the remote host is not reachable or because the remote
97 replication slot cannot be dropped or does not exist or never existed,
98 the <command>DROP SUBSCRIPTION</command> command will fail. To proceed
99 in this situation, first disable the subscription by executing
100 <link linkend="sql-altersubscription-params-disable">
101 <literal>ALTER SUBSCRIPTION ... DISABLE</literal></link>, and then disassociate
102 it from the replication slot by executing
103 <link linkend="sql-altersubscription-params-set">
104 <literal>ALTER SUBSCRIPTION ... SET (slot_name = NONE)</literal></link>.
105 After that, <command>DROP SUBSCRIPTION</command> will not attempt to drop
106 the subscription's own replication slot. It may still connect to the publisher
107 to drop internally-created table synchronization slots if some table
108 synchronization is left unfinished; if the publisher is unreachable, those
109 slots (and the main slot, if it still exists) must be dropped manually. Otherwise
110 it/they will continue to reserve WAL and might eventually cause the disk to
111 fill up. See also
112 <xref linkend="logical-replication-subscription-slot"/>.
113 </para>
114
115 <para>
116 If a subscription is associated with a replication slot, then <command>DROP
117 SUBSCRIPTION</command> cannot be executed inside a transaction block.
118 </para>
119 </refsect1>
120
121 <refsect1>
122 <title>Examples</title>
123
124 <para>
125 Drop a subscription:
126 <programlisting>
127 DROP SUBSCRIPTION mysub;
128 </programlisting></para>
129 </refsect1>
130
131 <refsect1>
132 <title>Compatibility</title>
133
134 <para>
135 <command>DROP SUBSCRIPTION</command> is a <productname>PostgreSQL</productname>
136 extension.
137 </para>
138 </refsect1>
139
140 <refsect1>
141 <title>See Also</title>
142
143 <simplelist type="inline">
144 <member><xref linkend="sql-createsubscription"/></member>
145 <member><xref linkend="sql-altersubscription"/></member>
146 </simplelist>
147 </refsect1>
148 </refentry>