summaryrefslogtreecommitdiff
path: root/src/backend/commands/cluster.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-05-27 21:13:39 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-05-27 21:13:39 +0000
commit290d4b37ab98be20ebb79c658b7590b8982d7f01 (patch)
tree51bfc4be1f2c6d83964898b2a523292b35ccb06b /src/backend/commands/cluster.c
parent48ecee132852b1631b9b6ec5d5fe9c0b9ab5ac98 (diff)
Back-patch the 8.3 fix that prohibits TRUNCATE, CLUSTER, and REINDEX when the
current transaction has any open references to the target relation or index (implying it has an active query using the relation). Also back-patch the 8.2 fix that prohibits TRUNCATE and CLUSTER when there are pending AFTER-trigger events. Per suggestion from Heikki.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r--src/backend/commands/cluster.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 698609a428e..9f18c919c16 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.141.2.2 2007/09/12 15:16:20 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.141.2.3 2008/05/27 21:13:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -419,6 +419,12 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot cluster temporary tables of other sessions")));
+ /*
+ * Also check for active uses of the relation in the current transaction,
+ * including open scans and pending AFTER trigger events.
+ */
+ CheckTableNotInUse(OldHeap, "CLUSTER");
+
/* Drop relcache refcnt on OldIndex, but keep lock */
index_close(OldIndex);
}