8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
32
32
#include "utils/syscache.h"
33
33
34
34
Oid binary_upgrade_next_pg_type_toast_oid = InvalidOid ;
35
+ extern Oid binary_upgrade_next_toast_relfilenode ;
35
36
36
37
static bool create_toast_table (Relation rel , Oid toastOid , Oid toastIndexOid ,
37
- Datum reloptions , bool force );
38
+ Datum reloptions );
38
39
static bool needs_toast_table (Relation rel );
39
40
40
41
41
42
/*
42
43
* AlterTableCreateToastTable
43
44
* 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.
51
46
*
52
47
* reloptions for the toast table can be passed, too. Pass (Datum) 0
53
48
* for default reloptions.
@@ -57,8 +52,7 @@ static bool needs_toast_table(Relation rel);
57
52
* to end with CommandCounterIncrement if it makes any changes.
58
53
*/
59
54
void
60
- AlterTableCreateToastTable (Oid relOid , Oid toastOid ,
61
- Datum reloptions , bool force )
55
+ AlterTableCreateToastTable (Oid relOid , Datum reloptions )
62
56
{
63
57
Relation rel ;
64
58
@@ -70,7 +64,7 @@ AlterTableCreateToastTable(Oid relOid, Oid toastOid,
70
64
rel = heap_open (relOid , AccessExclusiveLock );
71
65
72
66
/* 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 );
74
68
75
69
heap_close (rel , NoLock );
76
70
}
@@ -96,7 +90,7 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
96
90
relName )));
97
91
98
92
/* 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 ))
100
94
elog (ERROR , "\"%s\" does not require a toast table" ,
101
95
relName );
102
96
@@ -108,12 +102,11 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
108
102
* create_toast_table --- internal workhorse
109
103
*
110
104
* rel is already opened and exclusive-locked
111
- * toastOid and toastIndexOid are normally InvalidOid, but
112
- * either or both can be nonzero to specify caller -assigned OIDs
105
+ * toastOid and toastIndexOid are normally InvalidOid, but during
106
+ * bootstrap they can be nonzero to specify hand -assigned OIDs
113
107
*/
114
108
static 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 )
117
110
{
118
111
Oid relOid = RelationGetRelid (rel );
119
112
HeapTuple reltup ;
@@ -152,12 +145,10 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
152
145
153
146
/*
154
147
* 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.
159
149
*/
160
- if (!force && !needs_toast_table (rel ))
150
+ if (!needs_toast_table (rel ) &&
151
+ !OidIsValid (binary_upgrade_next_toast_relfilenode ))
161
152
return false;
162
153
163
154
/*
0 commit comments