Thread: pg_dump options and perhaps 'Enhancement request'

pg_dump options and perhaps 'Enhancement request'

From
Terry Yapt
Date:
Hi all,

I don't know if I can do this stuffs.  If not I would like to get it in
the future.  Thanks.

1-) Are there any way to do a pg_dump without '--' COMMENTS ?  For
example, I don't like to have this in my output file:
--
-- TOC entry 19 (OID 26027)
-- Name: TABLE news; Type: COMMENT; Schema: www; Owner: www
--

2-) The same for the 'blank' lines.  Are there a lot of in the output
file.

3-) Are there any way to get the output file with schemas in all
table_names ?
I would like to get this:
COMMENT ON TABLE www.fo_temas IS 'xxxx.';  -- instead of:
COMMENT ON TABLE     fo_temas IS 'xxxx.';

Thanks in advance...


Re: pg_dump options and perhaps 'Enhancement request'

From
Andrew Sullivan
Date:
On Thu, May 08, 2003 at 10:11:48PM +0200, Terry Yapt wrote:
> 1-) Are there any way to do a pg_dump without '--' COMMENTS ?  For
> example, I don't like to have this in my output file:
> --
> -- TOC entry 19 (OID 26027)
> -- Name: TABLE news; Type: COMMENT; Schema: www; Owner: www
> --

You could do this with grep (and something similar for blank lines):

pg_dump [options] dbname | grep -v "^--" > dumpfile

A

--
----
Andrew Sullivan                         204-4141 Yonge Street
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110


Re: pg_dump options and perhaps 'Enhancement request'

From
Reece Hart
Date:
On Thu, 2003-05-08 at 13:11, Terry Yapt wrote:
> I don't know if I can do this stuffs.  If not I would like to get it in
> the future.  Thanks.
>
> 1-) Are there any way to do a pg_dump without '--' COMMENTS ?  For
> example, I don't like to have this in my output file:
> --
> -- TOC entry 19 (OID 26027)
> -- Name: TABLE news; Type: COMMENT; Schema: www; Owner: www
> --
>
> 2-) The same for the 'blank' lines.  Are there a lot of in the output
> file.

The plain-text pg_dump output is just that and you can use various
command line tools to strip out stuff you don't like.  A simple solution
for most cases:

$ pg_dump [args] | egrep -v '^--|^$' >backup.sql

HOWEVER, if you have the diabolical case of a table whose first column
is a text type AND a row in which that first column's text begins with
'--', then you'll strip those too.  I think you're safe otherwise.
(newlines are translated as '\n').

> 3-) Are there any way to get the output file with schemas in all
> table_names ?
> I would like to get this:
> COMMENT ON TABLE www.fo_temas IS 'xxxx.';  -- instead of:
> COMMENT ON TABLE     fo_temas IS 'xxxx.';

This is fairly easy with a simple perl script.
--
Reece Hart, Ph.D.                       rkh@gene.com, http://www.gene.com/
Genentech, Inc.                         650/225-6133 (voice), -5389 (fax)
Bioinformatics and Protein Engineering
1 DNA Way, MS-93                        http://www.in-machina.com/~reece/
South San Francisco, CA  94080-4990     reece@in-machina.com, GPG: 0x25EC91A0


Re: pg_dump options and perhaps 'Enhancement request'

From
Terry Yapt
Date:
Ok.. ok...

I know I can do a lot of things with external software or utilities (even with sed, vi or others).  I can develop my
ownsoftware tool to do what I want to do too.  But, I think PostgreSQL team is porting this great DB to Win32 now.  Ok,
Ican tell you the windows guys don't have so much utilities like linux/unix guys or worse perhaps they will be users
onlyand don't know how to use perl or something similar. 

I only want a 'clear' pg_dump if it is possible and with SCHEMA.object_name ala ORACLE if it is possible too.

Thanks a lot four your answers...

Andrew Sullivan wrote:
>
> On Thu, May 08, 2003 at 10:11:48PM +0200, Terry Yapt wrote:
> > 1-) Are there any way to do a pg_dump without '--' COMMENTS ?  For
> > example, I don't like to have this in my output file:
> > --
> > -- TOC entry 19 (OID 26027)
> > -- Name: TABLE news; Type: COMMENT; Schema: www; Owner: www
> > --
>
> You could do this with grep (and something similar for blank lines):
>
> pg_dump [options] dbname | grep -v "^--" > dumpfile
>
> A
>
> --
> ----
> Andrew Sullivan                         204-4141 Yonge Street
> Liberty RMS                           Toronto, Ontario Canada
> <andrew@libertyrms.info>                              M2P 2A8
>                                          +1 416 646 3304 x110
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly


Re: pg_dump options and perhaps 'Enhancement request'

From
Dennis Gearon
Date:
This guy raises a good point, albeit indirectly. The transitions from one major version to another need to be smoother
ifPostgres is going to gain any more acceptance in big database circles. 

A dump file shouldn't have to be messed with to reload it into the next version. There should be a 'conversion tool' or
scriptbetween each version. And if a customer waits 8 versions to update, those tools, used in sequence, should be able
tochange his old dump to be imported into the latest version. 

Terry Yapt wrote:
> Ok.. ok...
>
> I know I can do a lot of things with external software or utilities (even with sed, vi or others).  I can develop my
ownsoftware tool to do what I want to do too.  But, I think PostgreSQL team is porting this great DB to Win32 now.  Ok,
Ican tell you the windows guys don't have so much utilities like linux/unix guys or worse perhaps they will be users
onlyand don't know how to use perl or something similar. 
>
> I only want a 'clear' pg_dump if it is possible and with SCHEMA.object_name ala ORACLE if it is possible too.
>
> Thanks a lot four your answers...
>
> Andrew Sullivan wrote:
>
>>On Thu, May 08, 2003 at 10:11:48PM +0200, Terry Yapt wrote:
>>
>>>1-) Are there any way to do a pg_dump without '--' COMMENTS ?  For
>>>example, I don't like to have this in my output file:
>>>--
>>>-- TOC entry 19 (OID 26027)
>>>-- Name: TABLE news; Type: COMMENT; Schema: www; Owner: www
>>>--
>>
>>You could do this with grep (and something similar for blank lines):
>>
>>pg_dump [options] dbname | grep -v "^--" > dumpfile
>>
>>A
>>
>>--
>>----
>>Andrew Sullivan                         204-4141 Yonge Street
>>Liberty RMS                           Toronto, Ontario Canada
>><andrew@libertyrms.info>                              M2P 2A8
>>                                         +1 416 646 3304 x110
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 3: if posting/reading through Usenet, please send an appropriate
>>subscribe-nomail command to majordomo@postgresql.org so that your
>>message can get through to the mailing list cleanly
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>