Commit 63513b20 authored by Tom Lane's avatar Tom Lane

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.
parent 8a8fbe7e
...@@ -266,7 +266,6 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh) ...@@ -266,7 +266,6 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh)
Relation *Irel; Relation *Irel;
int nindexes; int nindexes;
bool hasindex; bool hasindex;
bool analyzableindex;
VacAttrStats **vacattrstats; VacAttrStats **vacattrstats;
AnlIndexData *indexdata; AnlIndexData *indexdata;
int targrows, int targrows,
...@@ -380,7 +379,6 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh) ...@@ -380,7 +379,6 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh)
} }
hasindex = (nindexes > 0); hasindex = (nindexes > 0);
indexdata = NULL; indexdata = NULL;
analyzableindex = false;
if (hasindex) if (hasindex)
{ {
indexdata = (AnlIndexData *) palloc0(nindexes * sizeof(AnlIndexData)); indexdata = (AnlIndexData *) palloc0(nindexes * sizeof(AnlIndexData));
...@@ -414,10 +412,7 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh) ...@@ -414,10 +412,7 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh)
thisdata->vacattrstats[tcnt] = thisdata->vacattrstats[tcnt] =
examine_attribute(Irel[ind], i + 1, indexkey); examine_attribute(Irel[ind], i + 1, indexkey);
if (thisdata->vacattrstats[tcnt] != NULL) if (thisdata->vacattrstats[tcnt] != NULL)
{
tcnt++; tcnt++;
analyzableindex = true;
}
} }
} }
thisdata->attr_cnt = tcnt; thisdata->attr_cnt = tcnt;
...@@ -425,16 +420,11 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh) ...@@ -425,16 +420,11 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh)
} }
} }
/*
* Quit if no analyzable columns.
*/
if (attr_cnt <= 0 && !analyzableindex)
goto cleanup;
/* /*
* Determine how many rows we need to sample, using the worst case from * Determine how many rows we need to sample, using the worst case from
* all analyzable columns. We use a lower bound of 100 rows to avoid * all analyzable columns. We use a lower bound of 100 rows to avoid
* possible overflow in Vitter's algorithm. * possible overflow in Vitter's algorithm. (Note: that will also be
* the target in the corner case where there are no analyzable columns.)
*/ */
targrows = 100; targrows = 100;
for (i = 0; i < attr_cnt; i++) for (i = 0; i < attr_cnt; i++)
...@@ -573,9 +563,6 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh) ...@@ -573,9 +563,6 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, bool inh)
if (!inh) if (!inh)
pgstat_report_analyze(onerel, totalrows, totaldeadrows); pgstat_report_analyze(onerel, totalrows, totaldeadrows);
/* We skip to here if there were no analyzable columns */
cleanup:
/* If this isn't part of VACUUM ANALYZE, let index AMs do cleanup */ /* If this isn't part of VACUUM ANALYZE, let index AMs do cleanup */
if (!(vacstmt->options & VACOPT_VACUUM)) if (!(vacstmt->options & VACOPT_VACUUM))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment