31
31
*
32
32
*
33
33
* IDENTIFICATION
34
- * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.47 2004/10/15 22:39:56 tgl Exp $
34
+ * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.48 2004/10/25 15:42:02 tgl Exp $
35
35
*
36
36
*-------------------------------------------------------------------------
37
37
*/
@@ -554,9 +554,12 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
554
554
vac_init_rusage (& ru0 );
555
555
556
556
/*
557
- * If index is unsafe for concurrent access, must lock it.
557
+ * Acquire appropriate type of lock on index: must be exclusive if
558
+ * index AM isn't concurrent-safe.
558
559
*/
559
- if (!indrel -> rd_am -> amconcurrent )
560
+ if (indrel -> rd_am -> amconcurrent )
561
+ LockRelation (indrel , RowExclusiveLock );
562
+ else
560
563
LockRelation (indrel , AccessExclusiveLock );
561
564
562
565
/*
@@ -576,7 +579,9 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
576
579
/*
577
580
* Release lock acquired above.
578
581
*/
579
- if (!indrel -> rd_am -> amconcurrent )
582
+ if (indrel -> rd_am -> amconcurrent )
583
+ UnlockRelation (indrel , RowExclusiveLock );
584
+ else
580
585
UnlockRelation (indrel , AccessExclusiveLock );
581
586
582
587
if (!stats )
@@ -619,9 +624,12 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats)
619
624
vac_init_rusage (& ru0 );
620
625
621
626
/*
622
- * If index is unsafe for concurrent access, must lock it.
627
+ * Acquire appropriate type of lock on index: must be exclusive if
628
+ * index AM isn't concurrent-safe.
623
629
*/
624
- if (!indrel -> rd_am -> amconcurrent )
630
+ if (indrel -> rd_am -> amconcurrent )
631
+ LockRelation (indrel , RowExclusiveLock );
632
+ else
625
633
LockRelation (indrel , AccessExclusiveLock );
626
634
627
635
/* Do bulk deletion */
@@ -636,7 +644,9 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats)
636
644
/*
637
645
* Release lock acquired above.
638
646
*/
639
- if (!indrel -> rd_am -> amconcurrent )
647
+ if (indrel -> rd_am -> amconcurrent )
648
+ UnlockRelation (indrel , RowExclusiveLock );
649
+ else
640
650
UnlockRelation (indrel , AccessExclusiveLock );
641
651
642
652
if (!stats )
0 commit comments