Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee56048

Browse files
committed
Improve readability of code PROCESS_MAIN in vacuum_rel()
4211fbd has been handling PROCESS_MAIN in vacuum_rel() with an "if/elseif" structure to avoid an extra level of indentation, but this has beenfound as being rather parse to read. This commit updates the code so aswe check for PROCESS_MAIN in a single place and then handle itssubpaths, FULL or non-FULL vacuums. Some comments are added to makethat clearer for the reader.Reported-by: Melanie PlagemanAuthor: Nathan BossartReviewed-by: Michael Paquier, Melanie PlagemanDiscussion:https://postgr.es/m/20230306194009.5cn6sp3wjotd36nu@liskov
1 parent99be6fe commitee56048

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

‎src/backend/commands/vacuum.c

Lines changed: 21 additions & 13 deletions
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-
ClusterParamscluster_params= {0};
2068+
/*
2069+
* Do the actual work --- either FULL or "lazy" vacuum
2070+
*/
2071+
if (params->options&VACOPT_FULL)
2072+
{
2073+
ClusterParamscluster_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-
elseif (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)

[8]ページ先頭

©2009-2025 Movatter.jp