Re: Dump all except some tables?

Lists: pgsql-general
From: "Roger Hand" <RHand(at)kailea(dot)com>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, "David Fetter" <david(at)fetter(dot)org>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "WireSpot" <wirespot(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Dump all except some tables?
Date: 2005-10-06 23:31:14
Message-ID: DB28E9B548192448A4E8C8A3C1B1E475611D56@sj1-exch-01.us.corp.kailea.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Jim C. Nasby
> Sent: Thursday, October 06, 2005 3:34 PM
> Subject: Re: [GENERAL] Dump all except some tables?
>
> ... I find myself
> wondering if it would be good to allow for specifying a set of rules for
> what to dump in a file, probably something like a set of regexes with a
> way to specify if it's an include or exclude rule. Seems like it would
> be a heck of a lot simpler to do that for complex cases than deal with a
> pile of spaghetti on the command-line

It may be useful to cut down on command line clutter if one could specify
a file holding a list of table names to include/exclude.

-Roger

> Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com


From: David Fetter <david(at)fetter(dot)org>
To: Roger Hand <RHand(at)kailea(dot)com>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, WireSpot <wirespot(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Dump all except some tables?
Date: 2005-10-07 00:12:24
Message-ID: 20051007001224.GE30487@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Oct 06, 2005 at 04:31:14PM -0700, Roger Hand wrote:
> > From: pgsql-general-owner(at)postgresql(dot)org
> > [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Jim C. Nasby
> > Sent: Thursday, October 06, 2005 3:34 PM
> > Subject: Re: [GENERAL] Dump all except some tables?
> >
> > ... I find myself wondering if it would be good to allow for
> > specifying a set of rules for what to dump in a file, probably
> > something like a set of regexes with a way to specify if it's an
> > include or exclude rule. Seems like it would be a heck of a lot
> > simpler to do that for complex cases than deal with a pile of
> > spaghetti on the command-line
>
> It may be useful to cut down on command line clutter if one could
> specify a file holding a list of table names to include/exclude.

Here's my thoughts on a summary:

[-t [table | glob]]... # 0 or more -t options
[-T [table | glob]]... # 0 or more -T options
[--include-tables-from-file f]
[--exclude-tables-from-file f]

where globs get expanded just the way they are in psql, and the
exclude is evaluated after the include to remove any tables where they
might conflict. I don't think regex matching is needed or good.

Does this make sense?

Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!


From: WireSpot <wirespot(at)gmail(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: Roger Hand <RHand(at)kailea(dot)com>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Dump all except some tables?
Date: 2005-10-07 08:47:26
Message-ID: b2d4b0380510070147j3e2b236fn19541297d8614095@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 10/7/05, David Fetter <david(at)fetter(dot)org> wrote:
> Here's my thoughts on a summary:
>
> [-t [table | glob]]... # 0 or more -t options
> [-T [table | glob]]... # 0 or more -T options
> [--include-tables-from-file f]
> [--exclude-tables-from-file f]
>
> where globs get expanded just the way they are in psql, and the
> exclude is evaluated after the include to remove any tables where they
> might conflict. I don't think regex matching is needed or good.
>
> Does this make sense?

Sure does, and it looks good.

But... will the resulting dump be consistent as far as foreign keys
are concerned? Or will the current -t warning still apply (YMMV as to
the consistency of the resulting dump)?

If it's my job to ensure foreign key consistency, an option that only
dumps foreign keys and/or omits the foreign keys from the dump would
also be essential... Grepping a full dump, as I said, is not nice,
plus the foreign keys are multi-line which complicates grepping.

If both table filtering and the foreign key options would be
implemented, one could truly do useful dumps using pg_dump alone. I
could dump only some tables sans the foreign keys, then dump the
foreign keys separately and take it from there.

I know that I can get the foreign keys from a schema-only dump. But an
"don't dump foreign keys" option would still help.


From: David Fetter <david(at)fetter(dot)org>
To: WireSpot <wirespot(at)gmail(dot)com>
Cc: Roger Hand <RHand(at)kailea(dot)com>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Dump all except some tables?
Date: 2005-10-07 09:07:47
Message-ID: 20051007090747.GC5149@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Fri, Oct 07, 2005 at 11:47:26AM +0300, WireSpot wrote:
> On 10/7/05, David Fetter <david(at)fetter(dot)org> wrote:
> > Here's my thoughts on a summary:
> >
> > [-t [table | glob]]... # 0 or more -t options
> > [-T [table | glob]]... # 0 or more -T options
> > [--include-tables-from-file f]
> > [--exclude-tables-from-file f]
> >
> > where globs get expanded just the way they are in psql, and the
> > exclude is evaluated after the include to remove any tables where
> > they might conflict. I don't think regex matching is needed or
> > good.
> >
> > Does this make sense?
>
> Sure does, and it looks good.
>
> But... will the resulting dump be consistent as far as foreign keys
> are concerned? Or will the current -t warning still apply (YMMV as
> to the consistency of the resulting dump)?

I think the latter is better. This is solidly in the realm of prying
off cover plates, and the warning is already there :)

> If it's my job to ensure foreign key consistency, an option that
> only dumps foreign keys and/or omits the foreign keys from the dump
> would also be essential... Grepping a full dump, as I said, is not
> nice, plus the foreign keys are multi-line which complicates
> grepping.

I think we can avoid a giant rat hole here by not trying to follow
foreign keys. Can we consider following foreign keys a separate
feature for later discussion and just go with the (not totally
trivial) considerations of schema and table inclusion and exclusion?

Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!


From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: WireSpot <wirespot(at)gmail(dot)com>, Roger Hand <RHand(at)kailea(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Dump all except some tables?
Date: 2005-10-08 01:21:31
Message-ID: 20051008012131.GB36108@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Fri, Oct 07, 2005 at 02:07:47AM -0700, David Fetter wrote:
> On Fri, Oct 07, 2005 at 11:47:26AM +0300, WireSpot wrote:
> > But... will the resulting dump be consistent as far as foreign keys
> > are concerned? Or will the current -t warning still apply (YMMV as
> > to the consistency of the resulting dump)?
>
> I think the latter is better. This is solidly in the realm of prying
> off cover plates, and the warning is already there :)

I think it would be good to include an option that only does checking
and doesn't actually try to dump anything. That would make it easier to
ensure your config file is correct.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461


From: David Fetter <david(at)fetter(dot)org>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
Cc: WireSpot <wirespot(at)gmail(dot)com>, Roger Hand <RHand(at)kailea(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Dump all except some tables?
Date: 2005-10-08 21:22:23
Message-ID: 20051008212223.GB24701@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Fri, Oct 07, 2005 at 08:21:31PM -0500, Jim C. Nasby wrote:
> On Fri, Oct 07, 2005 at 02:07:47AM -0700, David Fetter wrote:
> > On Fri, Oct 07, 2005 at 11:47:26AM +0300, WireSpot wrote:
> > > But... will the resulting dump be consistent as far as foreign
> > > keys are concerned? Or will the current -t warning still apply
> > > (YMMV as to the consistency of the resulting dump)?
> >
> > I think the latter is better. This is solidly in the realm of
> > prying off cover plates, and the warning is already there :)
>
> I think it would be good to include an option that only does
> checking and doesn't actually try to dump anything. That would make
> it easier to ensure your config file is correct.

Could you flesh this out a bit? What would this option produce in the
(imho most common) case where dependencies weren't all taken care of?

Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!


From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: WireSpot <wirespot(at)gmail(dot)com>, Roger Hand <RHand(at)kailea(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Dump all except some tables?
Date: 2005-10-08 22:33:16
Message-ID: 20051008223316.GA36108@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Sat, Oct 08, 2005 at 02:22:23PM -0700, David Fetter wrote:
> On Fri, Oct 07, 2005 at 08:21:31PM -0500, Jim C. Nasby wrote:
> > On Fri, Oct 07, 2005 at 02:07:47AM -0700, David Fetter wrote:
> > > On Fri, Oct 07, 2005 at 11:47:26AM +0300, WireSpot wrote:
> > > > But... will the resulting dump be consistent as far as foreign
> > > > keys are concerned? Or will the current -t warning still apply
> > > > (YMMV as to the consistency of the resulting dump)?
> > >
> > > I think the latter is better. This is solidly in the realm of
> > > prying off cover plates, and the warning is already there :)
> >
> > I think it would be good to include an option that only does
> > checking and doesn't actually try to dump anything. That would make
> > it easier to ensure your config file is correct.
>
> Could you flesh this out a bit? What would this option produce in the
> (imho most common) case where dependencies weren't all taken care of?

For one thing, it would produce a list of missing dependancies (or any
other errors that could be detected without doing the actual dump, for
that matter). I think that when trying to setup a non-trival dump
scenario, it would be great to actually produce output stating exactly
what dump would have done had it run for real. One way to think of it
would be running pg_dump -v and piping stdout to /dev/null.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461


From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Dump all except some tables?
Date: 2005-10-09 00:36:21
Message-ID: 60zmpjil16.fsf@dba2.int.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

david(at)fetter(dot)org (David Fetter) writes:
> On Fri, Oct 07, 2005 at 08:21:31PM -0500, Jim C. Nasby wrote:
>> On Fri, Oct 07, 2005 at 02:07:47AM -0700, David Fetter wrote:
>> > On Fri, Oct 07, 2005 at 11:47:26AM +0300, WireSpot wrote:
>> > > But... will the resulting dump be consistent as far as foreign
>> > > keys are concerned? Or will the current -t warning still apply
>> > > (YMMV as to the consistency of the resulting dump)?
>> >
>> > I think the latter is better. This is solidly in the realm of
>> > prying off cover plates, and the warning is already there :)
>>
>> I think it would be good to include an option that only does
>> checking and doesn't actually try to dump anything. That would make
>> it easier to ensure your config file is correct.
>
> Could you flesh this out a bit? What would this option produce in the
> (imho most common) case where dependencies weren't all taken care of?

I'd think that throwing in the "-s" option would allow a meaningful
dry run...
--
let name="cbbrowne" and tld="cbbrowne.com" in name ^ "@" ^ tld;;
http://www.ntlug.org/~cbbrowne/languages.html
Frisbeetarianism: The belief that when you die, your soul goes up on
the roof and gets stuck...