Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2007-09-12 15:16:24 +0000
committerAlvaro Herrera2007-09-12 15:16:24 +0000
commit23df99783ed45c6b1a45a255fdf171dfbfaf87da (patch)
treefa6aa6253e96d9d32c5039a1638c820682adaf0d /src/backend/commands/cluster.c
parent59f7d47ed77348f5a0f491dd48f633ad97578049 (diff)
Fix the database-wide version of CLUSTER to silently skip temp tables of
remote sessions, instead of erroring out in the middle of the operation. This is a backpatch of a previous fix applied to CLUSTER to HEAD and 8.2, all the way back that it is relevant to.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r--src/backend/commands/cluster.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index fe3162aea61..3256b172206 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.116.2.2 2005/02/06 20:19:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.116.2.3 2007/09/12 15:16:24 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -308,6 +308,25 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
*/
OldHeap = heap_open(rvtc->tableOid, AccessExclusiveLock);
+ /*
+ * Don't allow cluster on temp tables of other backends ... their local
+ * buffer manager is not going to cope. We silently skip it in the
+ * "recheck" case, because it means somebody is executing a database-wide
+ * CLUSTER. In the single relation case, we must cause a hard error.
+ */
+ if (isOtherTempNamespace(RelationGetNamespace(OldHeap)))
+ {
+ if (recheck)
+ {
+ heap_close(OldHeap, AccessExclusiveLock);
+ return;
+ }
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot cluster temporary tables of other sessions")));
+ }
+
OldIndex = index_open(rvtc->indexOid);
LockRelation(OldIndex, AccessExclusiveLock);
@@ -379,15 +398,6 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
errmsg("\"%s\" is a system catalog",
RelationGetRelationName(OldHeap))));
- /*
- * Don't allow cluster on temp tables of other backends ... their
- * local buffer manager is not going to cope.
- */
- if (isOtherTempNamespace(RelationGetNamespace(OldHeap)))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot cluster temporary tables of other sessions")));
-
/* Drop relcache refcnt on OldIndex, but keep lock */
index_close(OldIndex);