aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/cluster.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-12-15 18:51:46 -0500
committerRobert Haas <rhaas@postgresql.org>2011-12-15 19:02:38 -0500
commit74a1d4fe7cc092076806767925d6f34ea347efde (patch)
tree4aec82c1cc22d267358d7216e7ec78650ee05f9f /src/backend/commands/cluster.c
parentd039fd51f79e9ddde4d692d2b396bdf5722b4c4e (diff)
downloadpostgresql-74a1d4fe7cc092076806767925d6f34ea347efde.tar.gz
postgresql-74a1d4fe7cc092076806767925d6f34ea347efde.zip
Improve behavior of concurrent rename statements.
Previously, renaming a table, sequence, view, index, foreign table, column, or trigger checked permissions before locking the object, which meant that if permissions were revoked during the lock wait, we would still allow the operation. Similarly, if the original object is dropped and a new one with the same name is created, the operation will be allowed if we had permissions on the old object; the permissions on the new object don't matter. All this is now fixed. Along the way, attempting to rename a trigger on a foreign table now gives the same error message as trying to create one there in the first place (i.e. that it's not a table or view) rather than simply stating that no trigger by that name exists. Patch by me; review by Noah Misch.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r--src/backend/commands/cluster.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index edec44d2c3d..e805e28a39e 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -1474,28 +1474,24 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
{
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",
OIDOldHeap);
RenameRelationInternal(newrel->rd_rel->reltoastrelid,
- NewToastName,
- toastnamespace);
+ NewToastName);
/* ... and its index too */
snprintf(NewToastName, NAMEDATALEN, "pg_toast_%u_index",
OIDOldHeap);
RenameRelationInternal(toastidx,
- NewToastName,
- toastnamespace);
+ NewToastName);
}
relation_close(newrel, NoLock);
}