aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-03-08 17:03:31 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-03-08 17:03:31 +0000
commit2825337232afa1fe2d6de30d163d93beb0177e67 (patch)
tree646487e50d83d7f5d19273fe35f5111c45d7ac25 /src
parent2afb01dbde46b985d01d44122e441fcf66b22e78 (diff)
downloadpostgresql-2825337232afa1fe2d6de30d163d93beb0177e67.tar.gz
postgresql-2825337232afa1fe2d6de30d163d93beb0177e67.zip
Fix vac_update_relstats to ensure it always sends a relcache inval message,
even if none of the fields in the pg_class row change. This behavior is necessary to ensure other backends flush rd_targblock values that might point to truncated-away pages. We got this right pre-8.2 but it was broken by overoptimistic change to not write out the pg_class row if unchanged. Per report from Pavan Deolasee.
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/vacuum.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 804897821ce..d13090ebf72 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.346 2007/02/15 23:23:22 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.347 2007/03/08 17:03:31 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -715,10 +715,20 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples,
}
/*
- * If anything changed, write out the tuple
+ * If anything changed, write out the tuple. Even if nothing changed,
+ * force relcache invalidation so all backends reset their rd_targblock
+ * --- otherwise it might point to a page we truncated away.
*/
if (dirty)
+ {
heap_inplace_update(rd, ctup);
+ /* the above sends a cache inval message */
+ }
+ else
+ {
+ /* no need to change tuple, but force relcache inval anyway */
+ CacheInvalidateRelcacheByTuple(ctup);
+ }
heap_close(rd, RowExclusiveLock);
}