Folks,
Although this is not really a JDBC problem, I initially posted it on the
JDBC group because I thought the Java folks would be there. I got no
response, so am posting here.
I have a PostgreSQL Java client CRUD GUI app that does backup and
restore by running pg_dump and pg_restore with a Process. A BufferedReader
attached to stderr catches the Password: prompt, the password is provided, and
the output is then captured for display. All worked fine with PostgreSQL
8.1. I updated to PostgreSQL 8.2, and the app is now broken.
I wrote a simple Java app (code available on request) to try to diagnose
the problem by comparing Java Process results with those obtained from
running the PostgreSQL utility from the command prompt.. It creates a
Process, attaches BufferedReaders to stdout and stderr, and each reader is
read character-by-character when its ready() returns 'true'. if ready() is
false, three read attempts are made with brief timeouts between
(Thread.sleep(100)). I tested Windows ipconfig.exe (as a control
condition) and six PostgreSQL utilities. Here are the results.
Using the --help parameter always works (createdb, createuser, dropdb,
initdb, pg_dump, and pg_restore). Output on stdout matches
command-prompt results and stderr has a blank line output. Exit code is
0.
Using no parameters, dropdb produces an error message from the command-line
that is not shown with the Java app (exit code is 1); createdb shows a
password prompt on command-line, nothing on the Java app, throws exit
error.
With a user (-Upostgres) parameter, the following utilities show a
password prompt from the command-line and nothing on the Java app, throwing an
exit error: createdb, pg_restore, pg_dump.
Incidentally findings. without command-line parameters, pg_restore
hangs. Shouldn't it close with an error message? The help shown by the
pg_dump utility doesn't entirely match the documentation in the manual.
The big problem is where has the utility output, specifically error
messages and prompts, gone? Does this qualify as a bug? How to
un-break my Java app (and other Java apps that may be doing similar
things)?
Michael Schmidt
|