Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 44aa60f

Browse files
committed
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.
1 parent db16e77 commit 44aa60f

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

src/backend/catalog/toasting.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.16 2009/06/11 14:48:55 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.17 2009/06/11 20:46:11 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -43,6 +43,11 @@ static bool needs_toast_table(Relation rel);
4343
* then create a toast table for it. (With the force option, make
4444
* a toast table even if it appears unnecessary.)
4545
*
46+
* The caller can also specify the OID to be used for the toast table.
47+
* Usually, toastOid should be InvalidOid to allow a free OID to be assigned.
48+
* (This option, as well as the force option, is not used by core Postgres,
49+
* but is provided to support pg_migrator.)
50+
*
4651
* reloptions for the toast table can be passed, too. Pass (Datum) 0
4752
* for default reloptions.
4853
*
@@ -51,7 +56,8 @@ static bool needs_toast_table(Relation rel);
5156
* to end with CommandCounterIncrement if it makes any changes.
5257
*/
5358
void
54-
AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force)
59+
AlterTableCreateToastTable(Oid relOid, Oid toastOid,
60+
Datum reloptions, bool force)
5561
{
5662
Relation rel;
5763

@@ -63,7 +69,7 @@ AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force)
6369
rel = heap_open(relOid, AccessExclusiveLock);
6470

6571
/* create_toast_table does all the work */
66-
(void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions, force);
72+
(void) create_toast_table(rel, toastOid, InvalidOid, reloptions, force);
6773

6874
heap_close(rel, NoLock);
6975
}
@@ -101,8 +107,8 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
101107
* create_toast_table --- internal workhorse
102108
*
103109
* rel is already opened and exclusive-locked
104-
* toastOid and toastIndexOid are normally InvalidOid, but during
105-
* bootstrap they can be nonzero to specify hand-assigned OIDs
110+
* toastOid and toastIndexOid are normally InvalidOid, but
111+
* either or both can be nonzero to specify caller-assigned OIDs
106112
*/
107113
static bool
108114
create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,

src/backend/commands/cluster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.185 2009/06/11 14:48:55 momjian Exp $
14+
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.186 2009/06/11 20:46:11 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -741,7 +741,7 @@ make_new_heap(Oid OIDOldHeap, const char *NewName, Oid NewTableSpace)
741741
if (isNull)
742742
reloptions = (Datum) 0;
743743
}
744-
AlterTableCreateToastTable(OIDNewHeap, reloptions, false);
744+
AlterTableCreateToastTable(OIDNewHeap, InvalidOid, reloptions, false);
745745

746746
if (OidIsValid(toastid))
747747
ReleaseSysCache(tuple);

src/backend/commands/tablecmds.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.286 2009/06/11 14:48:56 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.287 2009/06/11 20:46:11 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2585,7 +2585,8 @@ ATRewriteCatalogs(List **wqueue)
25852585
(tab->subcmds[AT_PASS_ADD_COL] ||
25862586
tab->subcmds[AT_PASS_ALTER_TYPE] ||
25872587
tab->subcmds[AT_PASS_COL_ATTRS]))
2588-
AlterTableCreateToastTable(tab->relid, (Datum) 0, false);
2588+
AlterTableCreateToastTable(tab->relid, InvalidOid,
2589+
(Datum) 0, false);
25892590
}
25902591
}
25912592

src/backend/executor/execMain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.325 2009/06/11 14:48:56 momjian Exp $
29+
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.326 2009/06/11 20:46:11 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -2953,7 +2953,7 @@ OpenIntoRel(QueryDesc *queryDesc)
29532953

29542954
(void) heap_reloptions(RELKIND_TOASTVALUE, reloptions, true);
29552955

2956-
AlterTableCreateToastTable(intoRelationId, reloptions, false);
2956+
AlterTableCreateToastTable(intoRelationId, InvalidOid, reloptions, false);
29572957

29582958
/*
29592959
* And open the constructed table for writing.

src/backend/tcop/utility.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.308 2009/06/11 14:49:02 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.309 2009/06/11 20:46:11 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -447,6 +447,7 @@ ProcessUtility(Node *parsetree,
447447
true);
448448

449449
AlterTableCreateToastTable(relOid,
450+
InvalidOid,
450451
toast_options,
451452
false);
452453
}

src/include/catalog/toasting.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.7 2009/05/07 22:58:28 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.8 2009/06/11 20:46:11 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -17,7 +17,8 @@
1717
/*
1818
* toasting.c prototypes
1919
*/
20-
extern void AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force);
20+
extern void AlterTableCreateToastTable(Oid relOid, Oid toastOid,
21+
Datum reloptions, bool force);
2122
extern void BootstrapToastTable(char *relName,
2223
Oid toastOid, Oid toastIndexOid);
2324

0 commit comments

Comments
 (0)