From: Michael Paquier Date: Wed, 22 Aug 2018 05:22:39 +0000 (+0900) Subject: Do not dump identity sequences with excluded parent table X-Git-Tag: REL_11_BETA4~92 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ed59e02f5aa97618bb33355dc3accbcc2d5ace1;p=postgresql 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 --- diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index e2673dcbc3..1efa1aad73 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -6627,8 +6627,20 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables) seqinfo->owning_tab, seqinfo->dobj.catId.oid); /* - * We need to dump the components that are being dumped for the table - * and any components which the sequence is explicitly marked with. + * Only dump identity sequences if we're going to dump the table that + * it belongs to. + */ + if (owning_tab->dobj.dump == DUMP_COMPONENT_NONE && + seqinfo->is_identity_sequence) + { + seqinfo->dobj.dump = DUMP_COMPONENT_NONE; + continue; + } + + /* + * Otherwise we need to dump the components that are being dumped for + * the table and any components which the sequence is explicitly + * marked with. * * We can't simply use the set of components which are being dumped * for the table as the table might be in an extension (and only the