aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/cluster.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-02-02 19:12:29 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-02-02 19:12:29 +0000
commitc98157d693edefdbf5e37bca9b26c18a80018dd4 (patch)
treecb02e574630bc996cffe676ceb7bcab8c364b883 /src/backend/commands/cluster.c
parent0a2734714127b01d1f77468766d132064a1d6a97 (diff)
downloadpostgresql-c98157d693edefdbf5e37bca9b26c18a80018dd4.tar.gz
postgresql-c98157d693edefdbf5e37bca9b26c18a80018dd4.zip
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.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r--src/backend/commands/cluster.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index dc967390ba6..2d2ac3e8940 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.195 2010/01/28 23:21:11 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.196 2010/02/02 19:12:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -657,20 +657,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);
}