|
7 | 7 | * |
8 | 8 | * |
9 | 9 | * 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 $ |
11 | 11 | * |
12 | 12 | *------------------------------------------------------------------------- |
13 | 13 | */ |
@@ -1792,8 +1792,16 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats * |
1792 | 1792 | /* overwrite the existing statistics in the tuple */ |
1793 | 1793 | if (VacAttrStatsEqValid(stats)) |
1794 | 1794 | { |
| 1795 | +Bufferabuffer; |
1795 | 1796 |
|
| 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); |
1796 | 1803 | vc_setpagelock(ad,ItemPointerGetBlockNumber(&atup->t_ctid)); |
| 1804 | +attp= (Form_pg_attribute)GETSTRUCT(atup); |
1797 | 1805 |
|
1798 | 1806 | if (stats->nonnull_cnt+stats->null_cnt==0|| |
1799 | 1807 | (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 * |
1822 | 1830 | if (selratio>1.0) |
1823 | 1831 | selratio=1.0; |
1824 | 1832 | 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); |
1826 | 1841 |
|
1827 | 1842 | /* DO PG_STATISTIC INSERTS */ |
1828 | 1843 |
|
@@ -1875,10 +1890,15 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats * |
1875 | 1890 | heap_close(sd); |
1876 | 1891 | } |
1877 | 1892 |
|
| 1893 | +/* |
| 1894 | + * Invalidate the cached pg_class tuple and |
| 1895 | + * write the buffer |
| 1896 | + */ |
1878 | 1897 | RelationInvalidateHeapTuple(rd,rtup); |
1879 | 1898 |
|
1880 | | -/* XXX -- after write, should invalidate relcache in other backends */ |
1881 | | -WriteBuffer(ItemPointerGetBlockNumber(&rtup->t_ctid)); |
| 1899 | +WriteNoReleaseBuffer(buffer); |
| 1900 | + |
| 1901 | +ReleaseBuffer(buffer); |
1882 | 1902 |
|
1883 | 1903 | heap_close(rd); |
1884 | 1904 | } |
|