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.
}
/*
- * 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);
}