Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb366562

Browse files
committed
Make CLUSTER and REINDEX silently skip remote temp tables in their
database-wide editions.Per report from bitsandbytes88 <at> hotmail.com and subsequent discussion.
1 parent6a10f0f commitb366562

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

‎src/backend/commands/cluster.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* 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 $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -106,6 +106,15 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
106106
aclcheck_error(ACLCHECK_NOT_OWNER,ACL_KIND_CLASS,
107107
RelationGetRelationName(rel));
108108

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+
109118
if (stmt->indexname==NULL)
110119
{
111120
ListCell*index;
@@ -275,6 +284,21 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
275284
return;
276285
}
277286

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+
278302
/*
279303
* Check that the index still exists
280304
*/

‎src/backend/commands/indexcmds.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.164 2007/09/07 00:58:56 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.165 2007/09/10 21:59:37 alvherre Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1313,6 +1313,10 @@ ReindexDatabase(const char *databaseName, bool do_system, bool do_user)
13131313
if (classtuple->relkind!=RELKIND_RELATION)
13141314
continue;
13151315

1316+
/* Skip temp tables of other backends; we can't reindex them at all */
1317+
if (isOtherTempNamespace(classtuple->relnamespace))
1318+
continue;
1319+
13161320
/* Check user/system classification, and optionally skip */
13171321
if (IsSystemClass(classtuple))
13181322
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp