mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +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:
		@@ -7,7 +7,7 @@
 | 
			
		||||
 * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
 | 
			
		||||
 * Portions Copyright (c) 1994, Regents of the University of California
 | 
			
		||||
 *
 | 
			
		||||
 * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.120 2010/01/17 22:56:23 tgl Exp $
 | 
			
		||||
 * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.121 2010/02/04 00:09:14 tgl Exp $
 | 
			
		||||
 *
 | 
			
		||||
 *-------------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
@@ -202,6 +202,16 @@ typedef struct RelationData
 | 
			
		||||
	uint16	   *rd_exclstrats;	/* exclusion ops' strategy numbers, if any */
 | 
			
		||||
	void	   *rd_amcache;		/* available for use by index AM */
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Hack for CLUSTER, rewriting ALTER TABLE, etc: when writing a new
 | 
			
		||||
	 * version of a table, we need to make any toast pointers inserted into it
 | 
			
		||||
	 * have the existing toast table's OID, not the OID of the transient toast
 | 
			
		||||
	 * table.  If rd_toastoid isn't InvalidOid, it is the OID to place in
 | 
			
		||||
	 * toast pointers inserted into this rel.  (Note it's set on the new
 | 
			
		||||
	 * version of the main heap, not the toast table itself.)
 | 
			
		||||
	 */
 | 
			
		||||
	Oid			rd_toastoid;	/* Real TOAST table's OID, or InvalidOid */
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * sizes of the free space and visibility map forks, or InvalidBlockNumber
 | 
			
		||||
	 * if not known yet
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user