mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-02 16:41:16 +02:00
Fix from Jan for vacuum statistics loss.
This commit is contained in:
parent
3037aace73
commit
54fd5f6cc4
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.89 1998/10/23 01:02:08 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.90 1998/10/23 16:49:24 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1792,8 +1792,16 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
|||||||
/* overwrite the existing statistics in the tuple */
|
/* overwrite the existing statistics in the tuple */
|
||||||
if (VacAttrStatsEqValid(stats))
|
if (VacAttrStatsEqValid(stats))
|
||||||
{
|
{
|
||||||
|
Buffer abuffer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We manipulate the heap tuple in the
|
||||||
|
* buffer, so we fetch it to get the
|
||||||
|
* buffer number
|
||||||
|
*/
|
||||||
|
atup = heap_fetch(ad, SnapshotNow, &atup->t_ctid, &abuffer);
|
||||||
vc_setpagelock(ad, ItemPointerGetBlockNumber(&atup->t_ctid));
|
vc_setpagelock(ad, ItemPointerGetBlockNumber(&atup->t_ctid));
|
||||||
|
attp = (Form_pg_attribute) GETSTRUCT(atup);
|
||||||
|
|
||||||
if (stats->nonnull_cnt + stats->null_cnt == 0 ||
|
if (stats->nonnull_cnt + stats->null_cnt == 0 ||
|
||||||
(stats->null_cnt <= 1 && stats->best_cnt == 1))
|
(stats->null_cnt <= 1 && stats->best_cnt == 1))
|
||||||
@ -1822,7 +1830,14 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
|||||||
if (selratio > 1.0)
|
if (selratio > 1.0)
|
||||||
selratio = 1.0;
|
selratio = 1.0;
|
||||||
attp->attdisbursion = selratio;
|
attp->attdisbursion = selratio;
|
||||||
WriteNoReleaseBuffer(ItemPointerGetBlockNumber(&atup->t_ctid));
|
|
||||||
|
/*
|
||||||
|
* Invalidate the cache for the tuple
|
||||||
|
* and write the buffer
|
||||||
|
*/
|
||||||
|
RelationInvalidateHeapTuple(ad, atup);
|
||||||
|
WriteNoReleaseBuffer(abuffer);
|
||||||
|
ReleaseBuffer(abuffer);
|
||||||
|
|
||||||
/* DO PG_STATISTIC INSERTS */
|
/* DO PG_STATISTIC INSERTS */
|
||||||
|
|
||||||
@ -1875,10 +1890,15 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
|||||||
heap_close(sd);
|
heap_close(sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Invalidate the cached pg_class tuple and
|
||||||
|
* write the buffer
|
||||||
|
*/
|
||||||
RelationInvalidateHeapTuple(rd, rtup);
|
RelationInvalidateHeapTuple(rd, rtup);
|
||||||
|
|
||||||
/* XXX -- after write, should invalidate relcache in other backends */
|
WriteNoReleaseBuffer(buffer);
|
||||||
WriteBuffer(ItemPointerGetBlockNumber(&rtup->t_ctid));
|
|
||||||
|
ReleaseBuffer(buffer);
|
||||||
|
|
||||||
heap_close(rd);
|
heap_close(rd);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user