diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-02-04 00:09:14 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-02-04 00:09:14 +0000 |
commit | 9727c583fe863252338dc4c5a925d78c59128c93 (patch) | |
tree | a5cc318744cccb7cb60565b2e0b11f7997cfde15 /src/backend/utils/cache/relcache.c | |
parent | fdac8cf998b9a41fa2b64cb3a80bc02548189082 (diff) | |
download | postgresql-9727c583fe863252338dc4c5a925d78c59128c93.tar.gz postgresql-9727c583fe863252338dc4c5a925d78c59128c93.zip |
Restructure CLUSTER/newstyle VACUUM FULL/ALTER TABLE support so that swapping
of old and new toast tables can be done either at the logical level (by
swapping the heaps' reltoastrelid links) or at the physical level (by swapping
the relfilenodes of the toast tables and their indexes). This is necessary
infrastructure for upcoming changes to support CLUSTER/VAC FULL on shared
system catalogs, where we cannot change reltoastrelid. The physical swap
saves a few catalog updates too.
We unfortunately have to keep the logical-level swap logic because in some
cases we will be adding or deleting a toast table, so there's no possibility
of a physical swap. However, that only happens as a consequence of schema
changes in the table, which we do not need to support for system catalogs,
so such cases aren't an obstacle for that.
In passing, refactor the cluster support functions a little bit to eliminate
unnecessarily-duplicated code; and fix the problem that while CLUSTER had
been taught to rename the final toast table at need, ALTER TABLE had not.
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r-- | src/backend/utils/cache/relcache.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index ba09331aba9..e71416c0f70 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.301 2010/02/03 01:14:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.302 2010/02/04 00:09:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1925,13 +1925,13 @@ RelationClearRelation(Relation relation, bool rebuild) * new entry, and this shouldn't happen often enough for that to be * a big problem. * - * When rebuilding an open relcache entry, we must preserve ref count - * and rd_createSubid/rd_newRelfilenodeSubid state. Also attempt to - * preserve the pg_class entry (rd_rel), tupledesc, and rewrite-rule - * substructures in place, because various places assume that these - * structures won't move while they are working with an open relcache - * entry. (Note: the refcount mechanism for tupledescs might someday - * allow us to remove this hack for the tupledesc.) + * When rebuilding an open relcache entry, we must preserve ref count, + * rd_createSubid/rd_newRelfilenodeSubid, and rd_toastoid state. Also + * attempt to preserve the pg_class entry (rd_rel), tupledesc, and + * rewrite-rule substructures in place, because various places assume + * that these structures won't move while they are working with an + * open relcache entry. (Note: the refcount mechanism for tupledescs + * might someday allow us to remove this hack for the tupledesc.) * * Note that this process does not touch CurrentResourceOwner; which * is good because whatever ref counts the entry may have do not @@ -2005,6 +2005,8 @@ RelationClearRelation(Relation relation, bool rebuild) SWAPFIELD(RuleLock *, rd_rules); SWAPFIELD(MemoryContext, rd_rulescxt); } + /* toast OID override must be preserved */ + SWAPFIELD(Oid, rd_toastoid); /* pgstat_info must be preserved */ SWAPFIELD(struct PgStat_TableStatus *, pgstat_info); |