diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-08-16 13:48:04 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-08-16 13:48:04 -0400 |
commit | 7b0d0e9356963d5c3e4d329a917f5fbb82a2ef05 (patch) | |
tree | 9f2c1e1539d421ceb937374310c0e87191e2e39b /src/backend/commands/cluster.c | |
parent | 2ada6779c5d3fcc31568ba263f8a0cc9bb8318c1 (diff) | |
download | postgresql-7b0d0e9356963d5c3e4d329a917f5fbb82a2ef05.tar.gz postgresql-7b0d0e9356963d5c3e4d329a917f5fbb82a2ef05.zip |
Preserve toast value OIDs in toast-swap-by-content for CLUSTER/VACUUM FULL.
This works around the problem that a catalog cache entry might contain a
toast pointer that we try to dereference just as a VACUUM FULL completes
on that catalog. We will see the sinval message on the cache entry when
we acquire lock on the toast table, but by that point we've already told
tuptoaster.c "here's the pointer to fetch", so it's difficult from a code
structural standpoint to update the pointer before we use it. Much less
painful to ensure that toast pointers are not invalidated in the first
place. We have to add a bit of code to deal with the case that a value
that previously wasn't toasted becomes so; but that should be a
seldom-exercised corner case, so the inefficiency shouldn't be significant.
Back-patch to 9.0. In prior versions, we didn't allow CLUSTER on system
catalogs, and VACUUM FULL didn't result in reassignment of toast OIDs, so
there was no problem.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r-- | src/backend/commands/cluster.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 9a7649bb4f9..670d29ea831 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -797,6 +797,10 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, * When doing swap by content, any toast pointers written into NewHeap * must use the old toast table's OID, because that's where the toast * data will eventually be found. Set this up by setting rd_toastoid. + * This also tells tuptoaster.c to preserve the toast value OIDs, + * which we want so as not to invalidate toast pointers in system + * catalog caches. + * * Note that we must hold NewHeap open until we are done writing data, * since the relcache will not guarantee to remember this setting once * the relation is closed. Also, this technique depends on the fact |