From e35af8098a81a80b82d25bee38ea7804eec2a9d0 Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Wed, 5 Apr 2023 20:02:10 -0400 Subject: [PATCH v12 1/4] VACUUM (FULL, ANALYZE) needs BufferAccessStrategy 4830f102 avoided making a BufferAccessStrategy when it would not be used, however we overlooked that the ANALYZE stage of VACUUM (FULL, ANALYZE) would still need the BufferAccessStrategy object. It didn't break because ReadBuffer_common() accepts NULL BufferAccessStrategy objects, but this was not the intended behavior. --- src/backend/commands/vacuum.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index da85330ef4..438e94410e 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -392,13 +392,14 @@ vacuum(List *relations, VacuumParams *params, /* * If caller didn't give us a buffer strategy object, make one in the * cross-transaction memory context. We needn't bother making this for - * VACUUM (FULL) or VACUUM (ONLY_DATABASE_STATS) as they'll not make use - * of it. + * VACUUM (ONLY_DATABASE_STATS) or VACUUM (FULL) without the ANALYZE + * option, as they'll not make use of it. */ if (bstrategy == NULL && - (params->options & (VACOPT_ONLY_DATABASE_STATS | - VACOPT_FULL)) == 0) + ((params->options & VACOPT_ONLY_DATABASE_STATS) == 0 && + ((params->options & VACOPT_FULL) == 0 || (params->options & VACOPT_ANALYZE)))) { + MemoryContext old_context = MemoryContextSwitchTo(vac_context); bstrategy = GetAccessStrategy(BAS_VACUUM); -- 2.37.2