]> granicus.if.org Git - postgresql/commitdiff
Ignore invalid indexes in pg_dump.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 26 Mar 2013 21:43:30 +0000 (17:43 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 26 Mar 2013 21:43:30 +0000 (17:43 -0400)
Dumping invalid indexes can cause problems at restore time, for example
if the reason the index creation failed was because it tried to enforce
a uniqueness condition not satisfied by the table's data.  Also, if the
index creation is in fact still in progress, it seems reasonable to
consider it to be an uncommitted DDL change, which pg_dump wouldn't be
expected to dump anyway.

Back-patch to all active versions, and teach them to ignore invalid
indexes in servers back to 8.2, where the concept was introduced.

Michael Paquier

src/bin/pg_dump/pg_dump.c

index 8f9c43019123e25612ec9524fa6bc3e763fc4b9b..390ce490c93527ca588812528caee0a5238059a0 100644 (file)
@@ -4028,6 +4028,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
                                                          "i.indexrelid = c.conindid AND "
                                                          "c.contype IN ('p','u','x')) "
                                                          "WHERE i.indrelid = '%u'::pg_catalog.oid "
+                                                         "AND i.indisvalid "
                                                          "ORDER BY indexname",
                                                          tbinfo->dobj.catId.oid);
                }
@@ -4056,6 +4057,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
                                                          "ON (d.refclassid = c.tableoid "
                                                          "AND d.refobjid = c.oid) "
                                                          "WHERE i.indrelid = '%u'::pg_catalog.oid "
+                                                         "AND i.indisvalid "
                                                          "ORDER BY indexname",
                                                          tbinfo->dobj.catId.oid);
                }