Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9789c99

Browse files
committed
Cosmetic cleanup for commit a760893.
Mostly, fixing overlooked comments.
1 parent c2a2f75 commit 9789c99

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

src/backend/access/nbtree/nbtpage.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ _bt_page_recyclable(Page page)
715715
}
716716

717717
/*
718-
* Delete item(s) from a btree page.
718+
* Delete item(s) from a btree page during VACUUM.
719719
*
720720
* This must only be used for deleting leaf items. Deleting an item on a
721721
* non-leaf page has to be done as part of an atomic action that includes
@@ -736,7 +736,8 @@ _bt_page_recyclable(Page page)
736736
*/
737737
void
738738
_bt_delitems_vacuum(Relation rel, Buffer buf,
739-
OffsetNumber *itemnos, int nitems, BlockNumber lastBlockVacuumed)
739+
OffsetNumber *itemnos, int nitems,
740+
BlockNumber lastBlockVacuumed)
740741
{
741742
Page page = BufferGetPage(buf);
742743
BTPageOpaque opaque;
@@ -771,7 +772,6 @@ _bt_delitems_vacuum(Relation rel, Buffer buf,
771772
{
772773
XLogRecPtr recptr;
773774
XLogRecData rdata[2];
774-
775775
xl_btree_vacuum xlrec_vacuum;
776776

777777
xlrec_vacuum.node = rel->rd_node;
@@ -811,13 +811,27 @@ _bt_delitems_vacuum(Relation rel, Buffer buf,
811811
END_CRIT_SECTION();
812812
}
813813

814+
/*
815+
* Delete item(s) from a btree page during single-page cleanup.
816+
*
817+
* As above, must only be used on leaf pages.
818+
*
819+
* This routine assumes that the caller has pinned and locked the buffer.
820+
* Also, the given itemnos *must* appear in increasing order in the array.
821+
*
822+
* This is nearly the same as _bt_delitems_vacuum as far as what it does to
823+
* the page, but the WAL logging considerations are quite different. See
824+
* comments for _bt_delitems_vacuum.
825+
*/
814826
void
815827
_bt_delitems_delete(Relation rel, Buffer buf,
816-
OffsetNumber *itemnos, int nitems, Relation heapRel)
828+
OffsetNumber *itemnos, int nitems,
829+
Relation heapRel)
817830
{
818831
Page page = BufferGetPage(buf);
819832
BTPageOpaque opaque;
820833

834+
/* Shouldn't be called unless there's something to do */
821835
Assert(nitems > 0);
822836

823837
/* No ereport(ERROR) until changes are logged */
@@ -849,7 +863,6 @@ _bt_delitems_delete(Relation rel, Buffer buf,
849863
{
850864
XLogRecPtr recptr;
851865
XLogRecData rdata[3];
852-
853866
xl_btree_delete xlrec_delete;
854867

855868
xlrec_delete.node = rel->rd_node;
@@ -863,8 +876,9 @@ _bt_delitems_delete(Relation rel, Buffer buf,
863876
rdata[0].next = &(rdata[1]);
864877

865878
/*
866-
* We need the target-offsets array whether or not we store the to
867-
* allow us to find the latestRemovedXid on a standby server.
879+
* We need the target-offsets array whether or not we store the whole
880+
* buffer, to allow us to find the latestRemovedXid on a standby
881+
* server.
868882
*/
869883
rdata[1].data = (char *) itemnos;
870884
rdata[1].len = nitems * sizeof(OffsetNumber);

src/backend/access/nbtree/nbtree.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,14 +1004,15 @@ btvacuumpage(BTVacState *vstate, BlockNumber blkno, BlockNumber orig_blkno)
10041004
}
10051005

10061006
/*
1007-
* Apply any needed deletes. We issue just one _bt_delitems() call
1008-
* per page, so as to minimize WAL traffic.
1007+
* Apply any needed deletes. We issue just one _bt_delitems_vacuum()
1008+
* call per page, so as to minimize WAL traffic.
10091009
*/
10101010
if (ndeletable > 0)
10111011
{
10121012
BlockNumber lastBlockVacuumed = BufferGetBlockNumber(buf);
10131013

1014-
_bt_delitems_vacuum(rel, buf, deletable, ndeletable, vstate->lastBlockVacuumed);
1014+
_bt_delitems_vacuum(rel, buf, deletable, ndeletable,
1015+
vstate->lastBlockVacuumed);
10151016

10161017
/*
10171018
* Keep track of the block number of the lastBlockVacuumed, so we
@@ -1031,8 +1032,8 @@ btvacuumpage(BTVacState *vstate, BlockNumber blkno, BlockNumber orig_blkno)
10311032
/*
10321033
* If the page has been split during this vacuum cycle, it seems
10331034
* worth expending a write to clear btpo_cycleid even if we don't
1034-
* have any deletions to do. (If we do, _bt_delitems takes care
1035-
* of this.) This ensures we won't process the page again.
1035+
* have any deletions to do. (If we do, _bt_delitems_vacuum takes
1036+
* care of this.) This ensures we won't process the page again.
10361037
*
10371038
* We treat this like a hint-bit update because there's no need to
10381039
* WAL-log it.

src/backend/access/nbtree/nbtxlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ btree_xlog_vacuum(XLogRecPtr lsn, XLogRecord *record)
539539

540540
/*
541541
* Mark the page as not containing any LP_DEAD items --- see comments in
542-
* _bt_delitems().
542+
* _bt_delitems_vacuum().
543543
*/
544544
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
545545
opaque->btpo_flags &= ~BTP_HAS_GARBAGE;
@@ -720,7 +720,7 @@ btree_xlog_delete(XLogRecPtr lsn, XLogRecord *record)
720720

721721
/*
722722
* Mark the page as not containing any LP_DEAD items --- see comments in
723-
* _bt_delitems().
723+
* _bt_delitems_delete().
724724
*/
725725
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
726726
opaque->btpo_flags &= ~BTP_HAS_GARBAGE;

src/include/access/nbtree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,8 @@ extern bool _bt_page_recyclable(Page page);
635635
extern void _bt_delitems_delete(Relation rel, Buffer buf,
636636
OffsetNumber *itemnos, int nitems, Relation heapRel);
637637
extern void _bt_delitems_vacuum(Relation rel, Buffer buf,
638-
OffsetNumber *itemnos, int nitems, BlockNumber lastBlockVacuumed);
638+
OffsetNumber *itemnos, int nitems,
639+
BlockNumber lastBlockVacuumed);
639640
extern int _bt_pagedel(Relation rel, Buffer buf, BTStack stack);
640641

641642
/*

0 commit comments

Comments
 (0)