Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 0BBFCB5DC49 for ; Thu, 25 Aug 2011 12:17:08 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 49989-04 for ; Thu, 25 Aug 2011 15:17:00 +0000 (UTC) X-Greylist: delayed 00:07:26.589438 by SQLgrey-1.7.6 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) by mail.postgresql.org (Postfix) with ESMTP id 7D73BB5D80A for ; Thu, 25 Aug 2011 12:17:00 -0300 (ADT) Received: by qyk34 with SMTP id 34so1531589qyk.19 for ; Thu, 25 Aug 2011 08:16:59 -0700 (PDT) Received: by 10.229.67.149 with SMTP id r21mr666000qci.99.1314284972888; Thu, 25 Aug 2011 08:09:32 -0700 (PDT) Received: from Chander-Ganesans-MacBook-Pro.local (rrcs-24-97-162-130.nys.biz.rr.com [24.97.162.130]) by mx.google.com with ESMTPS id r2sm351037qcv.46.2011.08.25.08.09.31 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Aug 2011 08:09:32 -0700 (PDT) Message-ID: <4E5665AA.7080900@otg-nc.com> Date: Thu, 25 Aug 2011 11:09:30 -0400 From: Chander Ganesan Organization: Open Technology Group, Inc. User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: Tom Lane CC: pgsql-bugs@postgresql.org Subject: Re: BUG #6176: pg_dump dumps pg_catalog tables References: <201108251300.p7PD0HiL074200@wwwmaster.postgresql.org> <2120.1314283923@sss.pgh.pa.us> In-Reply-To: <2120.1314283923@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201108/148 X-Sequence-Number: 30960 On 8/25/11 10:52 AM, Tom Lane wrote: > "Chander Ganesan" writes: >> Normally, the pg_dump command ignored the pg_catalog tables when performing >> a dump. However, when provided the '--table' argument it fails to ignore >> the pg_catalog table. >> For example, suppose I had tables p1-p10 that I wanted to dump, I could use >> the following command: >> pg_dump test_db --table 'p*' >> This command would dump the requested tables, but it would also dump all the >> tables (in all schemas) that start with 'p*' . Generally speaking, there >> are no "excluded schemas" when using the pg_dump command with the '--table' >> argument. >> It is my belief that the pg_catalog tables should almost always be ignored >> (lest restores fail miserably). > This proposal seems overly simplistic to me: if we did this, it would be > impossible to use pg_dump to dump a catalog's contents at all. (I don't > care whether the resulting script is restorable; sometimes you just need > to see what's actually in pg_class.) Hence the "almost always" in my proposal - I agree with you. I think the common use case would want to preclude the export of pg_catalog tables, and most folks reading the documentation would end up getting confusing output in their dumps... At the very least, the documentation might include a caveat to warn users of the side effect... Especially since the default behavior is to exclude pg_catalog > I wonder whether it would be helpful to provide a default setting for > --exclude-schema that lists pg_catalog, information_schema, etc. > If we approached it that way, it'd be possible to override the default > at need. However, I'm not sure how that switch interacts with wildcard > --table specs ... I tried that, at present it seems that the --exclude-schema flag is ignored when the --table flag is used. I'd love to see those work together (i.e., all tables starting with 'p' except those in schema 'old_data'.) I'd hate to see a command like this result in pg_catalog being dumped (which might be more backwards-incompatible than my suggestion below): pg_dump test_db --exclude-schema old_stuff How about making those schemas *always* excluded except when specified in the '--schema' flag (so one could explicity say "include pg_catalog") In that case the use case to dump pg_class would be: pg_dump test_db --schema pg_catalog --table pg_class Such flag wouldn't break the existing behavior (which is, by default, to exclude system schemas) Chander