Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <[EMAIL PROTECTED]> 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
  [EMAIL PROTECTED]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/bin/pg_dump/pg_backup_archiver.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_backup_archiver.c,v
retrieving revision 1.78
diff -c -c -r1.78 pg_backup_archiver.c
*** src/bin/pg_dump/pg_backup_archiver.c        3 Oct 2003 20:10:59 -0000       1.78
--- src/bin/pg_dump/pg_backup_archiver.c        8 Oct 2003 04:43:39 -0000
***************
*** 1232,1246 ****
                 * connected then send it to the DB.
                 */
                if (RestoringToDB(AH))
!                       return ExecuteSqlCommandBuf(AH, (void *) ptr, size * nmemb);   
         /* Always 1, currently */
!               else
                {
                        res = fwrite((void *) ptr, size, nmemb, AH->OF);
                        if (res != nmemb)
                                die_horribly(AH, modulename, "could not write to 
output file (%lu != %lu)\n",
                                                         (unsigned long) res, 
(unsigned long) nmemb);
-                       return res;
                }
        }
  }
  
--- 1232,1247 ----
                 * connected then send it to the DB.
                 */
                if (RestoringToDB(AH))
!                       res = ExecuteSqlCommandBuf(AH, (void *) ptr, size * nmemb);    
 /* Always 1, currently */
! 
!               if (!RestoringToDB(AH) || AH->public.verbose)
                {
                        res = fwrite((void *) ptr, size, nmemb, AH->OF);
                        if (res != nmemb)
                                die_horribly(AH, modulename, "could not write to 
output file (%lu != %lu)\n",
                                                         (unsigned long) res, 
(unsigned long) nmemb);
                }
+               return res;
        }
  }
  
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to