]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/unlisten.sgml
Create a "sort support" interface API for faster sorting.
[postgresql] / doc / src / sgml / ref / unlisten.sgml
1 <!--
2 doc/src/sgml/ref/unlisten.sgml
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-UNLISTEN">
7  <refmeta>
8   <refentrytitle>UNLISTEN</refentrytitle>
9   <manvolnum>7</manvolnum>
10   <refmiscinfo>SQL - Language Statements</refmiscinfo>
11  </refmeta>
12
13  <refnamediv>
14   <refname>UNLISTEN</refname>
15   <refpurpose>stop listening for a notification</refpurpose>
16  </refnamediv>
17
18  <indexterm zone="sql-unlisten">
19   <primary>UNLISTEN</primary>
20  </indexterm>
21
22  <refsynopsisdiv>
23 <synopsis>
24 UNLISTEN { <replaceable class="PARAMETER">channel</replaceable> | * }
25 </synopsis>
26  </refsynopsisdiv>
27
28  <refsect1>
29   <title>Description</title>
30
31   <para>
32    <command>UNLISTEN</command> is used to remove an existing
33    registration for <command>NOTIFY</command> events.
34    <command>UNLISTEN</command> cancels any existing registration of
35    the current <productname>PostgreSQL</productname> session as a
36    listener on the notification channel named <replaceable
37    class="PARAMETER">channel</replaceable>.  The special wildcard
38    <literal>*</literal> cancels all listener registrations for the
39    current session.
40   </para>
41
42   <para>
43    <xref linkend="sql-notify">
44    contains a more extensive
45    discussion of the use of <command>LISTEN</command> and
46    <command>NOTIFY</command>.
47   </para>
48  </refsect1>
49
50  <refsect1>
51   <title>Parameters</title>
52
53   <variablelist>
54    <varlistentry>
55     <term><replaceable class="PARAMETER">channel</replaceable></term>
56     <listitem>
57      <para>
58       Name of a notification channel (any identifier).
59      </para>
60     </listitem>
61    </varlistentry>
62
63    <varlistentry>
64     <term><literal>*</literal></term>
65     <listitem>
66      <para>
67       All current listen registrations for this session are cleared.
68      </para>
69     </listitem>
70    </varlistentry>
71   </variablelist>
72  </refsect1>
73
74  <refsect1>
75   <title>Notes</title>
76
77   <para>
78    You can unlisten something you were not listening for; no warning or error
79    will appear.
80   </para>
81
82   <para>
83    At the end of each session, <command>UNLISTEN *</command> is
84    automatically executed.
85   </para>
86
87   <para>
88    A transaction that has executed <command>UNLISTEN</command> cannot be
89    prepared for two-phase commit.
90   </para>
91  </refsect1>
92
93  <refsect1>
94   <title>Examples</title>
95
96   <para>
97    To make a registration:
98
99 <programlisting>
100 LISTEN virtual;
101 NOTIFY virtual;
102 Asynchronous notification "virtual" received from server process with PID 8448.
103 </programlisting>
104   </para>
105
106   <para>
107    Once <command>UNLISTEN</> has been executed, further <command>NOTIFY</>
108    messages will be ignored:
109
110 <programlisting>
111 UNLISTEN virtual;
112 NOTIFY virtual;
113 -- no NOTIFY event is received
114 </programlisting></para>
115  </refsect1>
116
117  <refsect1>
118   <title>Compatibility</title>
119
120   <para>
121    There is no <command>UNLISTEN</command> command in the SQL standard.
122   </para>
123  </refsect1>
124
125  <refsect1>
126   <title>See Also</title>
127
128   <simplelist type="inline">
129    <member><xref linkend="sql-listen"></member>
130    <member><xref linkend="sql-notify"></member>
131   </simplelist>
132  </refsect1>
133 </refentry>