88 * Portions Copyright (c) 1994, Regents of the University of California
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.26 2010/01/02 16:57:36 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.27 2010/01/06 03:03:58 momjian Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
3232#include "utils/syscache.h"
3333
3434Oid binary_upgrade_next_pg_type_toast_oid = InvalidOid ;
35+ extern Oid binary_upgrade_next_toast_relfilenode ;
3536
3637static bool create_toast_table (Relation rel ,Oid toastOid ,Oid toastIndexOid ,
37- Datum reloptions , bool force );
38+ Datum reloptions );
3839static bool needs_toast_table (Relation rel );
3940
4041
4142/*
4243 * AlterTableCreateToastTable
4344 *If the table needs a toast table, and doesn't already have one,
44- *then create a toast table for it. (With the force option, make
45- *a toast table even if it appears unnecessary.)
46- *
47- * The caller can also specify the OID to be used for the toast table.
48- * Usually, toastOid should be InvalidOid to allow a free OID to be assigned.
49- * (This option, as well as the force option, is not used by core Postgres,
50- * but is provided to support pg_migrator.)
45+ *then create a toast table for it.
5146 *
5247 * reloptions for the toast table can be passed, too. Pass (Datum) 0
5348 * for default reloptions.
@@ -57,8 +52,7 @@ static bool needs_toast_table(Relation rel);
5752 * to end with CommandCounterIncrement if it makes any changes.
5853 */
5954void
60- AlterTableCreateToastTable (Oid relOid ,Oid toastOid ,
61- Datum reloptions ,bool force )
55+ AlterTableCreateToastTable (Oid relOid ,Datum reloptions )
6256{
6357Relation rel ;
6458
@@ -70,7 +64,7 @@ AlterTableCreateToastTable(Oid relOid, Oid toastOid,
7064rel = heap_open (relOid ,AccessExclusiveLock );
7165
7266/* create_toast_table does all the work */
73- (void )create_toast_table (rel ,toastOid ,InvalidOid ,reloptions , force );
67+ (void )create_toast_table (rel ,InvalidOid ,InvalidOid ,reloptions );
7468
7569heap_close (rel ,NoLock );
7670}
@@ -96,7 +90,7 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
9690relName )));
9791
9892/* create_toast_table does all the work */
99- if (!create_toast_table (rel ,toastOid ,toastIndexOid , (Datum )0 , false ))
93+ if (!create_toast_table (rel ,toastOid ,toastIndexOid , (Datum )0 ))
10094elog (ERROR ,"\"%s\" does not require a toast table" ,
10195relName );
10296
@@ -108,12 +102,11 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
108102 * create_toast_table --- internal workhorse
109103 *
110104 * rel is already opened and exclusive-locked
111- * toastOid and toastIndexOid are normally InvalidOid, but
112- *either or both can be nonzero to specifycaller -assigned OIDs
105+ * toastOid and toastIndexOid are normally InvalidOid, but during
106+ *bootstrap they can be nonzero to specifyhand -assigned OIDs
113107 */
114108static bool
115- create_toast_table (Relation rel ,Oid toastOid ,Oid toastIndexOid ,
116- Datum reloptions ,bool force )
109+ create_toast_table (Relation rel ,Oid toastOid ,Oid toastIndexOid ,Datum reloptions )
117110{
118111Oid relOid = RelationGetRelid (rel );
119112HeapTuple reltup ;
@@ -152,12 +145,10 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
152145
153146/*
154147 * Check to see whether the table actually needs a TOAST table.
155- *
156- * Caller can optionally override this check. (Note: at present no
157- * callers in core Postgres do so, but this option is needed by
158- * pg_migrator.)
148+ * If the relfilenode is specified, force toast file creation.
159149 */
160- if (!force && !needs_toast_table (rel ))
150+ if (!needs_toast_table (rel )&&
151+ !OidIsValid (binary_upgrade_next_toast_relfilenode ))
161152return false;
162153
163154/*