postgres.git / summary / log / commit / refs

commit    b965f2617184032687037547204e1db1c1e1a56c
Author:   Michael Paquier <michael@paquier.xyz>
Date:     Wed Aug 22 05:21:49 2018 +0000

    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


src/bin/pg_dump/pg_dump.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index d5f1269f93d..89056207b97 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -6636,8 +6636,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 [parent: 98abc738027e]