From a9d0b6d6546c640630dd53d2b9f8d9c926044023 Mon Sep 17 00:00:00 2001
From: Lev Nikolaev <lev.nikolaev@tantorlabs.com>
Date: Mon, 30 Mar 2026 11:15:47 +0000
Subject: [PATCH] analyze: move elevel calculation into do_analyze_rel()

analyze_rel() computes elevel from params.options, but does not use it
directly and only passes it to do_analyze_rel().

Since do_analyze_rel() already receives params and derives verbose from
params.options, compute elevel there instead and remove the extra
function argument.

No behavioral change intended.
---
 src/backend/commands/analyze.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index eeed91be266..9a334d1d756 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -78,7 +78,7 @@ static BufferAccessStrategy vac_strategy;
 static void do_analyze_rel(Relation onerel,
 						   const VacuumParams params, List *va_cols,
 						   AcquireSampleRowsFunc acquirefunc, BlockNumber relpages,
-						   bool inh, bool in_outer_xact, int elevel);
+						   bool inh, bool in_outer_xact);
 static void compute_index_stats(Relation onerel, double totalrows,
 								AnlIndexData *indexdata, int nindexes,
 								HeapTuple *rows, int numrows,
@@ -111,16 +111,9 @@ analyze_rel(Oid relid, RangeVar *relation,
 			BufferAccessStrategy bstrategy)
 {
 	Relation	onerel;
-	int			elevel;
 	AcquireSampleRowsFunc acquirefunc = NULL;
 	BlockNumber relpages = 0;
 
-	/* Select logging level */
-	if (params.options & VACOPT_VERBOSE)
-		elevel = INFO;
-	else
-		elevel = DEBUG2;
-
 	/* Set up static variables */
 	vac_strategy = bstrategy;
 
@@ -253,14 +246,14 @@ analyze_rel(Oid relid, RangeVar *relation,
 	 */
 	if (onerel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
 		do_analyze_rel(onerel, params, va_cols, acquirefunc,
-					   relpages, false, in_outer_xact, elevel);
+					   relpages, false, in_outer_xact);
 
 	/*
 	 * If there are child tables, do recursive ANALYZE.
 	 */
 	if (onerel->rd_rel->relhassubclass)
 		do_analyze_rel(onerel, params, va_cols, acquirefunc, relpages,
-					   true, in_outer_xact, elevel);
+					   true, in_outer_xact);
 
 	/*
 	 * Close source relation now, but keep lock so that no one deletes it
@@ -283,8 +276,7 @@ analyze_rel(Oid relid, RangeVar *relation,
 static void
 do_analyze_rel(Relation onerel, const VacuumParams params,
 			   List *va_cols, AcquireSampleRowsFunc acquirefunc,
-			   BlockNumber relpages, bool inh, bool in_outer_xact,
-			   int elevel)
+			   BlockNumber relpages, bool inh, bool in_outer_xact)
 {
 	int			attr_cnt,
 				tcnt,
@@ -292,6 +284,7 @@ do_analyze_rel(Relation onerel, const VacuumParams params,
 				ind;
 	Relation   *Irel;
 	int			nindexes;
+	int			elevel;
 	bool		verbose,
 				instrument,
 				hasindex;
@@ -316,6 +309,13 @@ do_analyze_rel(Relation onerel, const VacuumParams params,
 	PgStat_Counter startwritetime = 0;
 
 	verbose = (params.options & VACOPT_VERBOSE) != 0;
+
+	/* Select logging level */
+	if (verbose)
+		elevel = INFO;
+	else
+		elevel = DEBUG2;
+
 	instrument = (verbose || (AmAutoVacuumWorkerProcess() &&
 							  params.log_analyze_min_duration >= 0));
 	if (inh)
-- 
2.34.1

