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 ...
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
* for shared relations (we have no way to update pg_class rows in other