|
11 | 11 | * |
12 | 12 | * |
13 | 13 | * IDENTIFICATION |
14 | | - * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.162 2007/05/19 01:02:34 alvherre Exp $ |
| 14 | + * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.163 2007/09/10 21:59:37 alvherre Exp $ |
15 | 15 | * |
16 | 16 | *------------------------------------------------------------------------- |
17 | 17 | */ |
@@ -106,6 +106,15 @@ cluster(ClusterStmt *stmt, bool isTopLevel) |
106 | 106 | aclcheck_error(ACLCHECK_NOT_OWNER,ACL_KIND_CLASS, |
107 | 107 | RelationGetRelationName(rel)); |
108 | 108 |
|
| 109 | +/* |
| 110 | + * Reject clustering a remote temp table ... their local buffer manager |
| 111 | + * is not going to cope. |
| 112 | + */ |
| 113 | +if (isOtherTempNamespace(RelationGetNamespace(rel))) |
| 114 | +ereport(ERROR, |
| 115 | +(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
| 116 | +errmsg("cannot cluster temporary tables of other sessions"))); |
| 117 | + |
109 | 118 | if (stmt->indexname==NULL) |
110 | 119 | { |
111 | 120 | ListCell*index; |
@@ -275,6 +284,21 @@ cluster_rel(RelToCluster *rvtc, bool recheck) |
275 | 284 | return; |
276 | 285 | } |
277 | 286 |
|
| 287 | +/* |
| 288 | + * Silently skip a temp table for a remote session. Only doing this |
| 289 | + * check in the "recheck" case is appropriate (which currently means |
| 290 | + * somebody is executing a database-wide CLUSTER), because there is |
| 291 | + * another check in cluster() which will stop any attempt to cluster |
| 292 | + * remote temp tables by name. There is another check in |
| 293 | + * check_index_is_clusterable which is redundant, but we leave it for |
| 294 | + * extra safety. |
| 295 | + */ |
| 296 | +if (isOtherTempNamespace(RelationGetNamespace(OldHeap))) |
| 297 | +{ |
| 298 | +relation_close(OldHeap,AccessExclusiveLock); |
| 299 | +return; |
| 300 | +} |
| 301 | + |
278 | 302 | /* |
279 | 303 | * Check that the index still exists |
280 | 304 | */ |
|