@@ -31,8 +31,6 @@ typedef struct
3131{
3232 IndexBulkDeleteResult stats ; /* must be first */
3333
34- IndexVacuumInfo * info ;
35-
3634 /*
3735 * These are used to memorize all internal and empty leaf pages in the 1st
3836 * vacuum stage. They are used in the 2nd stage, to delete all the empty
@@ -46,6 +44,7 @@ typedef struct
4644/* Working state needed by gistbulkdelete */
4745typedef struct
4846{
47+ IndexVacuumInfo * info ;
4948 GistBulkDeleteResult * stats ;
5049 IndexBulkDeleteCallback callback ;
5150 void * callback_state ;
@@ -56,8 +55,9 @@ static void gistvacuumscan(IndexVacuumInfo *info, GistBulkDeleteResult *stats,
5655 IndexBulkDeleteCallback callback , void * callback_state );
5756static void gistvacuumpage (GistVacState * vstate , BlockNumber blkno ,
5857 BlockNumber orig_blkno );
59- static void gistvacuum_delete_empty_pages (GistBulkDeleteResult * stats );
60- static bool gistdeletepage (GistBulkDeleteResult * stats ,
58+ static void gistvacuum_delete_empty_pages (IndexVacuumInfo * info ,
59+ GistBulkDeleteResult * stats );
60+ static bool gistdeletepage (IndexVacuumInfo * info , GistBulkDeleteResult * stats ,
6161 Buffer buffer , OffsetNumber downlink ,
6262 Buffer leafBuffer );
6363
@@ -121,7 +121,7 @@ gistvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
121121 * If we saw any empty pages, try to unlink them from the tree so that
122122 * they can be reused.
123123 */
124- gistvacuum_delete_empty_pages (gist_stats );
124+ gistvacuum_delete_empty_pages (info , gist_stats );
125125
126126 /* we don't need the internal and empty page sets anymore */
127127 MemoryContextDelete (gist_stats -> page_set_context );
@@ -183,7 +183,7 @@ gistvacuumscan(IndexVacuumInfo *info, GistBulkDeleteResult *stats,
183183 stats -> empty_leaf_set = intset_create ();
184184
185185 /* Set up info to pass down to gistvacuumpage */
186- stats -> info = info ;
186+ vstate . info = info ;
187187 vstate .stats = stats ;
188188 vstate .callback = callback ;
189189 vstate .callback_state = callback_state ;
@@ -269,7 +269,7 @@ static void
269269gistvacuumpage (GistVacState * vstate , BlockNumber blkno , BlockNumber orig_blkno )
270270{
271271 GistBulkDeleteResult * stats = vstate -> stats ;
272- IndexVacuumInfo * info = stats -> info ;
272+ IndexVacuumInfo * info = vstate -> info ;
273273 IndexBulkDeleteCallback callback = vstate -> callback ;
274274 void * callback_state = vstate -> callback_state ;
275275 Relation rel = info -> index ;
@@ -456,9 +456,8 @@ gistvacuumpage(GistVacState *vstate, BlockNumber blkno, BlockNumber orig_blkno)
456456 * Scan all internal pages, and try to delete their empty child pages.
457457 */
458458static void
459- gistvacuum_delete_empty_pages (GistBulkDeleteResult * stats )
459+ gistvacuum_delete_empty_pages (IndexVacuumInfo * info , GistBulkDeleteResult * stats )
460460{
461- IndexVacuumInfo * info = stats -> info ;
462461 Relation rel = info -> index ;
463462 BlockNumber empty_pages_remaining ;
464463 uint64 blkno ;
@@ -552,7 +551,9 @@ gistvacuum_delete_empty_pages(GistBulkDeleteResult *stats)
552551 gistcheckpage (rel , leafbuf );
553552
554553 LockBuffer (buffer , GIST_EXCLUSIVE );
555- if (gistdeletepage (stats , buffer , todelete [i ] - deleted , leafbuf ))
554+ if (gistdeletepage (info , stats ,
555+ buffer , todelete [i ] - deleted ,
556+ leafbuf ))
556557 deleted ++ ;
557558 LockBuffer (buffer , GIST_UNLOCK );
558559
@@ -585,7 +586,7 @@ gistvacuum_delete_empty_pages(GistBulkDeleteResult *stats)
585586 * prevented it.
586587 */
587588static bool
588- gistdeletepage (GistBulkDeleteResult * stats ,
589+ gistdeletepage (IndexVacuumInfo * info , GistBulkDeleteResult * stats ,
589590 Buffer parentBuffer , OffsetNumber downlink ,
590591 Buffer leafBuffer )
591592{
@@ -661,10 +662,10 @@ gistdeletepage(GistBulkDeleteResult *stats,
661662 MarkBufferDirty (parentBuffer );
662663 PageIndexTupleDelete (parentPage , downlink );
663664
664- if (RelationNeedsWAL (stats -> info -> index ))
665+ if (RelationNeedsWAL (info -> index ))
665666 recptr = gistXLogPageDelete (leafBuffer , txid , parentBuffer , downlink );
666667 else
667- recptr = gistGetFakeLSN (stats -> info -> index );
668+ recptr = gistGetFakeLSN (info -> index );
668669 PageSetLSN (parentPage , recptr );
669670 PageSetLSN (leafPage , recptr );
670671
0 commit comments