77 * Portions Copyright (c) 1994, Regents of the University of California
88 *
99 * IDENTIFICATION
10- * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.124 2005/08/20 00:39:53 tgl Exp $
10+ * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.125 2005/10/06 21:30:32 neilc Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -146,13 +146,10 @@ static void ClearPendingNotifies(void);
146146 *Actual notification happens during transaction commit.
147147 *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
148148 *
149- * Results:
150- *XXX
151- *
152149 *--------------------------------------------------------------
153150 */
154151void
155- Async_Notify (char * relname )
152+ Async_Notify (const char * relname )
156153{
157154if (Trace_notify )
158155elog (DEBUG1 ,"Async_Notify(%s)" ,relname );
@@ -180,19 +177,16 @@ Async_Notify(char *relname)
180177 *
181178 *This is executed by the SQL listen command.
182179 *
183- *Register a backend (identified by its Unix PID) as listening
184- *on the specified relation.
185- *
186- * Results:
187- *XXX
180+ *Register the current backend as listening on the specified
181+ *relation.
188182 *
189183 * Side effects:
190184 *pg_listener is updated.
191185 *
192186 *--------------------------------------------------------------
193187 */
194188void
195- Async_Listen (char * relname , int pid )
189+ Async_Listen (const char * relname )
196190{
197191Relation lRel ;
198192HeapScanDesc scan ;
@@ -203,7 +197,7 @@ Async_Listen(char *relname, int pid)
203197bool alreadyListener = false;
204198
205199if (Trace_notify )
206- elog (DEBUG1 ,"Async_Listen(%s,%d)" ,relname ,pid );
200+ elog (DEBUG1 ,"Async_Listen(%s,%d)" ,relname ,MyProcPid );
207201
208202lRel = heap_open (ListenerRelationId ,ExclusiveLock );
209203
@@ -213,7 +207,7 @@ Async_Listen(char *relname, int pid)
213207{
214208Form_pg_listener listener = (Form_pg_listener )GETSTRUCT (tuple );
215209
216- if (listener -> listenerpid == pid &&
210+ if (listener -> listenerpid == MyProcPid &&
217211strncmp (NameStr (listener -> relname ),relname ,NAMEDATALEN )== 0 )
218212{
219213alreadyListener = true;
@@ -241,7 +235,7 @@ Async_Listen(char *relname, int pid)
241235
242236i = 0 ;
243237values [i ++ ]= (Datum )relname ;
244- values [i ++ ]= (Datum )pid ;
238+ values [i ++ ]= (Datum )MyProcPid ;
245239values [i ++ ]= (Datum )0 ;/* no notifies pending */
246240
247241tuple = heap_formtuple (RelationGetDescr (lRel ),values ,nulls );
@@ -271,19 +265,16 @@ Async_Listen(char *relname, int pid)
271265 *
272266 *This is executed by the SQL unlisten command.
273267 *
274- *Remove the backend from the list of listening backends
268+ *Remove thecurrent backend from the list of listening backends
275269 *for the specified relation.
276270 *
277- * Results:
278- *XXX
279- *
280271 * Side effects:
281272 *pg_listener is updated.
282273 *
283274 *--------------------------------------------------------------
284275 */
285276void
286- Async_Unlisten (char * relname , int pid )
277+ Async_Unlisten (const char * relname )
287278{
288279Relation lRel ;
289280HeapScanDesc scan ;
@@ -297,7 +288,7 @@ Async_Unlisten(char *relname, int pid)
297288}
298289
299290if (Trace_notify )
300- elog (DEBUG1 ,"Async_Unlisten(%s,%d)" ,relname ,pid );
291+ elog (DEBUG1 ,"Async_Unlisten(%s,%d)" ,relname ,MyProcPid );
301292
302293lRel = heap_open (ListenerRelationId ,ExclusiveLock );
303294
@@ -306,7 +297,7 @@ Async_Unlisten(char *relname, int pid)
306297{
307298Form_pg_listener listener = (Form_pg_listener )GETSTRUCT (tuple );
308299
309- if (listener -> listenerpid == pid &&
300+ if (listener -> listenerpid == MyProcPid &&
310301strncmp (NameStr (listener -> relname ),relname ,NAMEDATALEN )== 0 )
311302{
312303/* Found the matching tuple, delete it */