User control over psql error stream

Karl O. Pinc <kop@meme.com>

From: "Karl O. Pinc" <kop@meme.com>
To: pgsql-hackers@postgresql.org
Date: 2012-11-15T20:53:24Z
Lists: pgsql-hackers

Attachments

Hi,

This patch gives the end user control over psql's
error stream.  This allows a single psql session
to use \o to send both errors and table output
to multiple files.  Useful when capturing test output, etc.

Control is provided via a new "estream" \pset.  Here's
the docs.

-------------------------<snip>------------------------
estream

    Controls the output stream(s) used to report error messages. Value 
must be one of: stderr (the default), which sends errors to the 
standard error stream; query, which injects error messages into the 
query result output stream; or both, which sends errors to both output 
streams. "Error messages" are comprised of errors from psql and notice 
messages and errors from the database server. 
-------------------------<snip>------------------------

Against head.

psql-estream.patch       The patch.
psql-estream_test.patch  Adds a regression test to test the patch.

There's a number of problems with psql-estream_test.patch,
the most notable is that it probably won't work on
MS Windows because it uses /dev/null to avoid touching the
host filesystem.   I'm not sure whether this should have
a regression test and if so what the right way is to do it.

Note that psql-stream.patch includes some re-writing of
the docs for the psql \o option that goes slightly beyond
the minimum change required to explain \pset estream's effects.

Regards,

Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                 -- Robert A. Heinlein