summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Korotkov2024-04-08 09:11:56 +0000
committerAlexander Korotkov2024-04-08 09:18:23 +0000
commit422041542f313f23ca66cad26e9b2b99c4d1999a (patch)
tree3c50fd5dc0021eea4707ce065200439563f2ab18
parent3dbd2ff78654b2ac484a8d08ace788c492117894 (diff)
Fill CommonRdOptions with default values in extract_autovac_opts()
Reported-by: Thomas Munro Reported-by: Pavel Borisov Discussion: https://postgr.es/m/CA%2BhUKGLZzLR50RBvuqOO3MZ%3DF54ETz-rTp1PDX9uDGP_GqyYqA%40mail.gmail.com
-rw-r--r--src/backend/access/common/reloptions.c28
-rw-r--r--src/backend/postmaster/autovacuum.c1
-rw-r--r--src/backend/utils/cache/relcache.c21
-rw-r--r--src/include/access/reloptions.h1
4 files changed, 31 insertions, 20 deletions
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index c1de092a42d..24245f71728 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -2057,6 +2057,34 @@ view_reloptions(Datum reloptions, bool validate)
}
/*
+ * Fill CommonRdOptions with the default values.
+ */
+void
+fill_default_common_reloptions(CommonRdOptions *common)
+{
+ common->autovacuum.enabled = true;
+ common->autovacuum.vacuum_threshold = -1;
+ common->autovacuum.vacuum_ins_threshold = -2;
+ common->autovacuum.analyze_threshold = -1;
+ common->autovacuum.vacuum_cost_limit = -1;
+ common->autovacuum.freeze_min_age = -1;
+ common->autovacuum.freeze_max_age = -1;
+ common->autovacuum.freeze_table_age = -1;
+ common->autovacuum.multixact_freeze_min_age = -1;
+ common->autovacuum.multixact_freeze_max_age = -1;
+ common->autovacuum.multixact_freeze_table_age = -1;
+ common->autovacuum.log_min_duration = -1;
+ common->autovacuum.vacuum_cost_delay = -1;
+ common->autovacuum.vacuum_scale_factor = -1;
+ common->autovacuum.vacuum_ins_scale_factor = -1;
+ common->autovacuum.analyze_scale_factor = -1;
+ common->parallel_workers = -1;
+ common->user_catalog_table = false;
+ common->vacuum_index_cleanup = STDRD_OPTION_VACUUM_INDEX_CLEANUP_AUTO;
+ common->vacuum_truncate = true;
+}
+
+/*
* Parse options for heaps, views and toast tables.
*/
bytea *
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 7cb79ebcedd..170b973cc52 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -2681,6 +2681,7 @@ extract_autovac_opts(HeapTuple tup, TupleDesc pg_class_desc)
((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_MATVIEW ||
((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_TOASTVALUE);
+ fill_default_common_reloptions(&common);
relopts = extractRelOptions(tup, pg_class_desc,
GetTableAmRoutineByAmOid(((Form_pg_class) GETSTRUCT(tup))->relam),
NULL, &common);
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index f6f60c21fab..8fa09a5d755 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -480,26 +480,7 @@ RelationParseRelOptions(Relation relation, HeapTuple tuple)
{
common = MemoryContextAlloc(CacheMemoryContext,
sizeof(CommonRdOptions));
- common->autovacuum.enabled = true;
- common->autovacuum.vacuum_threshold = -1;
- common->autovacuum.vacuum_ins_threshold = -2;
- common->autovacuum.analyze_threshold = -1;
- common->autovacuum.vacuum_cost_limit = -1;
- common->autovacuum.freeze_min_age = -1;
- common->autovacuum.freeze_max_age = -1;
- common->autovacuum.freeze_table_age = -1;
- common->autovacuum.multixact_freeze_min_age = -1;
- common->autovacuum.multixact_freeze_max_age = -1;
- common->autovacuum.multixact_freeze_table_age = -1;
- common->autovacuum.log_min_duration = -1;
- common->autovacuum.vacuum_cost_delay = -1;
- common->autovacuum.vacuum_scale_factor = -1;
- common->autovacuum.vacuum_ins_scale_factor = -1;
- common->autovacuum.analyze_scale_factor = -1;
- common->parallel_workers = -1;
- common->user_catalog_table = false;
- common->vacuum_index_cleanup = STDRD_OPTION_VACUUM_INDEX_CLEANUP_AUTO;
- common->vacuum_truncate = true;
+ fill_default_common_reloptions(common);
relation->rd_common_options = common;
}
else
diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h
index 342b9cdd6ed..a3560500f36 100644
--- a/src/include/access/reloptions.h
+++ b/src/include/access/reloptions.h
@@ -236,6 +236,7 @@ extern void *build_reloptions(Datum reloptions, bool validate,
extern void *build_local_reloptions(local_relopts *relopts, Datum options,
bool validate);
+extern void fill_default_common_reloptions(CommonRdOptions *common);
extern bytea *heap_reloptions(char relkind, Datum reloptions,
CommonRdOptions *common, bool validate);
extern bytea *view_reloptions(Datum reloptions, bool validate);