Skip to content

Commit ccdce73

Browse files
committed
Fix thinko in previous patch to always update pg_class.reltuples/relpages.
I mis-simplified the test where ANALYZE decided if it could get away without doing anything: under the new regime, that's never allowed. Per bug #6068 from Jeff Janes. Back-patch to 8.4, just like previous patch.
1 parent ae7fc61 commit ccdce73

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/backend/commands/analyze.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh)
252252
Relation *Irel;
253253
int nindexes;
254254
bool hasindex;
255-
bool analyzableindex;
256255
VacAttrStats **vacattrstats;
257256
AnlIndexData *indexdata;
258257
int targrows,
@@ -366,7 +365,6 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh)
366365
}
367366
hasindex = (nindexes > 0);
368367
indexdata = NULL;
369-
analyzableindex = false;
370368
if (hasindex)
371369
{
372370
indexdata = (AnlIndexData *) palloc0(nindexes * sizeof(AnlIndexData));
@@ -400,27 +398,19 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh)
400398
thisdata->vacattrstats[tcnt] =
401399
examine_attribute(Irel[ind], i + 1, indexkey);
402400
if (thisdata->vacattrstats[tcnt] != NULL)
403-
{
404401
tcnt++;
405-
analyzableindex = true;
406-
}
407402
}
408403
}
409404
thisdata->attr_cnt = tcnt;
410405
}
411406
}
412407
}
413408

414-
/*
415-
* Quit if no analyzable columns.
416-
*/
417-
if (attr_cnt <= 0 && !analyzableindex)
418-
goto cleanup;
419-
420409
/*
421410
* Determine how many rows we need to sample, using the worst case from
422411
* all analyzable columns. We use a lower bound of 100 rows to avoid
423-
* possible overflow in Vitter's algorithm.
412+
* possible overflow in Vitter's algorithm. (Note: that will also be
413+
* the target in the corner case where there are no analyzable columns.)
424414
*/
425415
targrows = 100;
426416
for (i = 0; i < attr_cnt; i++)
@@ -559,9 +549,6 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh)
559549
if (!inh)
560550
pgstat_report_analyze(onerel, totalrows, totaldeadrows);
561551

562-
/* We skip to here if there were no analyzable columns */
563-
cleanup:
564-
565552
/* If this isn't part of VACUUM ANALYZE, let index AMs do cleanup */
566553
if (!(vacstmt->options & VACOPT_VACUUM))
567554
{

0 commit comments

Comments
 (0)