pg_restore -d doesn't display output

Started by Bruce Momjianover 22 years ago6 messageshackers
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Does anyone know why 'pg_restore -d' doesn't display the commands being
executed, like you see when you don't use '-d':

pg_dump -Fc test >/tmp/test.db
pg_restore < /tmp/test.db
pg_restore -d test < /tmp/test.db

The first pg_restore displays the commands, while the second does not.

-- 
  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
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: pg_restore -d doesn't display output

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Does anyone know why 'pg_restore -d' doesn't display the commands being
executed, like you see when you don't use '-d':

pg_restore < /tmp/test.db
pg_restore -d test < /tmp/test.db

The first sends a script to stdout (effectively equivalent to pg_dump
plain style). The second sends the commands to a backend.

I would have expected there to be a --verbose option that would also echo
the commands to stderr, but it doesn't look like there's any support for
that in the code.

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: pg_restore -d doesn't display output

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Does anyone know why 'pg_restore -d' doesn't display the commands being
executed, like you see when you don't use '-d':

pg_restore < /tmp/test.db
pg_restore -d test < /tmp/test.db

The first sends a script to stdout (effectively equivalent to pg_dump
plain style). The second sends the commands to a backend.

I would have expected there to be a --verbose option that would also echo
the commands to stderr, but it doesn't look like there's any support for
that in the code.

I don't understand why sending something to a backend should effect the
script output.

-- 
  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
#4Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#3)
Re: [HACKERS] pg_restore -d doesn't display output

Bruce Momjian wrote:

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Does anyone know why 'pg_restore -d' doesn't display the commands being
executed, like you see when you don't use '-d':

pg_restore < /tmp/test.db
pg_restore -d test < /tmp/test.db

The first sends a script to stdout (effectively equivalent to pg_dump
plain style). The second sends the commands to a backend.

I would have expected there to be a --verbose option that would also echo
the commands to stderr, but it doesn't look like there's any support for
that in the code.

I don't understand why sending something to a backend should effect the
script output.

I have patched pg_restore to output the script contents if you restore
with -v:

pg_restore -v -d test /tmp/x

Patch attached. I will save this for 7.5.

-- 
  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

Attachments:

/pgpatches/dumptext/plainDownload+6-6
#5Peter Eisentraut
peter_e@gmx.net
In reply to: Bruce Momjian (#4)
Re: [HACKERS] pg_restore -d doesn't display output

Bruce Momjian writes:

I have patched pg_restore to output the script contents if you restore
with -v:

I don't think it's a good idea to overload the -v switch with it. A
separate switch seems OK, but I don't quite get the point of this
functionality, actually.

--
Peter Eisentraut peter_e@gmx.net

#6Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#5)
Re: [HACKERS] pg_restore -d doesn't display output

Peter Eisentraut wrote:

Bruce Momjian writes:

I have patched pg_restore to output the script contents if you restore
with -v:

I don't think it's a good idea to overload the -v switch with it. A
separate switch seems OK, but I don't quite get the point of this
functionality, actually.

Oh, OK. When I was testing, I didn't realize that pg_restore doesn't do
anything unless you specify the database via -d, but I see it in the
docs now:

pg_restore can operate in two modes: If a database name is
specified, the archive is restored directly into the
database. Otherwise, a script containing the SQL commands
necessary to rebuild the database is created (and written
to a file or standard output), similar to the ones created
by the pg_dump plain text format. Some of the options con-
trolling the script output are therefore analogous to
pg_dump options.

-- 
  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