7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.12 1997/01/24 23:48:25 scrappy Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.13 1997/03/10 00:18:09 scrappy Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
84
84
85
85
#include <port-protos.h> /* for strdup() */
86
86
87
+ #include <storage/lmgr.h>
88
+
87
89
static int notifyFrontEndPending = 0 ;
88
90
static int notifyIssued = 0 ;
89
91
static Dllist * pendingNotifies = NULL ;
@@ -194,6 +196,7 @@ Async_Notify(char *relname)
194
196
195
197
lRel = heap_openr (ListenerRelationName );
196
198
tdesc = RelationGetTupleDescriptor (lRel );
199
+ RelationSetLockForWrite (lRel );
197
200
sRel = heap_beginscan (lRel , 0 , NowTimeQual , 1 , & key );
198
201
199
202
nulls [0 ] = nulls [1 ] = nulls [2 ] = ' ' ;
@@ -212,6 +215,7 @@ Async_Notify(char *relname)
212
215
ReleaseBuffer (b );
213
216
}
214
217
heap_endscan (sRel );
218
+ RelationUnsetLockForWrite (lRel );
215
219
heap_close (lRel );
216
220
notifyIssued = 1 ;
217
221
}
@@ -269,6 +273,7 @@ Async_NotifyAtCommit()
269
273
Integer32EqualRegProcedure ,
270
274
Int32GetDatum (1 ));
271
275
lRel = heap_openr (ListenerRelationName );
276
+ RelationSetLockForWrite (lRel );
272
277
sRel = heap_beginscan (lRel , 0 , NowTimeQual , 1 , & key );
273
278
tdesc = RelationGetTupleDescriptor (lRel );
274
279
ourpid = getpid ();
@@ -302,6 +307,7 @@ Async_NotifyAtCommit()
302
307
ReleaseBuffer (b );
303
308
}
304
309
heap_endscan (sRel );
310
+ RelationUnsetLockForWrite (lRel );
305
311
heap_close (lRel );
306
312
307
313
CommitTransactionCommand ();
@@ -405,6 +411,7 @@ Async_Listen(char *relname, int pid)
405
411
values [i ++ ] = (Datum ) 0 ; /* no notifies pending */
406
412
407
413
lDesc = heap_openr (ListenerRelationName );
414
+ RelationSetLockForWrite (lDesc );
408
415
409
416
/* is someone already listening. One listener per relation */
410
417
tdesc = RelationGetTupleDescriptor (lDesc );
@@ -440,6 +447,8 @@ Async_Listen(char *relname, int pid)
440
447
/* if (alreadyListener) {
441
448
elog(NOTICE,"Async_Listen: already one listener on %s (possibly dead)",relname);
442
449
}*/
450
+
451
+ RelationUnsetLockForWrite (lDesc );
443
452
heap_close (lDesc );
444
453
445
454
/*
@@ -480,9 +489,13 @@ Async_Unlisten(char *relname, int pid)
480
489
Int32GetDatum (pid ),
481
490
0 ,0 );
482
491
lDesc = heap_openr (ListenerRelationName );
492
+ RelationSetLockForWrite (lDesc );
493
+
483
494
if (lTuple != NULL ) {
484
495
heap_delete (lDesc ,& lTuple -> t_ctid );
485
496
}
497
+
498
+ RelationUnsetLockForWrite (lDesc );
486
499
heap_close (lDesc );
487
500
}
488
501
@@ -549,6 +562,7 @@ Async_NotifyFrontEnd()
549
562
Integer32EqualRegProcedure ,
550
563
Int32GetDatum (ourpid ));
551
564
lRel = heap_openr (ListenerRelationName );
565
+ RelationSetLockForWrite (lRel );
552
566
tdesc = RelationGetTupleDescriptor (lRel );
553
567
sRel = heap_beginscan (lRel , 0 , NowTimeQual , 2 , key );
554
568
0 commit comments