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

Commita4dde3b

Browse files
committed
Report index name on CLUSTER failure. Also, suggest ALTER TABLE
WITHOUT CLUSTER for cluster failure of a single table in a full dbcluster.
1 parentdc5ebcf commita4dde3b

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

‎src/backend/commands/cluster.c

Lines changed: 16 additions & 10 deletions
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.137 2005/05/06 17:24:53 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.138 2005/05/10 13:16:26 momjian Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -292,7 +292,7 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
292292
OldHeap=heap_open(rvtc->tableOid,AccessExclusiveLock);
293293

294294
/* Check index is valid to cluster on */
295-
check_index_is_clusterable(OldHeap,rvtc->indexOid);
295+
check_index_is_clusterable(OldHeap,rvtc->indexOid,recheck);
296296

297297
/* rebuild_relation does all the dirty work */
298298
rebuild_relation(OldHeap,rvtc->indexOid);
@@ -309,7 +309,7 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
309309
* definition can't change under us.
310310
*/
311311
void
312-
check_index_is_clusterable(RelationOldHeap,OidindexOid)
312+
check_index_is_clusterable(RelationOldHeap,OidindexOid,boolrecheck)
313313
{
314314
RelationOldIndex;
315315

@@ -336,7 +336,9 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid)
336336
if (!heap_attisnull(OldIndex->rd_indextuple,Anum_pg_index_indpred))
337337
ereport(ERROR,
338338
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
339-
errmsg("cannot cluster on partial index")));
339+
errmsg("cannot cluster on partial index \"%s\"",
340+
RelationGetRelationName(OldIndex))));
341+
340342
if (!OldIndex->rd_am->amindexnulls)
341343
{
342344
AttrNumbercolno;
@@ -354,21 +356,25 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid)
354356
if (!OldHeap->rd_att->attrs[colno-1]->attnotnull)
355357
ereport(ERROR,
356358
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
357-
errmsg("cannot cluster when index access method does not handle null values"),
358-
errhint("You may be able to work around this by marking column \"%s\" NOT NULL.",
359-
NameStr(OldHeap->rd_att->attrs[colno-1]->attname))));
359+
errmsg("cannot cluster on index \"%s\" because access method\n"
360+
"does not handle null values",
361+
RelationGetRelationName(OldIndex)),
362+
errhint("You may be able to work around this by marking column \"%s\" NOT NULL%s",
363+
NameStr(OldHeap->rd_att->attrs[colno-1]->attname),
364+
recheck ?",\nor use ALTER TABLE ... SET WITHOUT CLUSTER to remove the cluster\n"
365+
"specification from the table." :".")));
360366
}
361367
elseif (colno<0)
362368
{
363369
/* system column --- okay, always non-null */
364370
}
365371
else
366-
{
367372
/* index expression, lose... */
368373
ereport(ERROR,
369374
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
370-
errmsg("cannot cluster on expressional index when index access method does not handle null values")));
371-
}
375+
errmsg("cannot cluster on expressional index \"%s\" because its index access\n"
376+
"method does not handle null values",
377+
RelationGetRelationName(OldIndex))));
372378
}
373379

374380
/*

‎src/backend/commands/tablecmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.156 2005/05/06 17:24:53 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.157 2005/05/10 13:16:26 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -5464,7 +5464,7 @@ ATExecClusterOn(Relation rel, const char *indexName)
54645464
indexName,RelationGetRelationName(rel))));
54655465

54665466
/* Check index is valid to cluster on */
5467-
check_index_is_clusterable(rel,indexOid);
5467+
check_index_is_clusterable(rel,indexOid, false);
54685468

54695469
/* And do the work */
54705470
mark_index_clustered(rel,indexOid);

‎src/include/commands/cluster.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/commands/cluster.h,v 1.27 2004/12/31 22:03:28 pgsql Exp $
9+
* $PostgreSQL: pgsql/src/include/commands/cluster.h,v 1.28 2005/05/10 13:16:26 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -19,7 +19,8 @@
1919

2020
externvoidcluster(ClusterStmt*stmt);
2121

22-
externvoidcheck_index_is_clusterable(RelationOldHeap,OidindexOid);
22+
externvoidcheck_index_is_clusterable(RelationOldHeap,OidindexOid,
23+
boolrecheck);
2324
externvoidmark_index_clustered(Relationrel,OidindexOid);
2425
externOidmake_new_heap(OidOIDOldHeap,constchar*NewName,
2526
OidNewTableSpace);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp