Skip to content

Commit cb282ea

Browse files
committed
Do not dump identity sequences with excluded parent table
This commit prevents a crash of pg_dump caused by the exclusion of a table which has identity columns, as the table would be correctly excluded but not its identity sequence. In order to fix that, identity sequences are excluded if the parent table is defined as such. Knowing about such sequences has no meaning without their parent table anyway. Reported-by: Andy Abelisto Author: David Rowley Reviewed-by: Peter Eisentraut, Michael Paquier Discussion: https://postgr.es/m/153479393218.1316.8472285660264976457@wrigleys.postgresql.org Backpatch-through: 10
1 parent 6350dc7 commit cb282ea

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6324,8 +6324,20 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
63246324
seqinfo->owning_tab, seqinfo->dobj.catId.oid);
63256325

63266326
/*
6327-
* We need to dump the components that are being dumped for the table
6328-
* and any components which the sequence is explicitly marked with.
6327+
* Only dump identity sequences if we're going to dump the table that
6328+
* it belongs to.
6329+
*/
6330+
if (owning_tab->dobj.dump == DUMP_COMPONENT_NONE &&
6331+
seqinfo->is_identity_sequence)
6332+
{
6333+
seqinfo->dobj.dump = DUMP_COMPONENT_NONE;
6334+
continue;
6335+
}
6336+
6337+
/*
6338+
* Otherwise we need to dump the components that are being dumped for
6339+
* the table and any components which the sequence is explicitly
6340+
* marked with.
63296341
*
63306342
* We can't simply use the set of components which are being dumped
63316343
* for the table as the table might be in an extension (and only the

0 commit comments

Comments
 (0)