pg_dump a specific schema

Started by Neil Conwayover 23 years ago19 messagespatches
Jump to latest
#1Neil Conway
neilc@samurai.com

This patch allows pg_dump to dump the contents of a specific schema, and
updates the documentation for pg_dump.

I used the '-n' and '--namespace' command-line arguments. I did some
limited testing and it seems to work fine, but there may be some bugs
lurking in it...

BTW, If the user specifies a non-existent namespace, what should pg_dump
do? ISTM that printing an error message and aborting the dump is
probably best, but presently non-existent namespaces are ignored, since
-t follows a similar policy. Should we change both of these?

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

Attachments:

ns_pg_dump-4.patchtext/x-patch; charset=ANSI_X3.4-1968; name=ns_pg_dump-4.patchDownload+146-81
#2Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#1)
Re: pg_dump a specific schema

Neil Conway wrote:

This patch allows pg_dump to dump the contents of a specific schema, and
updates the documentation for pg_dump.

I used the '-n' and '--namespace' command-line arguments. I did some
limited testing and it seems to work fine, but there may be some bugs
lurking in it...

BTW, If the user specifies a non-existent namespace, what should pg_dump
do? ISTM that printing an error message and aborting the dump is
probably best, but presently non-existent namespaces are ignored, since
-t follows a similar policy. Should we change both of these?

I can't think of any logic that would allow a table to be skipped on a
dump, same with namespaces.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Neil Conway
neilc@samurai.com
In reply to: Bruce Momjian (#2)
Re: pg_dump a specific schema

On Fri, 2003-01-10 at 13:32, Bruce Momjian wrote:

I can't think of any logic that would allow a table to be skipped on a
dump, same with namespaces.

Uh, what? The issue is that:

pg_dump -t some_non_existent_table_name

produces an empty dump (well, it has a 3 lines of comments, but no SQL).
Similarly:

pg_dump -n some_non_existent_schema_name

also produces an empty dump. I'm asking if that's the correct behavior:
perhaps we should throw an error instead?

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

#4Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#3)
Re: pg_dump a specific schema

Neil Conway wrote:

On Fri, 2003-01-10 at 13:32, Bruce Momjian wrote:

I can't think of any logic that would allow a table to be skipped on a
dump, same with namespaces.

Uh, what? The issue is that:

pg_dump -t some_non_existent_table_name

produces an empty dump (well, it has a 3 lines of comments, but no SQL).
Similarly:

pg_dump -n some_non_existent_schema_name

also produces an empty dump. I'm asking if that's the correct behavior:
perhaps we should throw an error instead?

We certainly should throw an error!

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Peter Eisentraut
peter_e@gmx.net
In reply to: Neil Conway (#1)
Re: pg_dump a specific schema

Neil Conway writes:

I used the '-n' and '--namespace' command-line arguments.

Please do not export the term namespace to the user space. Use schema
instead.

--
Peter Eisentraut peter_e@gmx.net

#6Neil Conway
neilc@samurai.com
In reply to: Peter Eisentraut (#5)
Re: pg_dump a specific schema

On Fri, 2003-01-10 at 17:08, Peter Eisentraut wrote:

Please do not export the term namespace to the user space. Use schema
instead.

Oh, yeah -- I was going to ask about that. If I should use "schema",
what command-line argument do you suggest? (-s and -S are taken)

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

#7Ross J. Reedstrom
reedstrm@rice.edu
In reply to: Peter Eisentraut (#5)
Re: pg_dump a specific schema

On Fri, Jan 10, 2003 at 11:08:09PM +0100, Peter Eisentraut wrote:

Neil Conway writes:

I used the '-n' and '--namespace' command-line arguments.

Please do not export the term namespace to the user space. Use schema
instead.

Here we have the problem of colliding nomenclature. Pg_dump already uses
the word schema in its generic RDB sense, rather than its SQL standard
sense. Got any ideas on what to call it instead? One option would be to
bite the bullet, and rename our current 'schema-only' option to 'DDL-only'
although that's not completely accurate.

BTW, -n _was_ the 'suppress unneeded quotes' flag/option. You overrode that?

Ross

#8Neil Conway
neilc@samurai.com
In reply to: Ross J. Reedstrom (#7)
Re: pg_dump a specific schema

On Fri, 2003-01-10 at 17:14, Ross J. Reedstrom wrote:

BTW, -n _was_ the 'suppress unneeded quotes' flag/option. You overrode that?

No, that's not been present since 7.3

Cheers,

Neil

#9Ross J. Reedstrom
reedstrm@rice.edu
In reply to: Neil Conway (#8)
Re: pg_dump a specific schema

On Fri, Jan 10, 2003 at 05:23:20PM -0500, Neil Conway wrote:

On Fri, 2003-01-10 at 17:14, Ross J. Reedstrom wrote:

BTW, -n _was_ the 'suppress unneeded quotes' flag/option. You overrode that?

No, that's not been present since 7.3

Right, sorry, I was looking on the older install (a 7.2 box)

Ross

#10Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#5)
Re: pg_dump a specific schema

Peter Eisentraut wrote:

Neil Conway writes:

I used the '-n' and '--namespace' command-line arguments.

Please do not export the term namespace to the user space. Use schema
instead.

We already exported it as \dn for namespace/schema.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#11Neil Conway
neilc@samurai.com
In reply to: Bruce Momjian (#4)
Re: pg_dump a specific schema

On Fri, 2003-01-10 at 16:45, Bruce Momjian wrote:

Neil Conway wrote:

I'm asking if that's the correct behavior:
perhaps we should throw an error instead?

We certainly should throw an error!

Ok, I've attached a revised version of the patch that throws an error if
the user specifies a non-existent object for "-t" or "-n". I also made a
few minor updates and documentation improvements.

I'll change the command-line args once we've reached a consensus on what
they should be.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

Attachments:

ns_pg_dump-5.patchtext/x-patch; charset=ANSI_X3.4-1968; name=ns_pg_dump-5.patchDownload+235-140
#12Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Peter Eisentraut (#5)
Re: pg_dump a specific schema

I used the '-n' and '--namespace' command-line arguments.

Please do not export the term namespace to the user space. Use schema
instead.

Hmmm - what about \dn and \? in psql CVS?

Chris

#13Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#11)
Re: pg_dump a specific schema

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Neil Conway wrote:

On Fri, 2003-01-10 at 16:45, Bruce Momjian wrote:

Neil Conway wrote:

I'm asking if that's the correct behavior:
perhaps we should throw an error instead?

We certainly should throw an error!

Ok, I've attached a revised version of the patch that throws an error if
the user specifies a non-existent object for "-t" or "-n". I also made a
few minor updates and documentation improvements.

I'll change the command-line args once we've reached a consensus on what
they should be.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#14Peter Eisentraut
peter_e@gmx.net
In reply to: Bruce Momjian (#13)
Re: pg_dump a specific schema

Please wait till we resolve the naming of the command-line arguments.

Bruce Momjian writes:

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Neil Conway wrote:

On Fri, 2003-01-10 at 16:45, Bruce Momjian wrote:

Neil Conway wrote:

I'm asking if that's the correct behavior:
perhaps we should throw an error instead?

We certainly should throw an error!

Ok, I've attached a revised version of the patch that throws an error if
the user specifies a non-existent object for "-t" or "-n". I also made a
few minor updates and documentation improvements.

I'll change the command-line args once we've reached a consensus on what
they should be.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

--
Peter Eisentraut peter_e@gmx.net

#15Peter Eisentraut
peter_e@gmx.net
In reply to: Neil Conway (#6)
Re: pg_dump a specific schema

Neil Conway writes:

Oh, yeah -- I was going to ask about that. If I should use "schema",
what command-line argument do you suggest? (-s and -S are taken)

I don't care what you use for short options if all useful ones are taken.
But the long option should be --schema.

--
Peter Eisentraut peter_e@gmx.net

#16Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#11)
Re: pg_dump a specific schema

Removed from queue at the request of Peter.

---------------------------------------------------------------------------

Neil Conway wrote:

On Fri, 2003-01-10 at 16:45, Bruce Momjian wrote:

Neil Conway wrote:

I'm asking if that's the correct behavior:
perhaps we should throw an error instead?

We certainly should throw an error!

Ok, I've attached a revised version of the patch that throws an error if
the user specifies a non-existent object for "-t" or "-n". I also made a
few minor updates and documentation improvements.

I'll change the command-line args once we've reached a consensus on what
they should be.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#17Neil Conway
neilc@samurai.com
In reply to: Peter Eisentraut (#15)
Re: pg_dump a specific schema

On Sun, 2003-01-12 at 11:55, Peter Eisentraut wrote:

I don't care what you use for short options if all useful ones are taken.
But the long option should be --schema.

Ok, fair enough: a revised patch is attached that uses the '-n' short
option and the '--schema' long option.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

Attachments:

ns_pg_dump-7.patchtext/x-patch; charset=ANSI_X3.4-1968; name=ns_pg_dump-7.patchDownload+234-140
#18Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#17)
Re: pg_dump a specific schema

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Neil Conway wrote:

On Sun, 2003-01-12 at 11:55, Peter Eisentraut wrote:

I don't care what you use for short options if all useful ones are taken.
But the long option should be --schema.

Ok, fair enough: a revised patch is attached that uses the '-n' short
option and the '--schema' long option.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#19Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#17)
Re: pg_dump a specific schema

Patch applied. Thanks.

---------------------------------------------------------------------------

Neil Conway wrote:

On Sun, 2003-01-12 at 11:55, Peter Eisentraut wrote:

I don't care what you use for short options if all useful ones are taken.
But the long option should be --schema.

Ok, fair enough: a revised patch is attached that uses the '-n' short
option and the '--schema' long option.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073