1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-05 09:19:17 +03:00

Disallow CLUSTER using an invalid index (that is, one left over from a failed

CREATE INDEX CONCURRENTLY).  Such an index might not have entries for every
heap row and thus clustering with it would result in silent data loss.
The scenario requires a pretty foolish DBA, but still ...
This commit is contained in:
Tom Lane 2007-09-29 18:05:28 +00:00
parent edc4d5edbe
commit c008a275c2

View File

@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.154.2.1 2007/09/10 22:02:05 alvherre Exp $ * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.154.2.2 2007/09/29 18:05:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -417,6 +417,16 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck)
RelationGetRelationName(OldIndex)))); RelationGetRelationName(OldIndex))));
} }
/*
* Disallow if index is left over from a failed CREATE INDEX CONCURRENTLY;
* it might well not contain entries for every heap row.
*/
if (!OldIndex->rd_index->indisvalid)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot cluster on invalid index \"%s\"",
RelationGetRelationName(OldIndex))));
/* /*
* Disallow clustering system relations. This will definitely NOT work * Disallow clustering system relations. This will definitely NOT work
* for shared relations (we have no way to update pg_class rows in other * for shared relations (we have no way to update pg_class rows in other