aboutsummaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref/notify.sgml
blob: f88ac45c28f77386b2e4b4818431289c6b5a5f85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<REFENTRY ID="SQL-NOTIFY">
<REFMETA>
<REFENTRYTITLE>
NOTIFY
</REFENTRYTITLE>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO>
</REFMETA>
<REFNAMEDIV>
<REFNAME>
NOTIFY
</REFNAME>
<REFPURPOSE>
Signals all frontends and backends listening on a class
</REFPURPOSE>

<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-24</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
<REPLACEABLE CLASS="PARAMETER">
</REPLACEABLE>
NOTIFY <REPLACEABLE CLASS="PARAMETER">classname</REPLACEABLE>        
</SYNOPSIS>

<REFSECT2 ID="R2-SQL-NOTIFY-1">
<REFSECT2INFO>
<DATE>1998-09-24</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>

<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">classname</REPLACEABLE>        
</TERM>
<LISTITEM>
<PARA>
Table or arbitrary relation class used for notification.

</VARIABLELIST>

</REFSECT2>

<REFSECT2 ID="R2-SQL-NOTIFY-2">
<REFSECT2INFO>
<DATE>1998-09-24</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
</TITLE>
<PARA>

<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>

<VARIABLELIST>
<VARLISTENTRY>
<TERM>
NOTIFY
</TERM>
<LISTITEM>
<PARA>
Notification message from backend.

</VARIABLELIST>
</VARIABLELIST>

</REFSECT2>
</REFSYNOPSISDIV>

<REFSECT1 ID="R1-SQL-NOTIFY-1">
<REFSECT1INFO>
<DATE>1998-09-24</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
   <command>NOTIFY</command> is used to awaken all sessions which have
previously executed
 <command>LISTEN <replaceable class="parameter">classname</replaceable></command>.
 This can be used either within an instance-level rule 
as part of the action body or from a  normal query.

<para>
 When used from within a normal query, 
this can be thought of as interprocess communication (IPC).  When
used from within a rule, this can be thought of as an alert mechanism.
<para>
       Note that the mere fact that a <command>NOTIFY</command> has been
 executed does not imply anything in particular about the state
       of  the class (e.g., that it has been updated),
 nor does the notification protocol transmit any useful information
 other than the class name.  
Therefore, all <command>NOTIFY</command> does is indicate that some backend
 wishes its  peers to
       examine <replaceable class="parameter">classname</replaceable>
 in some application-specific way.
<para>
       In  fact,  <replaceable class="parameter">classname</replaceable>
  need  not be the name of an SQL class at all.
  It is best thought of as a condition name
       that the application programmer selects.
<para>
       This event notification is performed through the libpq protocol
 and frontend application interface.  The application  program
  must  call  the routine <function>PQnotifies</function>
 in order to find out the name of the class to which a given
       notification corresponds.  
If this code is not included in the application,  
the  event  notification  will  be
       queued and never be processed.
 
<REFSECT2 ID="R2-SQL-NOTIFY-3">
<REFSECT2INFO>
<DATE>1998-09-24</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<PARA>
</PARA>

</REFSECT2>

<REFSECT1 ID="R1-SQL-NOTIFY-2">
<TITLE>
Usage
</TITLE>
<PARA>
</PARA>
<ProgramListing>
-- Configure and execute a listen/notify sequence
-- from psql
CREATE TABLE t (i int4);
<computeroutput>
LISTEN t;
</computeroutput>
NOTIFY t;
<computeroutput>
NOTIFY
ASYNC NOTIFY of 't' from backend pid '10949' received
</computeroutput>
</ProgramListing>

</REFSECT1>

<REFSECT1 ID="R1-SQL-NOTIFY-3">
<TITLE>
Compatibility
</TITLE>
<PARA>


<REFSECT2 ID="R2-SQL-NOTIFY-4">
<REFSECT2INFO>
<DATE>1998-09-24</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
There is no <command>NOTIFY</command> statement in <acronym>SQL92</acronym>.

</REFENTRY>