Re: Bug in pg_dump

From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug in pg_dump
Date: 2015-02-24 22:46:23
Message-ID: 54ECFF3F.2000905@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Le 24/02/2015 05:40, Michael Paquier a écrit :
>
>
> On Tue, Feb 24, 2015 at 2:17 AM, Gilles Darold
> <gilles(dot)darold(at)dalibo(dot)com <mailto:gilles(dot)darold(at)dalibo(dot)com>> wrote:
>
> Looks great to me, I have tested with the postgis_topology extension
> everything works fine.
>
>
> Actually, after looking more in depth at the internals of pg_dump I
> think that both patches are wrong (did that yesterday night for
> another patch). First this patch marks a table in an extension as
> always dumpable:
> + /* Mark member table as dumpable */
> + configtbl->dobj.dump = true;
> And then many checks on ext_member are added in many code paths to
> ensure that objects in extensions have their definition never dumped.
> But actually this assumption is not true all the time per this code in
> getExtensionMemberShip:
> if (!dopt->binary_upgrade)
> dobj->dump = false;
> else
> dobj->dump = refdobj->dump;
> So this patch would break binary upgrade where some extension objects
> should be dumped (one reason why I haven't noticed that before is that
> pg_upgrade tests do not include extensions).
>
> Hence, one idea coming to my mind to fix the problem would be to add
> some extra processing directly in getExtensionMembership() after
> building the objects DO_TABLE_DATA with makeTableDataInfo() by
> checking the FK dependencies and add a dependency link with
> addObjectDependency. The good part with that is that even user tables
> that reference extension tables with a FK can be restored correctly
> because their constraint is added *after* loading the data. I noticed
> as well that with this patch the --data-only mode was dumping tables
> in the correct order.
>
> Speaking of which, patches implementing this idea are attached. The
> module test case has been improved as well with a check using a table
> not in an extension linked with a FK to a table in an extension.
> --
> Michael

This is a far better patch and the test to export/import of the
postgis_topology extension works great for me.

Thanks for the work.

--
Gilles Darold
Consultant PostgreSQL
http://dalibo.com - http://dalibo.org

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Kirkwood 2015-02-24 23:03:33 Re: Unable to build pg_rewind
Previous Message Tom Lane 2015-02-24 22:12:19 Re: PostgreSQL on z/OS UNIX?