* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.14 2009/03/31 22:12:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.15 2009/05/07 22:58:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
static bool create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
- Datum reloptions);
+ Datum reloptions, bool force);
static bool needs_toast_table(Relation rel);
/*
* AlterTableCreateToastTable
* If the table needs a toast table, and doesn't already have one,
- * then create a toast table for it.
+ * then create a toast table for it. (With the force option, make
+ * a toast table even if it appears unnecessary.)
+ *
+ * reloptions for the toast table can be passed, too. Pass (Datum) 0
+ * for default reloptions.
*
* We expect the caller to have verified that the relation is a table and have
* already done any necessary permission checks. Callers expect this function
* to end with CommandCounterIncrement if it makes any changes.
*/
void
-AlterTableCreateToastTable(Oid relOid, Datum reloptions)
+AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force)
{
Relation rel;
rel = heap_open(relOid, AccessExclusiveLock);
/* create_toast_table does all the work */
- (void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions);
+ (void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions, force);
heap_close(rel, NoLock);
}
relName)));
/* create_toast_table does all the work */
- if (!create_toast_table(rel, toastOid, toastIndexOid, (Datum) 0))
+ if (!create_toast_table(rel, toastOid, toastIndexOid, (Datum) 0, false))
elog(ERROR, "\"%s\" does not require a toast table",
relName);
* bootstrap they can be nonzero to specify hand-assigned OIDs
*/
static bool
-create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptions)
+create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
+ Datum reloptions, bool force)
{
Oid relOid = RelationGetRelid(rel);
HeapTuple reltup;
/*
* Check to see whether the table actually needs a TOAST table.
+ *
+ * Caller can optionally override this check. (Note: at present
+ * no callers in core Postgres do so, but this option is needed by
+ * pg_migrator.)
*/
- if (!needs_toast_table(rel))
+ if (!force && !needs_toast_table(rel))
return false;
/*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.281 2009/03/31 22:12:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.282 2009/05/07 22:58:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
(tab->subcmds[AT_PASS_ADD_COL] ||
tab->subcmds[AT_PASS_ALTER_TYPE] ||
tab->subcmds[AT_PASS_COL_ATTRS]))
- AlterTableCreateToastTable(tab->relid, (Datum) 0);
+ AlterTableCreateToastTable(tab->relid, (Datum) 0, false);
}
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.323 2009/02/08 18:02:27 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.324 2009/05/07 22:58:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
(void) heap_reloptions(RELKIND_TOASTVALUE, reloptions, true);
- AlterTableCreateToastTable(intoRelationId, reloptions);
+ AlterTableCreateToastTable(intoRelationId, reloptions, false);
/*
* And open the constructed table for writing.
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.306 2009/02/02 19:31:39 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.307 2009/05/07 22:58:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
"toast",
validnsps,
true, false);
- (void) heap_reloptions(RELKIND_TOASTVALUE, toast_options,
+ (void) heap_reloptions(RELKIND_TOASTVALUE,
+ toast_options,
true);
- AlterTableCreateToastTable(relOid, toast_options);
+ AlterTableCreateToastTable(relOid,
+ toast_options,
+ false);
}
else
{
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.6 2009/02/02 19:31:40 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.7 2009/05/07 22:58:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
* toasting.c prototypes
*/
-extern void AlterTableCreateToastTable(Oid relOid, Datum reloptions);
+extern void AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force);
extern void BootstrapToastTable(char *relName,
Oid toastOid, Oid toastIndexOid);