postgres.git / summary / log / commit / refs

commit    3d8f71a370f0ad93762f140f6e69c2abe05b229a
Author:   Nathan Bossart <nathan@postgresql.org>
Date:     Mon Aug 17 18:17:12 2026 +0000

    Make autovacuum_enabled a ternary reloption.
    
    This commit reimplements autovacuum_enabled as a ternary, using the
    support added in commit 4d6a66f675 and following the example of
    vacuum_truncate.  This changes only the internal representation: an
    unset value still behaves as enabled, and the option accepts the
    same input as before.
    
    This is preparatory work for a follow-up commit that will make use
    of the new "unset" state.
    
    Reviewed-by: Michael Paquier <michael@paquier.xyz>
    Reviewed-by: Greg Burd <greg@burd.me>
    Reviewed-by: Sami Imseih <samimseih@gmail.com>
    Tested-by: solai v <solai.cdac@gmail.com>
    Discussion: https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan


src/backend/access/common/reloptions.c | 19 +++++++++---------- src/backend/catalog/index.c | 3 ++- src/backend/postmaster/autovacuum.c | 2 +- src/include/utils/rel.h | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 11ace24dd53..4481d83412f 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -107,15 +107,6 @@ static relopt_bool boolRelOpts[] = }, false }, - { - { - "autovacuum_enabled", - "Enables autovacuum in this relation", - RELOPT_KIND_HEAP | RELOPT_KIND_TOAST, - ShareUpdateExclusiveLock - }, - true - }, { { "user_catalog_table", @@ -168,6 +159,14 @@ static relopt_bool boolRelOpts[] = static relopt_ternary ternaryRelOpts[] = { + { + { + "autovacuum_enabled", + "Enables autovacuum in this relation", + RELOPT_KIND_HEAP | RELOPT_KIND_TOAST, + ShareUpdateExclusiveLock + } + }, { { "vacuum_truncate", @@ -1975,7 +1974,7 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind) { static const relopt_parse_elt tab[] = { {"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)}, - {"autovacuum_enabled", RELOPT_TYPE_BOOL, + {"autovacuum_enabled", RELOPT_TYPE_TERNARY, offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)}, {"autovacuum_parallel_workers", RELOPT_TYPE_INT, offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, autovacuum_parallel_workers)}, diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 4c5da7e5db0..ec21b83b6b8 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -2900,7 +2900,8 @@ index_update_stats(Relation rel, { StdRdOptions *options = (StdRdOptions *) rel->rd_options; - if (options != NULL && !options->autovacuum.enabled) + if (options != NULL && + options->autovacuum.enabled == PG_TERNARY_FALSE) update_stats = false; } else diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index b13908fe2c0..874454891d3 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -3146,7 +3146,7 @@ relation_needs_vacanalyze(Oid relid, ? Min(relopts->multixact_freeze_max_age, effective_multixact_freeze_max_age) : effective_multixact_freeze_max_age; - av_enabled = (relopts ? relopts->enabled : true); + av_enabled = (relopts ? relopts->enabled != PG_TERNARY_FALSE : true); av_enabled &= AutoVacuumingActive(); relfrozenxid = classForm->relfrozenxid; diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 674ac5a1cf4..ad7badf91da 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -310,7 +310,7 @@ typedef struct ForeignKeyCacheInfo /* autovacuum-related reloptions. */ typedef struct AutoVacOpts { - bool enabled; + pg_ternary enabled; int autovacuum_parallel_workers; int vacuum_threshold; [parent: 0499c6ccf5ce]