aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-09-29 18:05:28 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-09-29 18:05:28 +0000
commitc008a275c21bb08c5045d26a50f5cd05e77c03cc (patch)
tree403639f251a8428f59f8fbb58924653e5e6da413 /src
parentedc4d5edbe2de0c9261e88aa6ccb22a788d0f9be (diff)
downloadpostgresql-c008a275c21bb08c5045d26a50f5cd05e77c03cc.tar.gz
postgresql-c008a275c21bb08c5045d26a50f5cd05e77c03cc.zip
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 ...
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/cluster.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 506e3d7894b..f0825a9d02f 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -11,7 +11,7 @@
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
@@ -418,6 +418,16 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck)
}
/*
+ * 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
* databases), nor for nailed-in-cache relations (the relfilenode values