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
ListCell *lc;
bool has_child;
+ /* Initialize output parameters to zero now, in case we exit early */
+ *totalrows = 0;
+ *totaldeadrows = 0;
+
/*
* Find all members of inheritance set. We only need AccessShareLock on
* the children.
pgstat_progress_update_param(PROGRESS_ANALYZE_CHILD_TABLES_TOTAL,
nrels);
numrows = 0;
- *totalrows = 0;
- *totaldeadrows = 0;
for (i = 0; i < nrels; i++)
{
Relation childrel = rels[i];