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

Commit c2d7d67

Browse files
committed
Ensure acquire_inherited_sample_rows sets its output parameters.
The totalrows/totaldeadrows outputs were left uninitialized in cases where we find no analyzable child tables of a partitioned table. This could lead to setting the partitioned table's pg_class.reltuples value to garbage. It's not clear that that would have any very bad effects in practice, but fix it anyway because it's making valgrind unhappy. Reported and diagnosed by Alexander Lakhin (bug #17880). Discussion: https://postgr.es/m/17880-9282037c923d856e@postgresql.org
1 parent 558fff0 commit c2d7d67

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/commands/analyze.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,10 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
13891389
ListCell *lc;
13901390
bool has_child;
13911391

1392+
/* Initialize output parameters to zero now, in case we exit early */
1393+
*totalrows = 0;
1394+
*totaldeadrows = 0;
1395+
13921396
/*
13931397
* Find all members of inheritance set. We only need AccessShareLock on
13941398
* the children.
@@ -1522,8 +1526,6 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
15221526
pgstat_progress_update_param(PROGRESS_ANALYZE_CHILD_TABLES_TOTAL,
15231527
nrels);
15241528
numrows = 0;
1525-
*totalrows = 0;
1526-
*totaldeadrows = 0;
15271529
for (i = 0; i < nrels; i++)
15281530
{
15291531
Relation childrel = rels[i];

0 commit comments

Comments
 (0)