PostgreSQL Source Code  git master
ginvacuum.c File Reference
#include "postgres.h"
#include "access/gin_private.h"
#include "access/ginxlog.h"
#include "access/xloginsert.h"
#include "commands/vacuum.h"
#include "miscadmin.h"
#include "postmaster/autovacuum.h"
#include "storage/indexfsm.h"
#include "storage/lmgr.h"
#include "storage/predicate.h"
#include "utils/memutils.h"
Include dependency graph for ginvacuum.c:

Go to the source code of this file.

Data Structures

struct  GinVacuumState
 
struct  DataPageDeleteStack
 

Typedefs

typedef struct DataPageDeleteStack DataPageDeleteStack
 

Functions

ItemPointer ginVacuumItemPointers (GinVacuumState *gvs, ItemPointerData *items, int nitem, int *nremaining)
 
static void xlogVacuumPage (Relation index, Buffer buffer)
 
static void ginDeletePage (GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkno, BlockNumber parentBlkno, OffsetNumber myoff, bool isParentRoot)
 
static bool ginScanToDelete (GinVacuumState *gvs, BlockNumber blkno, bool isRoot, DataPageDeleteStack *parent, OffsetNumber myoff)
 
static bool ginVacuumPostingTreeLeaves (GinVacuumState *gvs, BlockNumber blkno)
 
static void ginVacuumPostingTree (GinVacuumState *gvs, BlockNumber rootBlkno)
 
static Page ginVacuumEntryPage (GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint32 *nroot)
 
IndexBulkDeleteResultginbulkdelete (IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
 
IndexBulkDeleteResultginvacuumcleanup (IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
 

Typedef Documentation

◆ DataPageDeleteStack

Function Documentation

◆ ginbulkdelete()

IndexBulkDeleteResult* ginbulkdelete ( IndexVacuumInfo info,
IndexBulkDeleteResult stats,
IndexBulkDeleteCallback  callback,
void *  callback_state 
)

Definition at line 561 of file ginvacuum.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, DataPageDeleteStack::blkno, BufferGetPage, GinVacuumState::callback, GinVacuumState::callback_state, CurrentMemoryContext, END_CRIT_SECTION, FirstOffsetNumber, GIN_EXCLUSIVE, GIN_ROOT_BLKNO, GIN_SHARE, GIN_UNLOCK, GinGetDownlink, ginInsertCleanup(), GinPageGetOpaque, GinPageIsData, GinPageIsLeaf, GinVacuumState::ginstate, ginVacuumEntryPage(), ginVacuumPostingTree(), i, GinVacuumState::index, IndexVacuumInfo::index, initGinState(), InvalidBlockNumber, IsAutoVacuumWorkerProcess(), LockBuffer(), MAIN_FORKNUM, MarkBufferDirty(), MemoryContextDelete(), IndexBulkDeleteResult::num_index_tuples, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, PageRestoreTempPage(), palloc0(), RBM_NORMAL, ReadBufferExtended(), GinVacuumState::result, START_CRIT_SECTION, GinVacuumState::strategy, IndexVacuumInfo::strategy, GinVacuumState::tmpCxt, UnlockReleaseBuffer(), vacuum_delay_point(), and xlogVacuumPage().

Referenced by ginhandler().

563 {
564  Relation index = info->index;
565  BlockNumber blkno = GIN_ROOT_BLKNO;
566  GinVacuumState gvs;
567  Buffer buffer;
568  BlockNumber rootOfPostingTree[BLCKSZ / (sizeof(IndexTupleData) + sizeof(ItemId))];
569  uint32 nRoot;
570 
572  "Gin vacuum temporary context",
574  gvs.index = index;
575  gvs.callback = callback;
576  gvs.callback_state = callback_state;
577  gvs.strategy = info->strategy;
578  initGinState(&gvs.ginstate, index);
579 
580  /* first time through? */
581  if (stats == NULL)
582  {
583  /* Yes, so initialize stats to zeroes */
585 
586  /*
587  * and cleanup any pending inserts
588  */
590  false, true, stats);
591  }
592 
593  /* we'll re-count the tuples each time */
594  stats->num_index_tuples = 0;
595  gvs.result = stats;
596 
597  buffer = ReadBufferExtended(index, MAIN_FORKNUM, blkno,
598  RBM_NORMAL, info->strategy);
599 
600  /* find leaf page */
601  for (;;)
602  {
603  Page page = BufferGetPage(buffer);
604  IndexTuple itup;
605 
606  LockBuffer(buffer, GIN_SHARE);
607 
608  Assert(!GinPageIsData(page));
609 
610  if (GinPageIsLeaf(page))
611  {
612  LockBuffer(buffer, GIN_UNLOCK);
613  LockBuffer(buffer, GIN_EXCLUSIVE);
614 
615  if (blkno == GIN_ROOT_BLKNO && !GinPageIsLeaf(page))
616  {
617  LockBuffer(buffer, GIN_UNLOCK);
618  continue; /* check it one more */
619  }
620  break;
621  }
622 
624 
625  itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, FirstOffsetNumber));
626  blkno = GinGetDownlink(itup);
627  Assert(blkno != InvalidBlockNumber);
628 
629  UnlockReleaseBuffer(buffer);
630  buffer = ReadBufferExtended(index, MAIN_FORKNUM, blkno,
631  RBM_NORMAL, info->strategy);
632  }
633 
634  /* right now we found leftmost page in entry's BTree */
635 
636  for (;;)
637  {
638  Page page = BufferGetPage(buffer);
639  Page resPage;
640  uint32 i;
641 
642  Assert(!GinPageIsData(page));
643 
644  resPage = ginVacuumEntryPage(&gvs, buffer, rootOfPostingTree, &nRoot);
645 
646  blkno = GinPageGetOpaque(page)->rightlink;
647 
648  if (resPage)
649  {
651  PageRestoreTempPage(resPage, page);
652  MarkBufferDirty(buffer);
653  xlogVacuumPage(gvs.index, buffer);
654  UnlockReleaseBuffer(buffer);
656  }
657  else
658  {
659  UnlockReleaseBuffer(buffer);
660  }
661 
663 
664  for (i = 0; i < nRoot; i++)
665  {
666  ginVacuumPostingTree(&gvs, rootOfPostingTree[i]);
668  }
669 
670  if (blkno == InvalidBlockNumber) /* rightmost page */
671  break;
672 
673  buffer = ReadBufferExtended(index, MAIN_FORKNUM, blkno,
674  RBM_NORMAL, info->strategy);
675  LockBuffer(buffer, GIN_EXCLUSIVE);
676  }
677 
679 
680  return gvs.result;
681 }
#define GIN_UNLOCK
Definition: gin_private.h:48
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:211
#define AllocSetContextCreate
Definition: memutils.h:170
void PageRestoreTempPage(Page tempPage, Page oldPage)
Definition: bufpage.c:410
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1458
Relation index
Definition: ginvacuum.c:30
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Definition: bufmgr.c:642
BufferAccessStrategy strategy
Definition: ginvacuum.c:35
#define END_CRIT_SECTION()
Definition: miscadmin.h:134
BufferAccessStrategy strategy
Definition: genam.h:52
#define START_CRIT_SECTION()
Definition: miscadmin.h:132
Relation index
Definition: genam.h:46
uint32 BlockNumber
Definition: block.h:31
#define GinPageGetOpaque(page)
Definition: ginblock.h:110
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:357
IndexBulkDeleteResult * result
Definition: ginvacuum.c:31
Definition: type.h:89
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3398
static void xlogVacuumPage(Relation index, Buffer buffer)
Definition: ginvacuum.c:90
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
static Page ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint32 *nroot)
Definition: ginvacuum.c:452
IndexBulkDeleteCallback callback
Definition: ginvacuum.c:32
#define FirstOffsetNumber
Definition: off.h:27
IndexTupleData * IndexTuple
Definition: itup.h:53
void initGinState(GinState *state, Relation index)
Definition: ginutil.c:93
unsigned int uint32
Definition: c.h:359
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
#define GinPageIsLeaf(page)
Definition: ginblock.h:112
void * callback_state
Definition: ginvacuum.c:33
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
bool IsAutoVacuumWorkerProcess(void)
Definition: autovacuum.c:3276
#define GIN_SHARE
Definition: gin_private.h:49
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:235
void * palloc0(Size size)
Definition: mcxt.c:980
struct IndexTupleData IndexTupleData
#define GIN_EXCLUSIVE
Definition: gin_private.h:50
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3612
#define GinGetDownlink(itup)
Definition: ginblock.h:258
void ginInsertCleanup(GinState *ginstate, bool full_clean, bool fill_fsm, bool forceCleanup, IndexBulkDeleteResult *stats)
Definition: ginfast.c:780
#define GinPageIsData(page)
Definition: ginblock.h:115
#define Assert(condition)
Definition: c.h:739
#define InvalidBlockNumber
Definition: block.h:33
int i
static void ginVacuumPostingTree(GinVacuumState *gvs, BlockNumber rootBlkno)
Definition: ginvacuum.c:405
void vacuum_delay_point(void)
Definition: vacuum.c:1942
MemoryContext tmpCxt
Definition: ginvacuum.c:36
double num_index_tuples
Definition: genam.h:77
int Buffer
Definition: buf.h:23
#define PageGetItem(page, itemId)
Definition: bufpage.h:340
#define GIN_ROOT_BLKNO
Definition: ginblock.h:52
Pointer Page
Definition: bufpage.h:78
GinState ginstate
Definition: ginvacuum.c:34

◆ ginDeletePage()

static void ginDeletePage ( GinVacuumState gvs,
BlockNumber  deleteBlkno,
BlockNumber  leftBlkno,
BlockNumber  parentBlkno,
OffsetNumber  myoff,
bool  isParentRoot 
)
static

Definition at line 130 of file ginvacuum.c.

References Assert, BufferGetPage, ginxlogDeletePage::deleteXid, END_CRIT_SECTION, GinDataPageGetPostingItem, GinPageDeletePostingItem(), GinPageGetDeleteXid, GinPageGetOpaque, GinPageSetDeleted, GinPageSetDeleteXid, GinVacuumState::index, MAIN_FORKNUM, MarkBufferDirty(), IndexBulkDeleteResult::pages_deleted, PageSetLSN, ginxlogDeletePage::parentOffset, PostingItemGetBlockNumber, PredicateLockPageCombine(), RBM_NORMAL, ReadBufferExtended(), ReadNewTransactionId(), REGBUF_STANDARD, RelationNeedsWAL, ReleaseBuffer(), GinVacuumState::result, ginxlogDeletePage::rightLink, START_CRIT_SECTION, GinVacuumState::strategy, XLOG_GIN_DELETE_PAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().

Referenced by ginScanToDelete().

132 {
133  Buffer dBuffer;
134  Buffer lBuffer;
135  Buffer pBuffer;
136  Page page,
137  parentPage;
138  BlockNumber rightlink;
139 
140  /*
141  * This function MUST be called only if someone of parent pages hold
142  * exclusive cleanup lock. This guarantees that no insertions currently
143  * happen in this subtree. Caller also acquires Exclusive locks on
144  * deletable, parent and left pages.
145  */
146  lBuffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, leftBlkno,
147  RBM_NORMAL, gvs->strategy);
148  dBuffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, deleteBlkno,
149  RBM_NORMAL, gvs->strategy);
150  pBuffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, parentBlkno,
151  RBM_NORMAL, gvs->strategy);
152 
153  page = BufferGetPage(dBuffer);
154  rightlink = GinPageGetOpaque(page)->rightlink;
155 
156  /*
157  * Any insert which would have gone on the leaf block will now go to its
158  * right sibling.
159  */
160  PredicateLockPageCombine(gvs->index, deleteBlkno, rightlink);
161 
163 
164  /* Unlink the page by changing left sibling's rightlink */
165  page = BufferGetPage(lBuffer);
166  GinPageGetOpaque(page)->rightlink = rightlink;
167 
168  /* For deleted page remember last xid which could knew its address */
170 
171  /* Delete downlink from parent */
172  parentPage = BufferGetPage(pBuffer);
173 #ifdef USE_ASSERT_CHECKING
174  do
175  {
176  PostingItem *tod = GinDataPageGetPostingItem(parentPage, myoff);
177 
178  Assert(PostingItemGetBlockNumber(tod) == deleteBlkno);
179  } while (0);
180 #endif
181  GinPageDeletePostingItem(parentPage, myoff);
182 
183  page = BufferGetPage(dBuffer);
184 
185  /*
186  * we shouldn't change rightlink field to save workability of running
187  * search scan
188  */
189  GinPageSetDeleted(page);
190 
191  MarkBufferDirty(pBuffer);
192  MarkBufferDirty(lBuffer);
193  MarkBufferDirty(dBuffer);
194 
195  if (RelationNeedsWAL(gvs->index))
196  {
197  XLogRecPtr recptr;
198  ginxlogDeletePage data;
199 
200  /*
201  * We can't pass REGBUF_STANDARD for the deleted page, because we
202  * didn't set pd_lower on pre-9.4 versions. The page might've been
203  * binary-upgraded from an older version, and hence not have pd_lower
204  * set correctly. Ditto for the left page, but removing the item from
205  * the parent updated its pd_lower, so we know that's OK at this
206  * point.
207  */
208  XLogBeginInsert();
209  XLogRegisterBuffer(0, dBuffer, 0);
210  XLogRegisterBuffer(1, pBuffer, REGBUF_STANDARD);
211  XLogRegisterBuffer(2, lBuffer, 0);
212 
213  data.parentOffset = myoff;
214  data.rightLink = GinPageGetOpaque(page)->rightlink;
215  data.deleteXid = GinPageGetDeleteXid(page);
216 
217  XLogRegisterData((char *) &data, sizeof(ginxlogDeletePage));
218 
219  recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_DELETE_PAGE);
220  PageSetLSN(page, recptr);
221  PageSetLSN(parentPage, recptr);
222  PageSetLSN(BufferGetPage(lBuffer), recptr);
223  }
224 
225  ReleaseBuffer(pBuffer);
226  ReleaseBuffer(lBuffer);
227  ReleaseBuffer(dBuffer);
228 
230 
231  gvs->result->pages_deleted++;
232 }
TransactionId deleteXid
Definition: ginxlog.h:159
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1458
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:213
Relation index
Definition: ginvacuum.c:30
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Definition: bufmgr.c:642
BlockNumber rightLink
Definition: ginxlog.h:158
BufferAccessStrategy strategy
Definition: ginvacuum.c:35
#define END_CRIT_SECTION()
Definition: miscadmin.h:134
#define START_CRIT_SECTION()
Definition: miscadmin.h:132
#define GinPageGetDeleteXid(page)
Definition: ginblock.h:135
uint32 BlockNumber
Definition: block.h:31
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3375
#define GinPageGetOpaque(page)
Definition: ginblock.h:110
OffsetNumber parentOffset
Definition: ginxlog.h:157
IndexBulkDeleteResult * result
Definition: ginvacuum.c:31
#define GinDataPageGetPostingItem(page, i)
Definition: ginblock.h:299
#define REGBUF_STANDARD
Definition: xloginsert.h:35
BlockNumber pages_deleted
Definition: genam.h:79
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:323
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
void GinPageDeletePostingItem(Page page, OffsetNumber offset)
Definition: gindatapage.c:417
#define PostingItemGetBlockNumber(pointer)
Definition: ginblock.h:190
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:739
#define GinPageSetDeleteXid(page, xid)
Definition: ginblock.h:136
#define RelationNeedsWAL(relation)
Definition: rel.h:530
static TransactionId ReadNewTransactionId(void)
Definition: transam.h:244
#define GinPageSetDeleted(page)
Definition: ginblock.h:125
void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno)
Definition: predicate.c:3187
void XLogBeginInsert(void)
Definition: xloginsert.c:120
#define XLOG_GIN_DELETE_PAGE
Definition: ginxlog.h:153
#define PageSetLSN(page, lsn)
Definition: bufpage.h:368
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:78

◆ ginScanToDelete()

static bool ginScanToDelete ( GinVacuumState gvs,
BlockNumber  blkno,
bool  isRoot,
DataPageDeleteStack parent,
OffsetNumber  myoff 
)
static

Definition at line 243 of file ginvacuum.c.

References Assert, DataPageDeleteStack::blkno, BufferGetBlockNumber(), BufferGetPage, BufferIsValid, DataPageDeleteStack::child, FirstOffsetNumber, GIN_EXCLUSIVE, GIN_UNLOCK, GinDataLeafPageIsEmpty, GinDataPageGetPostingItem, ginDeletePage(), GinPageGetOpaque, GinPageIsData, GinPageIsLeaf, GinPageRightMost, i, GinVacuumState::index, InvalidBuffer, DataPageDeleteStack::isRoot, DataPageDeleteStack::leftBuffer, LockBuffer(), MAIN_FORKNUM, palloc0(), DataPageDeleteStack::parent, PostingItemGetBlockNumber, RBM_NORMAL, ReadBufferExtended(), ReleaseBuffer(), GinVacuumState::strategy, and UnlockReleaseBuffer().

Referenced by ginVacuumPostingTree().

245 {
247  Buffer buffer;
248  Page page;
249  bool meDelete = false;
250  bool isempty;
251 
252  if (isRoot)
253  {
254  me = parent;
255  }
256  else
257  {
258  if (!parent->child)
259  {
261  me->parent = parent;
262  parent->child = me;
264  }
265  else
266  me = parent->child;
267  }
268 
269  buffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, blkno,
270  RBM_NORMAL, gvs->strategy);
271 
272  if (!isRoot)
273  LockBuffer(buffer, GIN_EXCLUSIVE);
274 
275  page = BufferGetPage(buffer);
276 
277  Assert(GinPageIsData(page));
278 
279  if (!GinPageIsLeaf(page))
280  {
281  OffsetNumber i;
282 
283  me->blkno = blkno;
284  for (i = FirstOffsetNumber; i <= GinPageGetOpaque(page)->maxoff; i++)
285  {
286  PostingItem *pitem = GinDataPageGetPostingItem(page, i);
287 
288  if (ginScanToDelete(gvs, PostingItemGetBlockNumber(pitem), false, me, i))
289  i--;
290  }
291 
292  if (GinPageRightMost(page) && BufferIsValid(me->child->leftBuffer))
293  {
296  }
297  }
298 
299  if (GinPageIsLeaf(page))
300  isempty = GinDataLeafPageIsEmpty(page);
301  else
302  isempty = GinPageGetOpaque(page)->maxoff < FirstOffsetNumber;
303 
304  if (isempty)
305  {
306  /* we never delete the left- or rightmost branch */
307  if (BufferIsValid(me->leftBuffer) && !GinPageRightMost(page))
308  {
309  Assert(!isRoot);
311  me->parent->blkno, myoff, me->parent->isRoot);
312  meDelete = true;
313  }
314  }
315 
316  if (!meDelete)
317  {
318  if (BufferIsValid(me->leftBuffer))
320  me->leftBuffer = buffer;
321  }
322  else
323  {
324  if (!isRoot)
325  LockBuffer(buffer, GIN_UNLOCK);
326 
327  ReleaseBuffer(buffer);
328  }
329 
330  if (isRoot)
331  ReleaseBuffer(buffer);
332 
333  return meDelete;
334 }
#define GIN_UNLOCK
Definition: gin_private.h:48
Relation index
Definition: ginvacuum.c:30
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Definition: bufmgr.c:642
BufferAccessStrategy strategy
Definition: ginvacuum.c:35
#define InvalidBuffer
Definition: buf.h:25
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3375
#define GinPageGetOpaque(page)
Definition: ginblock.h:110
static void ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkno, BlockNumber parentBlkno, OffsetNumber myoff, bool isParentRoot)
Definition: ginvacuum.c:130
#define GinDataLeafPageIsEmpty(page)
Definition: ginblock.h:284
uint16 OffsetNumber
Definition: off.h:24
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3398
#define GinPageRightMost(page)
Definition: ginblock.h:129
#define GinDataPageGetPostingItem(page, i)
Definition: ginblock.h:299
BlockNumber blkno
Definition: ginvacuum.c:119
#define FirstOffsetNumber
Definition: off.h:27
#define GinPageIsLeaf(page)
Definition: ginblock.h:112
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
void * palloc0(Size size)
Definition: mcxt.c:980
#define GIN_EXCLUSIVE
Definition: gin_private.h:50
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3612
struct DataPageDeleteStack * child
Definition: ginvacuum.c:116
#define GinPageIsData(page)
Definition: ginblock.h:115
#define PostingItemGetBlockNumber(pointer)
Definition: ginblock.h:190
#define Assert(condition)
Definition: c.h:739
struct DataPageDeleteStack * parent
Definition: ginvacuum.c:117
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2623
int i
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:78
static bool ginScanToDelete(GinVacuumState *gvs, BlockNumber blkno, bool isRoot, DataPageDeleteStack *parent, OffsetNumber myoff)
Definition: ginvacuum.c:243

◆ ginvacuumcleanup()

IndexBulkDeleteResult* ginvacuumcleanup ( IndexVacuumInfo info,
IndexBulkDeleteResult stats 
)

Definition at line 684 of file ginvacuum.c.

References IndexVacuumInfo::analyze_only, Assert, DataPageDeleteStack::blkno, BufferGetPage, IndexVacuumInfo::estimated_count, IndexBulkDeleteResult::estimated_count, ExclusiveLock, GIN_ROOT_BLKNO, GIN_SHARE, ginInsertCleanup(), GinPageIsData, GinPageIsLeaf, GinPageIsList, GinPageIsRecyclable, GinVacuumState::ginstate, ginUpdateStats(), IndexVacuumInfo::index, IndexFreeSpaceMapVacuum(), initGinState(), IsAutoVacuumWorkerProcess(), LockBuffer(), LockRelationForExtension(), MAIN_FORKNUM, GinStatsData::nDataPages, GinStatsData::nEntries, GinStatsData::nEntryPages, GinStatsData::nTotalPages, IndexVacuumInfo::num_heap_tuples, IndexBulkDeleteResult::num_index_tuples, IndexBulkDeleteResult::num_pages, PageGetMaxOffsetNumber, IndexBulkDeleteResult::pages_free, palloc0(), RBM_NORMAL, ReadBufferExtended(), RecordFreeIndexPage(), RELATION_IS_LOCAL, RelationGetNumberOfBlocks, IndexVacuumInfo::strategy, UnlockRelationForExtension(), UnlockReleaseBuffer(), and vacuum_delay_point().

Referenced by ginhandler().

685 {
686  Relation index = info->index;
687  bool needLock;
688  BlockNumber npages,
689  blkno;
690  BlockNumber totFreePages;
691  GinState ginstate;
692  GinStatsData idxStat;
693 
694  /*
695  * In an autovacuum analyze, we want to clean up pending insertions.
696  * Otherwise, an ANALYZE-only call is a no-op.
697  */
698  if (info->analyze_only)
699  {
701  {
702  initGinState(&ginstate, index);
703  ginInsertCleanup(&ginstate, false, true, true, stats);
704  }
705  return stats;
706  }
707 
708  /*
709  * Set up all-zero stats and cleanup pending inserts if ginbulkdelete
710  * wasn't called
711  */
712  if (stats == NULL)
713  {
715  initGinState(&ginstate, index);
717  false, true, stats);
718  }
719 
720  memset(&idxStat, 0, sizeof(idxStat));
721 
722  /*
723  * XXX we always report the heap tuple count as the number of index
724  * entries. This is bogus if the index is partial, but it's real hard to
725  * tell how many distinct heap entries are referenced by a GIN index.
726  */
727  stats->num_index_tuples = info->num_heap_tuples;
728  stats->estimated_count = info->estimated_count;
729 
730  /*
731  * Need lock unless it's local to this backend.
732  */
733  needLock = !RELATION_IS_LOCAL(index);
734 
735  if (needLock)
737  npages = RelationGetNumberOfBlocks(index);
738  if (needLock)
740 
741  totFreePages = 0;
742 
743  for (blkno = GIN_ROOT_BLKNO; blkno < npages; blkno++)
744  {
745  Buffer buffer;
746  Page page;
747 
749 
750  buffer = ReadBufferExtended(index, MAIN_FORKNUM, blkno,
751  RBM_NORMAL, info->strategy);
752  LockBuffer(buffer, GIN_SHARE);
753  page = (Page) BufferGetPage(buffer);
754 
755  if (GinPageIsRecyclable(page))
756  {
757  Assert(blkno != GIN_ROOT_BLKNO);
758  RecordFreeIndexPage(index, blkno);
759  totFreePages++;
760  }
761  else if (GinPageIsData(page))
762  {
763  idxStat.nDataPages++;
764  }
765  else if (!GinPageIsList(page))
766  {
767  idxStat.nEntryPages++;
768 
769  if (GinPageIsLeaf(page))
770  idxStat.nEntries += PageGetMaxOffsetNumber(page);
771  }
772 
773  UnlockReleaseBuffer(buffer);
774  }
775 
776  /* Update the metapage with accurate page and entry counts */
777  idxStat.nTotalPages = npages;
778  ginUpdateStats(info->index, &idxStat, false);
779 
780  /* Finally, vacuum the FSM */
782 
783  stats->pages_free = totFreePages;
784 
785  if (needLock)
787  stats->num_pages = RelationGetNumberOfBlocks(index);
788  if (needLock)
790 
791  return stats;
792 }
BlockNumber nEntryPages
Definition: gin.h:45
#define GinPageIsRecyclable(page)
Definition: ginblock.h:137
#define ExclusiveLock
Definition: lockdefs.h:44
#define RELATION_IS_LOCAL(relation)
Definition: rel.h:548
bool analyze_only
Definition: genam.h:47
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Definition: bufmgr.c:642
BufferAccessStrategy strategy
Definition: genam.h:52
Relation index
Definition: genam.h:46
int64 nEntries
Definition: gin.h:47
uint32 BlockNumber
Definition: block.h:31
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:357
Definition: type.h:89
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3398
BlockNumber num_pages
Definition: genam.h:74
BlockNumber pages_free
Definition: genam.h:80
void initGinState(GinState *state, Relation index)
Definition: ginutil.c:93
#define GinPageIsLeaf(page)
Definition: ginblock.h:112
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
bool IsAutoVacuumWorkerProcess(void)
Definition: autovacuum.c:3276
#define GIN_SHARE
Definition: gin_private.h:49
void LockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:402
void * palloc0(Size size)
Definition: mcxt.c:980
void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:452
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3612
#define RelationGetNumberOfBlocks(reln)
Definition: bufmgr.h:198
BlockNumber nDataPages
Definition: gin.h:46
void ginInsertCleanup(GinState *ginstate, bool full_clean, bool fill_fsm, bool forceCleanup, IndexBulkDeleteResult *stats)
Definition: ginfast.c:780
#define GinPageIsData(page)
Definition: ginblock.h:115
double num_heap_tuples
Definition: genam.h:51
#define Assert(condition)
Definition: c.h:739
void IndexFreeSpaceMapVacuum(Relation rel)
Definition: indexfsm.c:71
#define GinPageIsList(page)
Definition: ginblock.h:117
BlockNumber nTotalPages
Definition: gin.h:44
void ginUpdateStats(Relation index, const GinStatsData *stats, bool is_build)
Definition: ginutil.c:655
void vacuum_delay_point(void)
Definition: vacuum.c:1942
void RecordFreeIndexPage(Relation rel, BlockNumber freeBlock)
Definition: indexfsm.c:52
double num_index_tuples
Definition: genam.h:77
int Buffer
Definition: buf.h:23
bool estimated_count
Definition: genam.h:76
#define GIN_ROOT_BLKNO
Definition: ginblock.h:52
Pointer Page
Definition: bufpage.h:78
bool estimated_count
Definition: genam.h:49

◆ ginVacuumEntryPage()

static Page ginVacuumEntryPage ( GinVacuumState gvs,
Buffer  buffer,
BlockNumber roots,
uint32 nroot 
)
static

Definition at line 452 of file ginvacuum.c.

References attnum, BufferGetPage, elog, ERROR, FirstOffsetNumber, ginCompressPostingList(), GinFormTuple(), GinGetDownlink, GinGetNPosting, GinGetPosting, GinIsPostingTree, GinItupIsCompressed, GinMaxItemSize, ginPostingListDecode(), GinVacuumState::ginstate, gintuple_get_attrnum(), gintuple_get_key(), ginVacuumItemPointers(), i, GinVacuumState::index, IndexTupleSize, sort-test::key, PageAddItem, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, PageGetTempPageCopy(), PageIndexTupleDelete(), pfree(), RelationGetRelationName, and SizeOfGinPostingList.

Referenced by ginbulkdelete().

453 {
454  Page origpage = BufferGetPage(buffer),
455  tmppage;
456  OffsetNumber i,
457  maxoff = PageGetMaxOffsetNumber(origpage);
458 
459  tmppage = origpage;
460 
461  *nroot = 0;
462 
463  for (i = FirstOffsetNumber; i <= maxoff; i++)
464  {
465  IndexTuple itup = (IndexTuple) PageGetItem(tmppage, PageGetItemId(tmppage, i));
466 
467  if (GinIsPostingTree(itup))
468  {
469  /*
470  * store posting tree's roots for further processing, we can't
471  * vacuum it just now due to risk of deadlocks with scans/inserts
472  */
473  roots[*nroot] = GinGetDownlink(itup);
474  (*nroot)++;
475  }
476  else if (GinGetNPosting(itup) > 0)
477  {
478  int nitems;
479  ItemPointer items_orig;
480  bool free_items_orig;
481  ItemPointer items;
482 
483  /* Get list of item pointers from the tuple. */
484  if (GinItupIsCompressed(itup))
485  {
486  items_orig = ginPostingListDecode((GinPostingList *) GinGetPosting(itup), &nitems);
487  free_items_orig = true;
488  }
489  else
490  {
491  items_orig = (ItemPointer) GinGetPosting(itup);
492  nitems = GinGetNPosting(itup);
493  free_items_orig = false;
494  }
495 
496  /* Remove any items from the list that need to be vacuumed. */
497  items = ginVacuumItemPointers(gvs, items_orig, nitems, &nitems);
498 
499  if (free_items_orig)
500  pfree(items_orig);
501 
502  /* If any item pointers were removed, recreate the tuple. */
503  if (items)
504  {
506  Datum key;
507  GinNullCategory category;
508  GinPostingList *plist;
509  int plistsize;
510 
511  if (nitems > 0)
512  {
513  plist = ginCompressPostingList(items, nitems, GinMaxItemSize, NULL);
514  plistsize = SizeOfGinPostingList(plist);
515  }
516  else
517  {
518  plist = NULL;
519  plistsize = 0;
520  }
521 
522  /*
523  * if we already created a temporary page, make changes in
524  * place
525  */
526  if (tmppage == origpage)
527  {
528  /*
529  * On first difference, create a temporary copy of the
530  * page and copy the tuple's posting list to it.
531  */
532  tmppage = PageGetTempPageCopy(origpage);
533 
534  /* set itup pointer to new page */
535  itup = (IndexTuple) PageGetItem(tmppage, PageGetItemId(tmppage, i));
536  }
537 
538  attnum = gintuple_get_attrnum(&gvs->ginstate, itup);
539  key = gintuple_get_key(&gvs->ginstate, itup, &category);
540  itup = GinFormTuple(&gvs->ginstate, attnum, key, category,
541  (char *) plist, plistsize,
542  nitems, true);
543  if (plist)
544  pfree(plist);
545  PageIndexTupleDelete(tmppage, i);
546 
547  if (PageAddItem(tmppage, (Item) itup, IndexTupleSize(itup), i, false, false) != i)
548  elog(ERROR, "failed to add item to index page in \"%s\"",
550 
551  pfree(itup);
552  pfree(items);
553  }
554  }
555  }
556 
557  return (tmppage == origpage) ? NULL : tmppage;
558 }
GinPostingList * ginCompressPostingList(const ItemPointer ipd, int nipd, int maxsize, int *nwritten)
ItemPointer ginPostingListDecode(GinPostingList *plist, int *ndecoded)
void PageIndexTupleDelete(Page page, OffsetNumber offnum)
Definition: bufpage.c:726
Relation index
Definition: ginvacuum.c:30
Pointer Item
Definition: item.h:17
ItemPointer ginVacuumItemPointers(GinVacuumState *gvs, ItemPointerData *items, int nitem, int *nremaining)
Definition: ginvacuum.c:48
#define PageAddItem(page, item, size, offsetNumber, overwrite, is_heap)
Definition: bufpage.h:416
#define GinGetNPosting(itup)
Definition: ginblock.h:229
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:357
#define GinGetPosting(itup)
Definition: ginblock.h:239
#define GinItupIsCompressed(itup)
Definition: ginblock.h:240
uint16 OffsetNumber
Definition: off.h:24
ItemPointerData * ItemPointer
Definition: itemptr.h:49
void pfree(void *pointer)
Definition: mcxt.c:1056
#define ERROR
Definition: elog.h:43
signed char GinNullCategory
Definition: ginblock.h:207
OffsetNumber gintuple_get_attrnum(GinState *ginstate, IndexTuple tuple)
Definition: ginutil.c:222
#define FirstOffsetNumber
Definition: off.h:27
IndexTupleData * IndexTuple
Definition: itup.h:53
#define RelationGetRelationName(relation)
Definition: rel.h:462
Datum gintuple_get_key(GinState *ginstate, IndexTuple tuple, GinNullCategory *category)
Definition: ginutil.c:255
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:235
uintptr_t Datum
Definition: postgres.h:367
#define GinGetDownlink(itup)
Definition: ginblock.h:258
int16 attnum
Definition: pg_attribute.h:79
IndexTuple GinFormTuple(GinState *ginstate, OffsetNumber attnum, Datum key, GinNullCategory category, Pointer data, Size dataSize, int nipd, bool errorTooBig)
Definition: ginentrypage.c:45
#define GinIsPostingTree(itup)
Definition: ginblock.h:232
Page PageGetTempPageCopy(Page page)
Definition: bufpage.c:368
#define SizeOfGinPostingList(plist)
Definition: ginblock.h:343
#define GinMaxItemSize
Definition: ginblock.h:249
#define elog(elevel,...)
Definition: elog.h:228
int i
#define PageGetItem(page, itemId)
Definition: bufpage.h:340
Pointer Page
Definition: bufpage.h:78
#define IndexTupleSize(itup)
Definition: itup.h:71
GinState ginstate
Definition: ginvacuum.c:34

◆ ginVacuumItemPointers()

ItemPointer ginVacuumItemPointers ( GinVacuumState gvs,
ItemPointerData items,
int  nitem,
int *  nremaining 
)

Definition at line 48 of file ginvacuum.c.

References GinVacuumState::callback, GinVacuumState::callback_state, i, IndexBulkDeleteResult::num_index_tuples, palloc(), remaining, GinVacuumState::result, and IndexBulkDeleteResult::tuples_removed.

Referenced by ginVacuumEntryPage(), and ginVacuumPostingTreeLeaf().

50 {
51  int i,
52  remaining = 0;
53  ItemPointer tmpitems = NULL;
54 
55  /*
56  * Iterate over TIDs array
57  */
58  for (i = 0; i < nitem; i++)
59  {
60  if (gvs->callback(items + i, gvs->callback_state))
61  {
62  gvs->result->tuples_removed += 1;
63  if (!tmpitems)
64  {
65  /*
66  * First TID to be deleted: allocate memory to hold the
67  * remaining items.
68  */
69  tmpitems = palloc(sizeof(ItemPointerData) * nitem);
70  memcpy(tmpitems, items, sizeof(ItemPointerData) * i);
71  }
72  }
73  else
74  {
75  gvs->result->num_index_tuples += 1;
76  if (tmpitems)
77  tmpitems[remaining] = items[i];
78  remaining++;
79  }
80  }
81 
82  *nremaining = remaining;
83  return tmpitems;
84 }
int remaining
Definition: informix.c:667
double tuples_removed
Definition: genam.h:78
IndexBulkDeleteResult * result
Definition: ginvacuum.c:31
IndexBulkDeleteCallback callback
Definition: ginvacuum.c:32
void * callback_state
Definition: ginvacuum.c:33
void * palloc(Size size)
Definition: mcxt.c:949
int i
double num_index_tuples
Definition: genam.h:77

◆ ginVacuumPostingTree()

static void ginVacuumPostingTree ( GinVacuumState gvs,
BlockNumber  rootBlkno 
)
static

Definition at line 405 of file ginvacuum.c.

References DataPageDeleteStack::child, ginScanToDelete(), ginVacuumPostingTreeLeaves(), GinVacuumState::index, InvalidBuffer, InvalidOffsetNumber, DataPageDeleteStack::isRoot, DataPageDeleteStack::leftBuffer, LockBufferForCleanup(), MAIN_FORKNUM, pfree(), RBM_NORMAL, ReadBufferExtended(), GinVacuumState::strategy, and UnlockReleaseBuffer().

Referenced by ginbulkdelete().

406 {
407  if (ginVacuumPostingTreeLeaves(gvs, rootBlkno))
408  {
409  /*
410  * There is at least one empty page. So we have to rescan the tree
411  * deleting empty pages.
412  */
413  Buffer buffer;
414  DataPageDeleteStack root,
415  *ptr,
416  *tmp;
417 
418  buffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, rootBlkno,
419  RBM_NORMAL, gvs->strategy);
420 
421  /*
422  * Lock posting tree root for cleanup to ensure there are no
423  * concurrent inserts.
424  */
425  LockBufferForCleanup(buffer);
426 
427  memset(&root, 0, sizeof(DataPageDeleteStack));
428  root.leftBuffer = InvalidBuffer;
429  root.isRoot = true;
430 
431  ginScanToDelete(gvs, rootBlkno, true, &root, InvalidOffsetNumber);
432 
433  ptr = root.child;
434 
435  while (ptr)
436  {
437  tmp = ptr->child;
438  pfree(ptr);
439  ptr = tmp;
440  }
441 
442  UnlockReleaseBuffer(buffer);
443  }
444 }
void LockBufferForCleanup(Buffer buffer)
Definition: bufmgr.c:3669
Relation index
Definition: ginvacuum.c:30
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Definition: bufmgr.c:642
BufferAccessStrategy strategy
Definition: ginvacuum.c:35
#define InvalidBuffer
Definition: buf.h:25
void pfree(void *pointer)
Definition: mcxt.c:1056
static bool ginVacuumPostingTreeLeaves(GinVacuumState *gvs, BlockNumber blkno)
Definition: ginvacuum.c:342
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3398
struct DataPageDeleteStack * child
Definition: ginvacuum.c:116
#define InvalidOffsetNumber
Definition: off.h:26
int Buffer
Definition: buf.h:23
static bool ginScanToDelete(GinVacuumState *gvs, BlockNumber blkno, bool isRoot, DataPageDeleteStack *parent, OffsetNumber myoff)
Definition: ginvacuum.c:243

◆ ginVacuumPostingTreeLeaves()

static bool ginVacuumPostingTreeLeaves ( GinVacuumState gvs,
BlockNumber  blkno 
)
static

Definition at line 342 of file ginvacuum.c.

References Assert, BufferGetPage, FirstOffsetNumber, GIN_EXCLUSIVE, GIN_SHARE, GIN_UNLOCK, GinDataLeafPageIsEmpty, GinDataPageGetPostingItem, GinPageGetOpaque, GinPageIsData, GinPageIsLeaf, ginVacuumPostingTreeLeaf(), GinVacuumState::index, InvalidBlockNumber, LockBuffer(), MAIN_FORKNUM, MemoryContextReset(), MemoryContextSwitchTo(), PageGetMaxOffsetNumber, PostingItemGetBlockNumber, RBM_NORMAL, ReadBufferExtended(), GinVacuumState::strategy, GinVacuumState::tmpCxt, and UnlockReleaseBuffer().

Referenced by ginVacuumPostingTree().

343 {
344  Buffer buffer;
345  Page page;
346  bool hasVoidPage = false;
347  MemoryContext oldCxt;
348 
349  /* Find leftmost leaf page of posting tree and lock it in exclusive mode */
350  while (true)
351  {
352  PostingItem *pitem;
353 
354  buffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, blkno,
355  RBM_NORMAL, gvs->strategy);
356  LockBuffer(buffer, GIN_SHARE);
357  page = BufferGetPage(buffer);
358 
359  Assert(GinPageIsData(page));
360 
361  if (GinPageIsLeaf(page))
362  {
363  LockBuffer(buffer, GIN_UNLOCK);
364  LockBuffer(buffer, GIN_EXCLUSIVE);
365  break;
366  }
367 
369 
371  blkno = PostingItemGetBlockNumber(pitem);
372  Assert(blkno != InvalidBlockNumber);
373 
374  UnlockReleaseBuffer(buffer);
375  }
376 
377  /* Iterate all posting tree leaves using rightlinks and vacuum them */
378  while (true)
379  {
380  oldCxt = MemoryContextSwitchTo(gvs->tmpCxt);
381  ginVacuumPostingTreeLeaf(gvs->index, buffer, gvs);
382  MemoryContextSwitchTo(oldCxt);
384 
385  if (GinDataLeafPageIsEmpty(page))
386  hasVoidPage = true;
387 
388  blkno = GinPageGetOpaque(page)->rightlink;
389 
390  UnlockReleaseBuffer(buffer);
391 
392  if (blkno == InvalidBlockNumber)
393  break;
394 
395  buffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, blkno,
396  RBM_NORMAL, gvs->strategy);
397  LockBuffer(buffer, GIN_EXCLUSIVE);
398  page = BufferGetPage(buffer);
399  }
400 
401  return hasVoidPage;
402 }
#define GIN_UNLOCK
Definition: gin_private.h:48
Relation index
Definition: ginvacuum.c:30
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Definition: bufmgr.c:642
BufferAccessStrategy strategy
Definition: ginvacuum.c:35
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:136
#define GinPageGetOpaque(page)
Definition: ginblock.h:110
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:357
#define GinDataLeafPageIsEmpty(page)
Definition: ginblock.h:284
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3398
#define GinDataPageGetPostingItem(page, i)
Definition: ginblock.h:299
void ginVacuumPostingTreeLeaf(Relation indexrel, Buffer buffer, GinVacuumState *gvs)
Definition: gindatapage.c:735
#define FirstOffsetNumber
Definition: off.h:27
#define GinPageIsLeaf(page)
Definition: ginblock.h:112
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define GIN_SHARE
Definition: gin_private.h:49
#define GIN_EXCLUSIVE
Definition: gin_private.h:50
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3612
#define GinPageIsData(page)
Definition: ginblock.h:115
#define PostingItemGetBlockNumber(pointer)
Definition: ginblock.h:190
#define Assert(condition)
Definition: c.h:739
#define InvalidBlockNumber
Definition: block.h:33
MemoryContext tmpCxt
Definition: ginvacuum.c:36
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:78

◆ xlogVacuumPage()

static void xlogVacuumPage ( Relation  index,
Buffer  buffer 
)
static

Definition at line 90 of file ginvacuum.c.

References Assert, BufferGetPage, GinPageIsData, GinPageIsLeaf, PageSetLSN, REGBUF_FORCE_IMAGE, REGBUF_STANDARD, RelationNeedsWAL, XLOG_GIN_VACUUM_PAGE, XLogBeginInsert(), XLogInsert(), and XLogRegisterBuffer().

Referenced by ginbulkdelete().

91 {
92  Page page = BufferGetPage(buffer);
93  XLogRecPtr recptr;
94 
95  /* This is only used for entry tree leaf pages. */
96  Assert(!GinPageIsData(page));
97  Assert(GinPageIsLeaf(page));
98 
99  if (!RelationNeedsWAL(index))
100  return;
101 
102  /*
103  * Always create a full image, we don't track the changes on the page at
104  * any more fine-grained level. This could obviously be improved...
105  */
106  XLogBeginInsert();
108 
109  recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_VACUUM_PAGE);
110  PageSetLSN(page, recptr);
111 }
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:213
#define REGBUF_STANDARD
Definition: xloginsert.h:35
#define GinPageIsLeaf(page)
Definition: ginblock.h:112
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define REGBUF_FORCE_IMAGE
Definition: xloginsert.h:31
#define XLOG_GIN_VACUUM_PAGE
Definition: ginxlog.h:135
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
#define GinPageIsData(page)
Definition: ginblock.h:115
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:739
#define RelationNeedsWAL(relation)
Definition: rel.h:530
void XLogBeginInsert(void)
Definition: xloginsert.c:120
#define PageSetLSN(page, lsn)
Definition: bufpage.h:368
Pointer Page
Definition: bufpage.h:78