pg_dump --comment? - Mailing list pgsql-hackers

From Chris Campbell
Subject pg_dump --comment?
Date
Msg-id 40B69F86.2020002@bignerdranch.com
Whole thread Raw
Responses Re: pg_dump --comment?  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Re: pg_dump --comment?  (Jan Wieck <JanWieck@Yahoo.com>)
List pgsql-hackers
I've encountered a situation where I'd like to store some information 
about the database when I do a pg_dump. For instance, the timestamp of 
the dump. And some other information that I pull from the database.

If pg_dump had a --comment flag that allowed me to pass a string that 
would be stored inside the dumpfile, that I could then retrieve in some 
way (without doing a full restore of the dump), that would meet my 
needs. In discussing this idea with other people, it sounded like a 
general-use feature that mankind as a whole could benefit from. :)

Here's what I'm envisioning:
   pg_dump --comment 'This is a comment' <more pg_dump args>

That would store the comment ('This is a comment') in the dump file 
somehow. The definition of "somehow" would vary depending on the output 
format (text, tar, or custom). Initially, since I only use the custom 
format, I would only focus on getting it to work with that. But for the 
text format, there could be a SQL comment at the top of the file with

-- COMMENT: This is a comment

or something. In the tar format, there could be a "comment" file in the 
archive that contains the text "This is a comment".

For the custom format...I haven't looked at the format specification, so 
I don't know exactly where the comment would go. It could go at the very 
top of the file, and have a special delimiter after it. pg_restore would 
just skim over the file until the delimiter is reached, and then go on 
about its business. The benefit of this scheme is that any program could 
read the comment -- just open a file and read the bytes until the delimiter.

There could also be a pg_dump or pg_restore option that prints out the 
comment stored in a given dump file, or another binary (pg_comment?) 
that does that.

Is this a desirable feature? Should I work it up like described and 
submit a patch? Any comments/suggestions?

Thanks!

- Chris

pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: Win32, PITR, nested transactions, tablespaces
Next
From: Erwin Brandstetter
Date:
Subject: Dynamic fieldname with NEW structure in trigger function?