mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Make CLUSTER and REINDEX silently skip remote temp tables in their
database-wide editions. Per report from bitsandbytes88 <at> hotmail.com and subsequent discussion.
This commit is contained in:
parent
6a10f0f749
commit
b366562e43
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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,
|
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
|
||||||
RelationGetRelationName(rel));
|
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)
|
if (stmt->indexname == NULL)
|
||||||
{
|
{
|
||||||
ListCell *index;
|
ListCell *index;
|
||||||
@ -275,6 +284,21 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
* Check that the index still exists
|
||||||
*/
|
*/
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.164 2007/09/07 00:58:56 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.165 2007/09/10 21:59:37 alvherre Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1313,6 +1313,10 @@ ReindexDatabase(const char *databaseName, bool do_system, bool do_user)
|
|||||||
if (classtuple->relkind != RELKIND_RELATION)
|
if (classtuple->relkind != RELKIND_RELATION)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* Skip temp tables of other backends; we can't reindex them at all */
|
||||||
|
if (isOtherTempNamespace(classtuple->relnamespace))
|
||||||
|
continue;
|
||||||
|
|
||||||
/* Check user/system classification, and optionally skip */
|
/* Check user/system classification, and optionally skip */
|
||||||
if (IsSystemClass(classtuple))
|
if (IsSystemClass(classtuple))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user