Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDxS9-0001IO-Np for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Jun 2016 17:21:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bDxS9-0004Xg-6v for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Jun 2016 17:21:09 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bDxS8-0004XE-9p for pgsql-bugs@postgresql.org; Fri, 17 Jun 2016 17:21:08 +0000 Received: from mail-qk0-x22e.google.com ([2607:f8b0:400d:c09::22e]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bDxS5-000440-Bp for pgsql-bugs@postgresql.org; Fri, 17 Jun 2016 17:21:07 +0000 Received: by mail-qk0-x22e.google.com with SMTP id c73so91282203qkg.2 for ; Fri, 17 Jun 2016 10:21:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to; bh=o+yTn6KE3cSw1PK02CecOft57AfDBE8wtWGVwm6vm64=; b=Ro9bEdBzAb5G3oPVUF+cHmyfiBUnE8eofff3EE4n7I0RjxnRd7Gw2jZcXQvwMsYysR Ep8+Ge45RvI+3r5HQMbN6TXFaShd3mSlhWcn9gok9y7bLStzZiYat6qPyggHm0UQUWwl YNMXku5SUUu33vOrdip4MMqg/EvNxORZGQ2IuKuVZ84S8EkoHRS1RUUN/Xhm1IKcpgqW qixiQoR4qhLpWhKuDfhJMSH72AScdvrvUkuqAhTvi+XwpGiClB0ISja3IWMb9J/wErmY w/aEfgHSPWeJ9/KO7HzvCuVIs9jmpXFjkgv5hF/MXRkgvQgr/SC6fNciPc7wRcTsle8J sHCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=o+yTn6KE3cSw1PK02CecOft57AfDBE8wtWGVwm6vm64=; b=S53AlvSZyvs8bk9Achrngae9tu2FPmOIx9gxxa007jbQSwiCr8zRAoqOP/c4prZeLv tvk8zQpZ9iG+borCvB1N5bWvI2FmPo7Cr6zT0wMMMCHVG5UHd7cd4R5PL3Q1QXzRdD5k PDQP4jiuuaDQ3eNgho5T8phnqZe3cbnoWxhRUZ/70TihKXVSWUqJke9SYQUgAqRee3Qf lc5ioDPawqXXhFXmWBiejquZ3b47RRhQeEdJdmCR3ZG0TJ7ix8iidgnQXwKd2PZjhLMG BrRRLED0lVvPA5UbxzhSbz/fG8a7SJ+9C19oH/PMNujmDy2wQdLr4bRX3oIe8E79v1aK TStw== X-Gm-Message-State: ALyK8tLIlpGobpXkrrX45NpawXpM6PVh22aZhEkXKvArge0aG6bWdd1KDTAgMLDj1ALXOMPpmSZNM7E6GjqeZhrs7l3avVz3mYaCcAZk2qzuBWVv18VEsfejmkp2Zfiv502icu5UIW+cRZUW5k0N9zGybxyqW9b5jC1HrH4d+3/4qAH9jgCxnogfHVaEsLNP X-Received: by 10.55.91.193 with SMTP id p184mr3554005qkb.3.1466184064195; Fri, 17 Jun 2016 10:21:04 -0700 (PDT) Received: from alderaan.marques ([190.57.235.183]) by smtp.googlemail.com with ESMTPSA id w11sm9427479qge.5.2016.06.17.10.21.02 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Jun 2016 10:21:03 -0700 (PDT) Subject: Re: pg_dump doesn't dump new objects created in schemas from extensions To: Michael Paquier References: <409fe594-f4cc-89f5-c0d2-0a921987a864@2ndquadrant.com> <20160616185547.GA72247@alvherre.pgsql> Cc: Alvaro Herrera , PostgreSQL mailing lists From: =?UTF-8?Q?Mart=c3=adn_Marqu=c3=a9s?= Message-ID: <24a4d9cf-025d-d855-fe76-3af3f878174d@2ndquadrant.com> Date: Fri, 17 Jun 2016 14:21:01 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------29652EFB674CDC8C87915006" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------29652EFB674CDC8C87915006 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit El 17/06/16 a las 03:35, Michael Paquier escribió: > On Fri, Jun 17, 2016 at 4:21 AM, Martín Marqués wrote: >> IMO, this assignment: >> >> tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump_contains; >> >> should be replaced by a call to some new function which would be more >> or less a copy of selectDumpableNamespace, but without the >> checkExtensionMembership call. > > Ah, I see. Yes this is definitely wrong. The namespace itself may be > part of an extension but we do not check for it at all. See for > example the patch attached that is giving what I would expect is the > correct behavior. This is a new version of your patch that checks for schema inclusion or exclusion. If there are no complains, I could apply similar changes on other objects for a more complete patch. Thoughts, objections? -- Martín Marqués http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --------------29652EFB674CDC8C87915006 Content-Type: invalid/octet-stream; name="dump-table-on-extension-schema.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="dump-table-on-extension-schema.patch" diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 13bfd2c..954f428 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -1391,14 +1391,41 @@ selectDumpableTable(TableInfo *tbinfo, Archive *fout) /* * If specific tables are being dumped, dump just those tables; else, dump - * according to the parent namespace's dump flag. + * according to the parent namespace's dump flag. Note that the parent + * namespace may be itself part of an extension, but not the table, in + * which case its content needs to be explicitely dumped. */ if (table_include_oids.head != NULL) tbinfo->dobj.dump = simple_oid_list_member(&table_include_oids, tbinfo->dobj.catId.oid) ? DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE; else - tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump_contains; + { + if (checkExtensionMembership(&tbinfo->dobj.namespace->dobj, fout)) + { + /* + * Table will be dumpable if no namespace include clause was passed, + * or if the tables namespace is in the list of of included schema. + * In any other case, the table will not be dumpable. + */ + if (schema_include_oids.head == NULL || + simple_oid_list_member(&schema_include_oids, + tbinfo->dobj.namespace->dobj.catId.oid)) + tbinfo->dobj.dump = DUMP_COMPONENT_ALL; + else + tbinfo->dobj.dump = DUMP_COMPONENT_NONE; + /* + * If we excluded the namespace we should exclude the table as well. + * It seems incorrect, as the namespace will in any case get created + * during the restore by the extension. + */ + if (simple_oid_list_member(&schema_exclude_oids, + tbinfo->dobj.namespace->dobj.catId.oid)) + tbinfo->dobj.dump = DUMP_COMPONENT_NONE; + } + else + tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump_contains; + } /* * In any case, a table can be excluded by an exclusion switch --------------29652EFB674CDC8C87915006 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --------------29652EFB674CDC8C87915006--