From b4af70cb210393c9c8f41643acf6b213e21178e7 Mon Sep 17 00:00:00 2001 From: Peter Geoghegan Date: Mon, 5 Apr 2021 13:21:44 -0700 Subject: Simplify state managed by VACUUM. Reorganize the state struct used by VACUUM -- group related items together to make it easier to understand. Also stop relying on stack variables inside lazy_scan_heap() -- move those into the state struct instead. Doing things this way simplifies large groups of related functions whose function signatures had a lot of unnecessary redundancy. Switch over to using int64 for the struct fields used to count things that are reported to the user via log_autovacuum and VACUUM VERBOSE output. We were using double, but that doesn't seem to have any advantages. Using int64 makes it possible to add assertions that verify that the first pass over the heap (pruning) encounters precisely the same number of LP_DEAD items that get deleted from indexes later on, in the second pass over the heap. These assertions will be added in later commits. Finally, adjust the signatures of functions with IndexBulkDeleteResult pointer arguments in cases where there was ambiguity about whether or not the argument relates to a single index or all indexes. Functions now use the idiom that both ambulkdelete() and amvacuumcleanup() have always used (where appropriate): accept a mutable IndexBulkDeleteResult pointer argument, and return a result IndexBulkDeleteResult pointer to caller. Author: Peter Geoghegan Reviewed-By: Masahiko Sawada Reviewed-By: Robert Haas Discussion: https://postgr.es/m/CAH2-WzkeOSYwC6KNckbhk2b1aNnWum6Yyn0NKP9D-Hq1LGTDPw@mail.gmail.com --- src/include/access/genam.h | 4 ++-- src/include/access/heapam.h | 2 +- src/include/access/tableam.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/include') diff --git a/src/include/access/genam.h b/src/include/access/genam.h index 4515401869f..480a4762f52 100644 --- a/src/include/access/genam.h +++ b/src/include/access/genam.h @@ -177,11 +177,11 @@ extern bool index_getnext_slot(IndexScanDesc scan, ScanDirection direction, extern int64 index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap); extern IndexBulkDeleteResult *index_bulk_delete(IndexVacuumInfo *info, - IndexBulkDeleteResult *stats, + IndexBulkDeleteResult *istat, IndexBulkDeleteCallback callback, void *callback_state); extern IndexBulkDeleteResult *index_vacuum_cleanup(IndexVacuumInfo *info, - IndexBulkDeleteResult *stats); + IndexBulkDeleteResult *istat); extern bool index_can_return(Relation indexRelation, int attno); extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum); diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index d803f277877..ceb625e13ac 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -196,7 +196,7 @@ extern void heap_get_root_tuples(Page page, OffsetNumber *root_offsets); /* in heap/vacuumlazy.c */ struct VacuumParams; -extern void heap_vacuum_rel(Relation onerel, +extern void heap_vacuum_rel(Relation rel, struct VacuumParams *params, BufferAccessStrategy bstrategy); extern void parallel_vacuum_main(dsm_segment *seg, shm_toc *toc); diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 414b6b4d578..9f1e4a1ac96 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -625,7 +625,7 @@ typedef struct TableAmRoutine * There probably, in the future, needs to be a separate callback to * integrate with autovacuum's scheduling. */ - void (*relation_vacuum) (Relation onerel, + void (*relation_vacuum) (Relation rel, struct VacuumParams *params, BufferAccessStrategy bstrategy); -- cgit v1.2.3