diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2007-09-10 21:59:37 +0000 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2007-09-10 21:59:37 +0000 |
commit | b366562e43a8cd70bfb73efd8f5508608f92fd9b (patch) | |
tree | b0530d94ffe068e59392ca90d6d3bdb838ec57cf /src/backend/commands/cluster.c | |
parent | 6a10f0f74957190b093f1b1147b1f2767548db90 (diff) | |
download | postgresql-b366562e43a8cd70bfb73efd8f5508608f92fd9b.tar.gz postgresql-b366562e43a8cd70bfb73efd8f5508608f92fd9b.zip |
Make CLUSTER and REINDEX silently skip remote temp tables in their
database-wide editions.
Per report from bitsandbytes88 <at> hotmail.com and subsequent discussion.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r-- | src/backend/commands/cluster.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index ded213de7e8..d781f79b641 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.162 2007/05/19 01:02:34 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.163 2007/09/10 21:59:37 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -106,6 +106,15 @@ cluster(ClusterStmt *stmt, bool isTopLevel) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS, RelationGetRelationName(rel)); + /* + * Reject clustering a remote temp table ... their local buffer manager + * is not going to cope. + */ + if (isOtherTempNamespace(RelationGetNamespace(rel))) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot cluster temporary tables of other sessions"))); + if (stmt->indexname == NULL) { ListCell *index; @@ -276,6 +285,21 @@ cluster_rel(RelToCluster *rvtc, bool recheck) } /* + * Silently skip a temp table for a remote session. Only doing this + * check in the "recheck" case is appropriate (which currently means + * somebody is executing a database-wide CLUSTER), because there is + * another check in cluster() which will stop any attempt to cluster + * remote temp tables by name. There is another check in + * check_index_is_clusterable which is redundant, but we leave it for + * extra safety. + */ + if (isOtherTempNamespace(RelationGetNamespace(OldHeap))) + { + relation_close(OldHeap, AccessExclusiveLock); + return; + } + + /* * Check that the index still exists */ if (!SearchSysCacheExists(RELOID, |