mirror of
https://github.com/postgres/postgres.git
synced 2025-07-24 14:22:24 +03:00
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.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.96 2010/01/02 16:57:35 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.97 2010/02/04 00:09:13 tgl Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -1185,10 +1185,25 @@ toast_save_datum(Relation rel, Datum value, int options)
|
||||
toast_pointer.va_extsize = data_todo;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert the correct table OID into the result TOAST pointer.
|
||||
*
|
||||
* Normally this is the actual OID of the target toast table, but during
|
||||
* table-rewriting operations such as CLUSTER, we have to insert the OID
|
||||
* of the table's real permanent toast table instead. rd_toastoid is
|
||||
* set if we have to substitute such an OID.
|
||||
*/
|
||||
if (OidIsValid(rel->rd_toastoid))
|
||||
toast_pointer.va_toastrelid = rel->rd_toastoid;
|
||||
else
|
||||
toast_pointer.va_toastrelid = RelationGetRelid(toastrel);
|
||||
|
||||
/*
|
||||
* Choose an unused OID within the toast table for this toast value.
|
||||
*/
|
||||
toast_pointer.va_valueid = GetNewOidWithIndex(toastrel,
|
||||
RelationGetRelid(toastidx),
|
||||
(AttrNumber) 1);
|
||||
toast_pointer.va_toastrelid = rel->rd_rel->reltoastrelid;
|
||||
|
||||
/*
|
||||
* Initialize constant parts of the tuple data
|
||||
|
Reference in New Issue
Block a user