Skip to content

Commit 30de42d

Browse files
committed
Ignore invalid indexes in pg_dump.
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
1 parent 2e4acef commit 30de42d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4534,6 +4534,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
45344534
"i.indexrelid = c.conindid AND "
45354535
"c.contype IN ('p','u','x')) "
45364536
"WHERE i.indrelid = '%u'::pg_catalog.oid "
4537+
"AND i.indisvalid "
45374538
"ORDER BY indexname",
45384539
tbinfo->dobj.catId.oid);
45394540
}
@@ -4562,6 +4563,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
45624563
"ON (d.refclassid = c.tableoid "
45634564
"AND d.refobjid = c.oid) "
45644565
"WHERE i.indrelid = '%u'::pg_catalog.oid "
4566+
"AND i.indisvalid "
45654567
"ORDER BY indexname",
45664568
tbinfo->dobj.catId.oid);
45674569
}

0 commit comments

Comments
 (0)