Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit54fd5f6

Browse files
committed
Fix from Jan for vacuum statistics loss.
1 parent3037aac commit54fd5f6

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

‎src/backend/commands/vacuum.c‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.89 1998/10/2301:02:08 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.90 1998/10/2316:49:24 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1792,8 +1792,16 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
17921792
/* overwrite the existing statistics in the tuple */
17931793
if (VacAttrStatsEqValid(stats))
17941794
{
1795+
Bufferabuffer;
17951796

1797+
/*
1798+
* We manipulate the heap tuple in the
1799+
* buffer, so we fetch it to get the
1800+
* buffer number
1801+
*/
1802+
atup=heap_fetch(ad,SnapshotNow,&atup->t_ctid,&abuffer);
17961803
vc_setpagelock(ad,ItemPointerGetBlockNumber(&atup->t_ctid));
1804+
attp= (Form_pg_attribute)GETSTRUCT(atup);
17971805

17981806
if (stats->nonnull_cnt+stats->null_cnt==0||
17991807
(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 *
18221830
if (selratio>1.0)
18231831
selratio=1.0;
18241832
attp->attdisbursion=selratio;
1825-
WriteNoReleaseBuffer(ItemPointerGetBlockNumber(&atup->t_ctid));
1833+
1834+
/*
1835+
* Invalidate the cache for the tuple
1836+
* and write the buffer
1837+
*/
1838+
RelationInvalidateHeapTuple(ad,atup);
1839+
WriteNoReleaseBuffer(abuffer);
1840+
ReleaseBuffer(abuffer);
18261841

18271842
/* DO PG_STATISTIC INSERTS */
18281843

@@ -1875,10 +1890,15 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
18751890
heap_close(sd);
18761891
}
18771892

1893+
/*
1894+
* Invalidate the cached pg_class tuple and
1895+
* write the buffer
1896+
*/
18781897
RelationInvalidateHeapTuple(rd,rtup);
18791898

1880-
/* XXX -- after write, should invalidate relcache in other backends */
1881-
WriteBuffer(ItemPointerGetBlockNumber(&rtup->t_ctid));
1899+
WriteNoReleaseBuffer(buffer);
1900+
1901+
ReleaseBuffer(buffer);
18821902

18831903
heap_close(rd);
18841904
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp