aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/cluster.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-05-27 21:14:00 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-05-27 21:14:00 +0000
commitc59eef17c96d98833c98341491ff9ca2da5a06b8 (patch)
tree63aee284cfd6898264418adbd9714c01a12641cc /src/backend/commands/cluster.c
parentea2827116540c5d8db51da030a4c4c9d4e4ab130 (diff)
downloadpostgresql-c59eef17c96d98833c98341491ff9ca2da5a06b8.tar.gz
postgresql-c59eef17c96d98833c98341491ff9ca2da5a06b8.zip
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 3256b172206..19ea0cac1ae 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.3 2007/09/12 15:16:24 alvherre Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.116.2.4 2008/05/27 21:14:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -398,6 +398,12 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
errmsg("\"%s\" is a system catalog",
RelationGetRelationName(OldHeap))));
+ /*
+ * 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);