pg_dump save command in output

Started by Joao Ferreira gmailover 4 years ago10 messagesgeneral
Jump to latest
#1Joao Ferreira gmail
joao.miguel.c.ferreira@gmail.com

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

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Joao Ferreira gmail (#1)
Re: pg_dump save command in output

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

#3Joao Ferreira gmail
joao.miguel.c.ferreira@gmail.com
In reply to: Adrian Klaver (#2)
Re: pg_dump save command in output

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)

Show quoted text

thank you
Joao

--
Adrian Klaver
adrian.klaver@aklaver.com

#4Karsten Hilbert
Karsten.Hilbert@gmx.net
In reply to: Joao Ferreira gmail (#3)
Re: pg_dump save command in output

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

#5Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Joao Ferreira gmail (#3)
Re: pg_dump save command in output

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

#6Daniel Gustafsson
daniel@yesql.se
In reply to: Joao Ferreira gmail (#1)
Re: pg_dump save command in output

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/

#7Joao Ferreira gmail
joao.miguel.c.ferreira@gmail.com
In reply to: Daniel Gustafsson (#6)
Re: pg_dump save command in output

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)

Show quoted text

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

#8Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Joao Ferreira gmail (#7)
Re: pg_dump save command in output

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

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

#9Daniel Gustafsson
daniel@yesql.se
In reply to: Laurenz Albe (#8)
Re: pg_dump save command in output

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

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/

#10Joao Ferreira gmail
joao.miguel.c.ferreira@gmail.com
In reply to: Daniel Gustafsson (#9)
Re: pg_dump save command in output

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

Show quoted text

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