Re: pg_dumping extensions having sequences with 9.6beta3

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Philippe BEAUDOIN <phb(dot)emaj(at)free(dot)fr>, PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_dumping extensions having sequences with 9.6beta3
Date: 2016-07-27 06:24:58
Message-ID: CAB7nPqTSgdbaUSUUvY5=oHA7sGcS14kR3erdqRKOj2jPeozH-Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Wed, Jul 27, 2016 at 8:07 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> That'd be great. It's definitely on my list of things to look into, but
> I'm extremely busy this week. I hope to look into it on Friday, would
> be great to see what you find.

Sequences that are directly defined in extensions do not get dumped,
and sequences that are part of a serial column in an extension are
getting dumped. Looking into this problem, getOwnedSeqs() is visibly
doing an incorrect assumption: sequences owned by table columns are
dumped unconditionally, but this is not true for sequences that are
part of extensions. More precisely, dobj->dump is being enforced to
DUMP_COMPONENT_ALL, which makes the sequence definition to be dumped.
Oops.

The patch attached fixes the problem for me. I have added as well
tests in test_pg_dump in the shape of sequences defined in an
extension, and sequences that are part of a serial column. This patch
is also able to work in the case where a sequence is created as part
of a serial column, and gets removed after, say with ALTER EXTENSION
DROP SEQUENCE. The behavior for sequences and serial columns that are
not part of extensions is unchanged.

Stephen, it would be good if you could check the correctness of this
patch as you did all this refactoring of pg_dump to support catalog
ACLs. I am sure by the way that checking for (owning_tab->dobj.dump &&
DUMP_COMPONENT_DEFINITION) != 0 is not good because of for example the
case of a serial column created in an extension where the sequence is
dropped from the extension afterwards.
--
Michael

Attachment Content-Type Size
pgdump-extension-seq.patch application/x-patch 3.1 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Condor 2016-07-27 07:15:07 Re: Uber migrated from Postgres to MySQL
Previous Message Stephen Frost 2016-07-26 23:07:02 Re: pg_dumping extensions having sequences with 9.6beta3

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Borodin 2016-07-27 06:33:03 Re: Optimizing numeric SUM() aggregate
Previous Message Amit Kapila 2016-07-27 06:20:06 Re: copyParamList