Thread: pg_dump save command in output

pg_dump save command in output

From
Joao Miguel Ferreira
Date:
Hello all,

is there a way to ask pg_dump to save a comment in the output file with the full command it is executing ?

thank you
Joao

Re: pg_dump save command in output

From
Adrian Klaver
Date:
On 10/3/21 9:56 AM, Joao Miguel Ferreira wrote:
> Hello all,
> 
> is there a way to ask pg_dump to save a comment in the output file with 
> the full command it is executing ?

No.

What information is the comment trying to convey?

Are you dumping in plain or custom format?

> 
> thank you
> Joao
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: pg_dump save command in output

From
Joao Miguel Ferreira
Date:


On Sun, Oct 3, 2021 at 6:03 PM Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 10/3/21 9:56 AM, Joao Miguel Ferreira wrote:
> Hello all,
>
> is there a way to ask pg_dump to save a comment in the output file with
> the full command it is executing ?

No.

What information is the comment trying to convey?

I just wanted to save the command inside the SQL file to be able to "remember" it later. ideally I would open the file on some text editor and see the original pg_dump command on the few first lines, as a comment

-- original command was: psql -h some_host -p .....
 

Are you dumping in plain or custom format?

plain (SQL)
 

>
> thank you
> Joao
>


--
Adrian Klaver
adrian.klaver@aklaver.com

Re: pg_dump save command in output

From
Karsten Hilbert
Date:
Am Sun, Oct 03, 2021 at 06:15:54PM +0100 schrieb Joao Miguel Ferreira:

> I just wanted to save the command inside the SQL file to be able to
> "remember" it later. ideally I would open the file on some text editor and
> see the original pg_dump command on the few first lines, as a comment
>
> -- original command was: psql -h some_host -p .....
>
> >
> > Are you dumping in plain or custom format?
> >
>
> plain (SQL)

Run the dump from a bash script which pre-catenates (Is that
even a word ? it is now :) the command into the plain (SQL)
output after the fact.

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B



Re: pg_dump save command in output

From
Adrian Klaver
Date:
On 10/3/21 10:15 AM, Joao Miguel Ferreira wrote:
> 

> I just wanted to save the command inside the SQL file to be able to 
> "remember" it later. ideally I would open the file on some text editor 
> and see the original pg_dump command on the few first lines, as a comment
> 
> -- original command was: psql -h some_host -p .....
> 
> 
>     Are you dumping in plain or custom format?
> 
> 
> plain (SQL)

A quick test here found that manually adding:

-- original command was: psql -h some_host -p .....

as:

-- Dumped by pg_dump version XX.x
-- original command was: psql -h some_host -p .....

at head of file did not infer with the restore.

No guarantees though.


> 
> 
>      >
>      > thank you
>      > Joao
>      >
> 
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: pg_dump save command in output

From
Daniel Gustafsson
Date:
> On 3 Oct 2021, at 18:56, Joao Miguel Ferreira <joao.miguel.c.ferreira@gmail.com> wrote:

> is there a way to ask pg_dump to save a comment in the output file with the full command it is executing ?

I think this idea has some merit.  Given the amount of switches for tailoring
the dump that pg_dump has there is a point to knowing just which ones were
used.  Connection level parameters should probably be scrubbed, but
object-level filtering etc could be handy.

Would you like to try and propose a patch for pg_dump to implement this?

--
Daniel Gustafsson        https://vmware.com/




Re: pg_dump save command in output

From
Joao Miguel Ferreira
Date:


On Wed, Oct 6, 2021 at 10:33 AM Daniel Gustafsson <daniel@yesql.se> wrote:
> On 3 Oct 2021, at 18:56, Joao Miguel Ferreira <joao.miguel.c.ferreira@gmail.com> wrote:

> is there a way to ask pg_dump to save a comment in the output file with the full command it is executing ?

I think this idea has some merit.  Given the amount of switches for tailoring
the dump that pg_dump has there is a point to knowing just which ones were
used.  Connection level parameters should probably be scrubbed, but
object-level filtering etc could be handy.

Would you like to try and propose a patch for pg_dump to implement this?
Hi Daniel, thank you for the feedback!

I would like to try that yes, it would be a pleasure but I have zero knowledge on the dev tools, setups and processes required for that.

If someone gives me some pointers I would love to try it. I'm a software developer so I should be able to at least try.

Can you point me to some hands-on docs on setting up my env ?

I use Debian Linux 10 and 11 VMs, if that is relevant, I could copy a VM for this purpose and start right away

Thank you
Joao (pg user for many many years)




 

--
Daniel Gustafsson               https://vmware.com/

Re: pg_dump save command in output

From
Laurenz Albe
Date:
On Wed, 2021-10-06 at 10:44 +0100, Joao Miguel Ferreira wrote:
> I would like to try that yes, it would be a pleasure but I have zero knowledge on the dev tools, setups and processes
requiredfor that. 
 
> 
> If someone gives me some pointers I would love to try it. I'm a software developer so I should be able to at least
try.
> 
> Can you point me to some hands-on docs on setting up my env ?

Here is an introductory article from the Wiki:

https://wiki.postgresql.org/wiki/So,_you_want_to_be_a_developer%3F

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




Re: pg_dump save command in output

From
Daniel Gustafsson
Date:
> On 6 Oct 2021, at 12:22, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
>
> On Wed, 2021-10-06 at 10:44 +0100, Joao Miguel Ferreira wrote:
>> I would like to try that yes, it would be a pleasure but I have zero knowledge on the dev tools, setups and
processesrequired for that.  
>>
>> If someone gives me some pointers I would love to try it. I'm a software developer so I should be able to at least
try.
>>
>> Can you point me to some hands-on docs on setting up my env ?
>
> Here is an introductory article from the Wiki:
>
> https://wiki.postgresql.org/wiki/So,_you_want_to_be_a_developer%3F

There is also the section in the docs for how to install a postgres instance
for source which will be handy:

    https://www.postgresql.org/docs/devel/installation.html

For an environment to hack in I would recommend enabling debig and TAP style
tests, and personally I always install to a specific folder (see the section on
developer options):

    ./configure --enable-debug --enable-tap-tests --prefix=path/to/dev/install

Feel free to reach out here if you get stuck on anything, so we can make the
Wiki page better.

--
Daniel Gustafsson        https://vmware.com/




Re: pg_dump save command in output

From
Joao Miguel Ferreira
Date:


On Wed, Oct 6, 2021 at 11:40 AM Daniel Gustafsson <daniel@yesql.se> wrote:
> On 6 Oct 2021, at 12:22, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
>
> On Wed, 2021-10-06 at 10:44 +0100, Joao Miguel Ferreira wrote:
>> I would like to try that yes, it would be a pleasure but I have zero knowledge on the dev tools, setups and processes required for that.
>>
>> If someone gives me some pointers I would love to try it. I'm a software developer so I should be able to at least try.
>>
>> Can you point me to some hands-on docs on setting up my env ?
>
> Here is an introductory article from the Wiki:
>
> https://wiki.postgresql.org/wiki/So,_you_want_to_be_a_developer%3F

There is also the section in the docs for how to install a postgres instance
for source which will be handy:

    https://www.postgresql.org/docs/devel/installation.html

For an environment to hack in I would recommend enabling debig and TAP style
tests, and personally I always install to a specific folder (see the section on
developer options):

    ./configure --enable-debug --enable-tap-tests --prefix=path/to/dev/install

Hi again, thank you both for the guidance. I will start reading and setting things up in the next few days
 

Feel free to reach out here if you get stuck on anything, so we can make the
Wiki page better.

sure
 

--
Daniel Gustafsson               https://vmware.com/