10000 Ignore invalid indexes in pg_dump. · danielcode/postgres@96103c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 96103c6

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 13f9634 commit 96103c6

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
@@ -4540,6 +4540,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
45404540
"i.indexrelid = c.conindid AND "
45414541
"c.contype IN ('p','u','x')) "
45424542
"WHERE i.indrelid = '%u'::pg_catalog.oid "
4543+
"AND i.indisvalid "
45434544
"ORDER BY indexname",
45444545
tbinfo->dobj.catId.oid);
45454546
}
@@ -4568,6 +4569,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
45684569
"ON (d.refclassid = c.tableoid "
45694570
"AND d.refobjid = c.oid) "
45704571
"WHERE i.indrelid = '%u'::pg_catalog.oid "
4572+
"AND i.indisvalid "
45714573
"ORDER BY indexname",
45724574
tbinfo->dobj.catId.oid);
45734575
}

0 commit comments

Comments
 (0)
0