1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-22 21:53:06 +03:00

CLUSTER specified the wrong namespace when renaming toast tables of temporary

relations (they don't live in pg_toast).  This caused an Assert failure in
assert-enabled builds.  So far as I can see, in a non-assert build it would
only have messed up the checks for conflicting names, so a failure would be
quite improbable but perhaps not impossible.
This commit is contained in:
Tom Lane
2010-02-02 19:12:34 +00:00
parent 9fd5fb8d15
commit 8f13ee63cb
3 changed files with 30 additions and 7 deletions

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.186 2009/06/11 20:46:11 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.186.2.1 2010/02/02 19:12:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -641,20 +641,25 @@ rebuild_relation(Relation OldHeap, Oid indexOid)
newrel = heap_open(tableOid, NoLock);
if (OidIsValid(newrel->rd_rel->reltoastrelid))
{
char NewToastName[NAMEDATALEN];
Relation toastrel;
Oid toastidx;
Oid toastnamespace;
char NewToastName[NAMEDATALEN];
toastrel = relation_open(newrel->rd_rel->reltoastrelid, AccessShareLock);
toastidx = toastrel->rd_rel->reltoastidxid;
toastnamespace = toastrel->rd_rel->relnamespace;
relation_close(toastrel, AccessShareLock);
/* rename the toast table ... */
snprintf(NewToastName, NAMEDATALEN, "pg_toast_%u", tableOid);
RenameRelationInternal(newrel->rd_rel->reltoastrelid, NewToastName,
PG_TOAST_NAMESPACE);
toastnamespace);
/* ... and its index too */
toastrel = relation_open(newrel->rd_rel->reltoastrelid, AccessShareLock);
snprintf(NewToastName, NAMEDATALEN, "pg_toast_%u_index", tableOid);
RenameRelationInternal(toastrel->rd_rel->reltoastidxid, NewToastName,
PG_TOAST_NAMESPACE);
relation_close(toastrel, AccessShareLock);
RenameRelationInternal(toastidx, NewToastName,
toastnamespace);
}
relation_close(newrel, NoLock);
}