nbtree: fix read page recheck typo.
[pgsql.git] / src / backend / storage / freespace / indexfsm.c
blob35fb41ea7d604a9e3856d142a4ad7d1219364357
1 /*-------------------------------------------------------------------------
3 * indexfsm.c
4 * POSTGRES free space map for quickly finding free pages in relations
7 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * IDENTIFICATION
11 * src/backend/storage/freespace/indexfsm.c
14 * NOTES:
16 * This is similar to the FSM used for heap, in freespace.c, but instead
17 * of tracking the amount of free space on pages, we only track whether
18 * pages are completely free or in-use. We use the same FSM implementation
19 * as for heaps, using BLCKSZ - 1 to denote used pages, and 0 for unused.
21 *-------------------------------------------------------------------------
23 #include "postgres.h"
25 #include "storage/freespace.h"
26 #include "storage/indexfsm.h"
29 * Exported routines
33 * GetFreeIndexPage - return a free page from the FSM
35 * As a side effect, the page is marked as used in the FSM.
37 BlockNumber
38 GetFreeIndexPage(Relation rel)
40 BlockNumber blkno = GetPageWithFreeSpace(rel, BLCKSZ / 2);
42 if (blkno != InvalidBlockNumber)
43 RecordUsedIndexPage(rel, blkno);
45 return blkno;
49 * RecordFreeIndexPage - mark a page as free in the FSM
51 void
52 RecordFreeIndexPage(Relation rel, BlockNumber freeBlock)
54 RecordPageWithFreeSpace(rel, freeBlock, BLCKSZ - 1);
59 * RecordUsedIndexPage - mark a page as used in the FSM
61 void
62 RecordUsedIndexPage(Relation rel, BlockNumber usedBlock)
64 RecordPageWithFreeSpace(rel, usedBlock, 0);
68 * IndexFreeSpaceMapVacuum - scan and fix any inconsistencies in the FSM
70 void
71 IndexFreeSpaceMapVacuum(Relation rel)
73 FreeSpaceMapVacuum(rel);