Apologies - this post is a bit long - but the gist is this...
1. pg_dump appears to send its output to stderr.
2. I suspect it should go to stdout.
(using PG8.1.3 on WinXP with Java/Hibernate)
I am a Java developer, and we are successfully building a distributed
desktop application for a small office setting using Postgress as our
data repository. Our SQL & Postgres skills are mediocre, but as most
things are hidden behind Hibernate ORM this has not been an issue.
Currently I am adding the capability for the database to be
automatically backed up. Manually this could be done using pgAdminIII
or perhaps a command line console using parameters such as ..
C:\Program Files\PostgreSQL\8.1\bin\pg_dump.exe -i -h localhost -p
5432 -U pgsuperuser -F c -b -v -f "C:\dummy.backup" devdb
The output of the process is then written to the console so the output
is like ..
pg_dump: reading schemas
pg_dump: reading user-defined functions
pg_dump: reading user-defined types
pg_dump: reading procedural languages
... etc etc etc ....
We have automated this in our Java application using ProcessBuilder
(to run pg_dump), and we can successfully restore the backup we
automatically create. So at this stage all appears good.
HOWEVER, it appears that this ouput is being directed to stderr, not stdout.
My original intention was to log all "stderr" output (assuming it
signified a real problem), and ignore all "stdout" output (assuming
all was well). If all output goes to stderr I cannot differentiate as
QuestionOne: Should this output go to sdout, and NOT to stderr???
So why do I think it goes to stderr? .....
To run a program like pg_dump from within Java you would typically use
ProcessBuilder. So the code could be like this (simplifying for
ProcessBuilder pb = new ProcessBuilder(cmds); // adds all the commands via cmds
Process process = pb.start(); // kick it off
StreamGobbler errorStream = new
StreamGobbler(process.getErrorStream()); // error
StreamGobbler stdStream = new StreamGobbler(process.getInputStream()); // std
So you can see that we pick up the two separate Streams (stderr &
stdout) that collect the output from the process. When I look at those
I find that pg_dump has sent all output to errorStream.
Can anyone guide me? The options appear to be ..
1. I have gone mad.
2. My own SNAFU.
3. pg_dump is correct to send its output to stderr.
4. pg_dump bug - it should go to stdout, not stderr.
5. Java bug (I doubt it - process.getErrorStream() is basic stuff)
Any guidance is appreciated.
pgsql-novice by date
|Next:||From: Tom Lane||Date: 2006-08-21 01:23:36|
|Subject: Re: pg_dump output goes to stderr, not stdout?!? |
|Previous:||From: ben sewell||Date: 2006-08-20 16:13:22|
|Subject: Re: Function error- A column definition list is required for functions returning "record"|