8000 Ensure acquire_inherited_sample_rows sets its output parameters. · postgres/postgres@e46a309 · GitHub
[go: up one dir, main page]

Skip to content

Commit e46a309

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 07554c9 commit e46a309

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/commands/analyze.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,10 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
13671367
ListCell *lc;
13681368
bool has_child;
13691369

1370+
/* Initialize output parameters to zero now, in case we exit early */
1371+
*totalrows = 0;
1372+
*totaldeadrows = 0;
1373+
13701374
/*
13711375
* Find all members of inheritance set. We only need AccessShareLock on
13721376
* the children.
@@ -1498,8 +1502,6 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
14981502
* clear that it's worth working harder.)
14991503
*/
15001504
numrows = 0;
1501-
*totalrows = 0;
1502-
*totaldeadrows = 0;
15031505
for (i = 0; i < nrels; i++)
15041506
{
15051507
Relation childrel = rels[i];

0 commit comments

Comments
 (0)
0