|
11 | 11 | *
|
12 | 12 | *
|
13 | 13 | * IDENTIFICATION
|
14 |
| - * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.195 2010/01/28 23:21:11 petere Exp $ |
| 14 | + * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.196 2010/02/02 19:12:29 tgl Exp $ |
15 | 15 | *
|
16 | 16 | *-------------------------------------------------------------------------
|
17 | 17 | */
|
@@ -657,20 +657,25 @@ rebuild_relation(Relation OldHeap, Oid indexOid,
|
657 | 657 | newrel = heap_open(tableOid, NoLock);
|
658 | 658 | if (OidIsValid(newrel->rd_rel->reltoastrelid))
|
659 | 659 | {
|
660 |
| - char NewToastName[NAMEDATALEN]; |
661 | 660 | Relation toastrel;
|
| 661 | + Oid toastidx; |
| 662 | + Oid toastnamespace; |
| 663 | + char NewToastName[NAMEDATALEN]; |
| 664 | + |
| 665 | + toastrel = relation_open(newrel->rd_rel->reltoastrelid, AccessShareLock); |
| 666 | + toastidx = toastrel->rd_rel->reltoastidxid; |
| 667 | + toastnamespace = toastrel->rd_rel->relnamespace; |
| 668 | + relation_close(toastrel, AccessShareLock); |
662 | 669 |
|
663 | 670 | /* rename the toast table ... */
|
664 | 671 | snprintf(NewToastName, NAMEDATALEN, "pg_toast_%u", tableOid);
|
665 | 672 | RenameRelationInternal(newrel->rd_rel->reltoastrelid, NewToastName,
|
666 |
| - PG_TOAST_NAMESPACE); |
| 673 | + toastnamespace); |
667 | 674 |
|
668 | 675 | /* ... and its index too */
|
669 |
| - toastrel = relation_open(newrel->rd_rel->reltoastrelid, AccessShareLock); |
670 | 676 | snprintf(NewToastName, NAMEDATALEN, "pg_toast_%u_index", tableOid);
|
671 |
| - RenameRelationInternal(toastrel->rd_rel->reltoastidxid, NewToastName, |
672 |
| - PG_TOAST_NAMESPACE); |
673 |
| - relation_close(toastrel, AccessShareLock); |
| 677 | + RenameRelationInternal(toastidx, NewToastName, |
| 678 | + toastnamespace); |
674 | 679 | }
|
675 | 680 | relation_close(newrel, NoLock);
|
676 | 681 | }
|
|
0 commit comments