*** pgsql/src/backend/commands/cluster.c 2007/09/29 18:05:28 1.154.2.2 --- pgsql/src/backend/commands/cluster.c 2008/05/27 21:13:25 1.154.2.3 *************** *** 11,17 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.154.2.1 2007/09/10 22:02:05 alvherre Exp $ * *------------------------------------------------------------------------- */ --- 11,17 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.154.2.2 2007/09/29 18:05:28 tgl Exp $ * *------------------------------------------------------------------------- */ *************** *** 28,33 **** --- 28,34 ---- #include "catalog/namespace.h" #include "catalog/toasting.h" #include "commands/cluster.h" + #include "commands/tablecmds.h" #include "miscadmin.h" #include "utils/acl.h" #include "utils/fmgroids.h" *************** check_index_is_clusterable(Relation OldH *** 449,454 **** --- 450,461 ---- (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, NoLock); }