Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ee56048

Browse files
committed
Improve readability of code PROCESS_MAIN in vacuum_rel()
4211fbd has been handling PROCESS_MAIN in vacuum_rel() with an "if/else if" structure to avoid an extra level of indentation, but this has been found as being rather parse to read. This commit updates the code so as we check for PROCESS_MAIN in a single place and then handle its subpaths, FULL or non-FULL vacuums. Some comments are added to make that clearer for the reader. Reported-by: Melanie Plageman Author: Nathan Bossart Reviewed-by: Michael Paquier, Melanie Plageman Discussion: https://postgr.es/m/20230306194009.5cn6sp3wjotd36nu@liskov
1 parent 99be6fe commit ee56048

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/backend/commands/vacuum.c

+21-13
Original file line numberDiff line numberDiff line change
@@ -2058,25 +2058,33 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params, bool skip_privs)
20582058
save_nestlevel = NewGUCNestLevel();
20592059

20602060
/*
2061-
* Do the actual work --- either FULL or "lazy" vacuum
2061+
* If PROCESS_MAIN is set (the default), it's time to vacuum the main
2062+
* relation. Otherwise, we can skip this part. If processing the TOAST
2063+
* table is required (e.g., PROCESS_TOAST is set), we force PROCESS_MAIN
2064+
* to be set when we recurse to the TOAST table.
20622065
*/
2063-
if ((params->options & VACOPT_FULL) &&
2064-
(params->options & VACOPT_PROCESS_MAIN))
2066+
if (params->options & VACOPT_PROCESS_MAIN)
20652067
{
2066-
ClusterParams cluster_params = {0};
2068+
/*
2069+
* Do the actual work --- either FULL or "lazy" vacuum
2070+
*/
2071+
if (params->options & VACOPT_FULL)
2072+
{
2073+
ClusterParams cluster_params = {0};
20672074

2068-
/* close relation before vacuuming, but hold lock until commit */
2069-
relation_close(rel, NoLock);
2070-
rel = NULL;
2075+
/* close relation before vacuuming, but hold lock until commit */
2076+
relation_close(rel, NoLock);
2077+
rel = NULL;
20712078

2072-
if ((params->options & VACOPT_VERBOSE) != 0)
2073-
cluster_params.options |= CLUOPT_VERBOSE;
2079+
if ((params->options & VACOPT_VERBOSE) != 0)
2080+
cluster_params.options |= CLUOPT_VERBOSE;
20742081

2075-
/* VACUUM FULL is now a variant of CLUSTER; see cluster.c */
2076-
cluster_rel(relid, InvalidOid, &cluster_params);
2082+
/* VACUUM FULL is now a variant of CLUSTER; see cluster.c */
2083+
cluster_rel(relid, InvalidOid, &cluster_params);
2084+
}
2085+
else
2086+
table_relation_vacuum(rel, params, vac_strategy);
20772087
}
2078-
else if (params->options & VACOPT_PROCESS_MAIN)
2079-
table_relation_vacuum(rel, params, vac_strategy);
20802088

20812089
/* Roll back any GUC changes executed by index functions */
20822090
AtEOXact_GUC(false, save_nestlevel);

0 commit comments

Comments
 (0)