Skip to content

Commit bccd690

Browse files
committed
Always make a BufferAccessStrategy for ANALYZE
32fbe02 changed things so we didn't bother allocating the BufferAccessStrategy during VACUUM (ONLY_DATABASE_STATS); and VACUUM (FULL), however, it forgot to consider that VACUUM (FULL, ANALYZE) is a possible combination. That change would have resulted in such a command allowing ANALYZE to make full use of shared buffers, which wasn't intended, so fix that. Reported-by: Melanie Plageman Discussion: https://postgr.es/m/CAAKRu_bJRKe+v_=OqwC+5sA3j5qv8rqdAwy3+yHaO3wmtfrCRg@mail.gmail.com
1 parent 1d477a9 commit bccd690

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/commands/vacuum.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,13 @@ vacuum(List *relations, VacuumParams *params,
393393
* If caller didn't give us a buffer strategy object, make one in the
394394
* cross-transaction memory context. We needn't bother making this for
395395
* VACUUM (FULL) or VACUUM (ONLY_DATABASE_STATS) as they'll not make use
396-
* of it.
396+
* of it. VACUUM (FULL, ANALYZE) is possible, so we'd better ensure that
397+
* we make a strategy when we see ANALYZE.
397398
*/
398399
if (bstrategy == NULL &&
399-
(params->options & (VACOPT_ONLY_DATABASE_STATS |
400-
VACOPT_FULL)) == 0)
400+
((params->options & (VACOPT_ONLY_DATABASE_STATS |
401+
VACOPT_FULL)) == 0 ||
402+
(params->options & VACOPT_ANALYZE) != 0))
401403
{
402404
MemoryContext old_context = MemoryContextSwitchTo(vac_context);
403405

0 commit comments

Comments
 (0)