7
7
* Portions Copyright (c) 1994, Regents of the University of California
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.63 2000/06/04 01:44:29 petere Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.64 2000/06/07 04:09:34 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -159,7 +159,6 @@ Async_Notify(char *relname)
159
159
/* no point in making duplicate entries in the list ... */
160
160
if (!AsyncExistsPendingNotify (relname ))
161
161
{
162
-
163
162
/*
164
163
* We allocate list memory from the global malloc pool to ensure
165
164
* that it will live until we want to use it. This is probably
@@ -202,7 +201,6 @@ Async_Listen(char *relname, int pid)
202
201
Datum d ;
203
202
int i ;
204
203
bool isnull ;
205
- int alreadyListener = 0 ;
206
204
TupleDesc tupDesc ;
207
205
208
206
if (Trace_notify )
@@ -212,25 +210,12 @@ Async_Listen(char *relname, int pid)
212
210
tdesc = RelationGetDescr (lRel );
213
211
214
212
/* Detect whether we are already listening on this relname */
215
- scan = heap_beginscan (lRel , 0 , SnapshotNow , 0 , (ScanKey ) NULL );
216
- while (HeapTupleIsValid (tuple = heap_getnext (scan , 0 )))
217
- {
218
- d = heap_getattr (tuple , Anum_pg_listener_relname , tdesc , & isnull );
219
- if (!strncmp ((char * ) DatumGetPointer (d ), relname , NAMEDATALEN ))
220
- {
221
- d = heap_getattr (tuple , Anum_pg_listener_pid , tdesc , & isnull );
222
- if (DatumGetInt32 (d ) == pid )
223
- {
224
- alreadyListener = 1 ;
225
- /* No need to scan the rest of the table */
226
- break ;
227
- }
228
- }
229
- }
230
- heap_endscan (scan );
231
-
232
- if (alreadyListener )
213
+ tuple = SearchSysCacheTuple (LISTENREL , Int32GetDatum (pid ),
214
+ PointerGetDatum (relname ),
215
+ 0 , 0 );
216
+ if (tuple != NULL )
233
217
{
218
+ /* No need to scan the rest of the table */
234
219
heap_close (lRel , AccessExclusiveLock );
235
220
elog (NOTICE , "Async_Listen: We are already listening on %s" , relname );
236
221
return ;
@@ -313,9 +298,9 @@ Async_Unlisten(char *relname, int pid)
313
298
314
299
lRel = heap_openr (ListenerRelationName , AccessExclusiveLock );
315
300
/* Note we assume there can be only one matching tuple. */
316
- lTuple = SearchSysCacheTuple (LISTENREL , PointerGetDatum ( relname ),
317
- Int32GetDatum ( pid ),
318
- 0 , 0 );
301
+ lTuple = SearchSysCacheTuple (LISTENREL , Int32GetDatum ( pid ),
302
+ PointerGetDatum ( relname ),
303
+ 0 , 0 );
319
304
if (lTuple != NULL )
320
305
heap_delete (lRel , & lTuple -> t_self , NULL );
321
306
heap_close (lRel , AccessExclusiveLock );
0 commit comments