agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedFrom: Nathan Bossart <nathan@postgresql.org>
Subject: [PATCH v5 2/4] Make autovacuum_enabled a ternary reloption.
Date: Mon, 8 Jun 2026 14:50:36 -0500
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.
---
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 3e832c3797e..79834126f2f 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",
@@ -1976,7 +1975,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 9407c357f27..c9f32728902 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -2873,7 +2873,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 203a146b1c0..aa2aca8fc4b 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -3136,7 +3136,7 @@ relation_needs_vacanalyze(Oid relid,
? Min(avopts->multixact_freeze_max_age, effective_multixact_freeze_max_age)
: effective_multixact_freeze_max_age;
- av_enabled = (avopts ? avopts->enabled : true);
+ av_enabled = (avopts ? avopts->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 fa07ebf8ff7..f0824b6899a 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;
--
2.50.1 (Apple Git-155)
--FpyHeza52HC3lxIg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename=v5-0003-Add-an-unset-value-for-vacuum_index_cleanup.patch
view thread (360+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: nathan@postgresql.org
Subject: Re: [PATCH v5 2/4] Make autovacuum_enabled a ternary reloption.
In-Reply-To: <no-message-id-1733583@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox