From 9ee2f4f68fc9314d42244b16d5268324fe7aff53 Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Wed, 22 Feb 2023 12:06:41 -0500 Subject: [PATCH v6 2/6] remove global variable vac_strategy --- src/backend/commands/vacuum.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index c54360a6a0..a6aac30529 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -75,7 +75,6 @@ int vacuum_multixact_failsafe_age; /* A few variables that don't seem worth passing around as parameters */ static MemoryContext vac_context = NULL; -static BufferAccessStrategy vac_strategy; /* @@ -94,7 +93,7 @@ static void vac_truncate_clog(TransactionId frozenXID, TransactionId lastSaneFrozenXid, MultiXactId lastSaneMinMulti); static bool vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params, - bool skip_privs); + bool skip_privs, BufferAccessStrategy bstrategy); static double compute_parallel_delay(void); static VacOptValue get_vacoptval_from_boolean(DefElem *def); static bool vac_tid_reaped(ItemPointer itemptr, void *state); @@ -338,7 +337,7 @@ vacuum(List *relations, VacuumParams *params, in_outer_xact = IsInTransactionBlock(isTopLevel); /* - * Due to static variables vac_context, anl_context and vac_strategy, + * Due to static variable vac_context * vacuum() is not reentrant. This matters when VACUUM FULL or ANALYZE * calls a hostile index expression that itself calls ANALYZE. */ @@ -404,7 +403,6 @@ vacuum(List *relations, VacuumParams *params, bstrategy = GetAccessStrategy(BAS_VACUUM); MemoryContextSwitchTo(old_context); } - vac_strategy = bstrategy; /* * Build list of relation(s) to process, putting any new data in @@ -509,7 +507,7 @@ vacuum(List *relations, VacuumParams *params, if (params->options & VACOPT_VACUUM) { - if (!vacuum_rel(vrel->oid, vrel->relation, params, false)) + if (!vacuum_rel(vrel->oid, vrel->relation, params, false, bstrategy)) continue; } @@ -527,7 +525,7 @@ vacuum(List *relations, VacuumParams *params, } analyze_rel(vrel->oid, vrel->relation, params, - vrel->va_cols, in_outer_xact, vac_strategy); + vrel->va_cols, in_outer_xact, bstrategy); if (use_own_xacts) { @@ -1838,7 +1836,7 @@ vac_truncate_clog(TransactionId frozenXID, * At entry and exit, we are not inside a transaction. */ static bool -vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params, bool skip_privs) +vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params, bool skip_privs, BufferAccessStrategy bstrategy) { LOCKMODE lmode; Relation rel; @@ -2084,7 +2082,7 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params, bool skip_privs) cluster_rel(relid, InvalidOid, &cluster_params); } else - table_relation_vacuum(rel, params, vac_strategy); + table_relation_vacuum(rel, params, bstrategy); } /* Roll back any GUC changes executed by index functions */ @@ -2118,7 +2116,7 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params, bool skip_privs) memcpy(&toast_vacuum_params, params, sizeof(VacuumParams)); toast_vacuum_params.options |= VACOPT_PROCESS_MAIN; - vacuum_rel(toast_relid, NULL, &toast_vacuum_params, true); + vacuum_rel(toast_relid, NULL, &toast_vacuum_params, true, bstrategy); } /* -- 2.37.2