mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-23 19:39:53 +08:00
Fix the database-wide version of CLUSTER to silently skip temp tables of
remote sessions, instead of erroring out in the middle of the operation. This is a backpatch of a previous fix applied to CLUSTER to HEAD and 8.2, all the way back that it is relevant to.
This commit is contained in:
parent
073164b767
commit
57dcb0f81d
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.141.2.1 2005/11/22 18:23:06 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.141.2.2 2007/09/12 15:16:20 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -101,6 +101,15 @@ cluster(ClusterStmt *stmt)
|
||||
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;
|
||||
@ -291,6 +300,18 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
|
||||
*/
|
||||
OldHeap = heap_open(rvtc->tableOid, AccessExclusiveLock);
|
||||
|
||||
/*
|
||||
* Don't allow cluster on temp tables of other backends ... their
|
||||
* local buffer manager is not going to cope. In the recheck case,
|
||||
* silently skip it. Otherwise continue -- there is a hard error
|
||||
* in check_index_is_clusterable.
|
||||
*/
|
||||
if (recheck && isOtherTempNamespace(RelationGetNamespace(OldHeap)))
|
||||
{
|
||||
heap_close(OldHeap, AccessExclusiveLock);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check index is valid to cluster on */
|
||||
check_index_is_clusterable(OldHeap, rvtc->indexOid, recheck);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user