Commit 44aa60fa authored by Tom Lane's avatar Tom Lane

Revisit AlterTableCreateToastTable's API once again, hoping to make it what

pg_migrator actually needs and not just a partial solution.  We have to be
able to specify the OID that the new toast table should be created with.
parent db16e773
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.16 2009/06/11 14:48:55 momjian Exp $ * $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.17 2009/06/11 20:46:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -43,6 +43,11 @@ static bool needs_toast_table(Relation rel); ...@@ -43,6 +43,11 @@ static bool needs_toast_table(Relation rel);
* then create a toast table for it. (With the force option, make * then create a toast table for it. (With the force option, make
* a toast table even if it appears unnecessary.) * a toast table even if it appears unnecessary.)
* *
* The caller can also specify the OID to be used for the toast table.
* Usually, toastOid should be InvalidOid to allow a free OID to be assigned.
* (This option, as well as the force option, is not used by core Postgres,
* but is provided to support pg_migrator.)
*
* reloptions for the toast table can be passed, too. Pass (Datum) 0 * reloptions for the toast table can be passed, too. Pass (Datum) 0
* for default reloptions. * for default reloptions.
* *
...@@ -51,7 +56,8 @@ static bool needs_toast_table(Relation rel); ...@@ -51,7 +56,8 @@ static bool needs_toast_table(Relation rel);
* to end with CommandCounterIncrement if it makes any changes. * to end with CommandCounterIncrement if it makes any changes.
*/ */
void void
AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force) AlterTableCreateToastTable(Oid relOid, Oid toastOid,
Datum reloptions, bool force)
{ {
Relation rel; Relation rel;
...@@ -63,7 +69,7 @@ AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force) ...@@ -63,7 +69,7 @@ AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force)
rel = heap_open(relOid, AccessExclusiveLock); rel = heap_open(relOid, AccessExclusiveLock);
/* create_toast_table does all the work */ /* create_toast_table does all the work */
(void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions, force); (void) create_toast_table(rel, toastOid, InvalidOid, reloptions, force);
heap_close(rel, NoLock); heap_close(rel, NoLock);
} }
...@@ -101,8 +107,8 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid) ...@@ -101,8 +107,8 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
* create_toast_table --- internal workhorse * create_toast_table --- internal workhorse
* *
* rel is already opened and exclusive-locked * rel is already opened and exclusive-locked
* toastOid and toastIndexOid are normally InvalidOid, but during * toastOid and toastIndexOid are normally InvalidOid, but
* bootstrap they can be nonzero to specify hand-assigned OIDs * either or both can be nonzero to specify caller-assigned OIDs
*/ */
static bool static bool
create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.185 2009/06/11 14:48:55 momjian Exp $ * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.186 2009/06/11 20:46:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -741,7 +741,7 @@ make_new_heap(Oid OIDOldHeap, const char *NewName, Oid NewTableSpace) ...@@ -741,7 +741,7 @@ make_new_heap(Oid OIDOldHeap, const char *NewName, Oid NewTableSpace)
if (isNull) if (isNull)
reloptions = (Datum) 0; reloptions = (Datum) 0;
} }
AlterTableCreateToastTable(OIDNewHeap, reloptions, false); AlterTableCreateToastTable(OIDNewHeap, InvalidOid, reloptions, false);
if (OidIsValid(toastid)) if (OidIsValid(toastid))
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.286 2009/06/11 14:48:56 momjian Exp $ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.287 2009/06/11 20:46:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2585,7 +2585,8 @@ ATRewriteCatalogs(List **wqueue) ...@@ -2585,7 +2585,8 @@ ATRewriteCatalogs(List **wqueue)
(tab->subcmds[AT_PASS_ADD_COL] || (tab->subcmds[AT_PASS_ADD_COL] ||
tab->subcmds[AT_PASS_ALTER_TYPE] || tab->subcmds[AT_PASS_ALTER_TYPE] ||
tab->subcmds[AT_PASS_COL_ATTRS])) tab->subcmds[AT_PASS_COL_ATTRS]))
AlterTableCreateToastTable(tab->relid, (Datum) 0, false); AlterTableCreateToastTable(tab->relid, InvalidOid,
(Datum) 0, false);
} }
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.325 2009/06/11 14:48:56 momjian Exp $ * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.326 2009/06/11 20:46:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2953,7 +2953,7 @@ OpenIntoRel(QueryDesc *queryDesc) ...@@ -2953,7 +2953,7 @@ OpenIntoRel(QueryDesc *queryDesc)
(void) heap_reloptions(RELKIND_TOASTVALUE, reloptions, true); (void) heap_reloptions(RELKIND_TOASTVALUE, reloptions, true);
AlterTableCreateToastTable(intoRelationId, reloptions, false); AlterTableCreateToastTable(intoRelationId, InvalidOid, reloptions, false);
/* /*
* And open the constructed table for writing. * And open the constructed table for writing.
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.308 2009/06/11 14:49:02 momjian Exp $ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.309 2009/06/11 20:46:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -447,6 +447,7 @@ ProcessUtility(Node *parsetree, ...@@ -447,6 +447,7 @@ ProcessUtility(Node *parsetree,
true); true);
AlterTableCreateToastTable(relOid, AlterTableCreateToastTable(relOid,
InvalidOid,
toast_options, toast_options,
false); false);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.7 2009/05/07 22:58:28 tgl Exp $ * $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.8 2009/06/11 20:46:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
/* /*
* toasting.c prototypes * toasting.c prototypes
*/ */
extern void AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force); extern void AlterTableCreateToastTable(Oid relOid, Oid toastOid,
Datum reloptions, bool force);
extern void BootstrapToastTable(char *relName, extern void BootstrapToastTable(char *relName,
Oid toastOid, Oid toastIndexOid); Oid toastOid, Oid toastIndexOid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment