psql binary output

Started by Andrew Dunstanover 13 years ago1 messageshackers
Jump to latest
#1Andrew Dunstan
andrew@dunslane.net

I whipped this up some months ago and forgot that I hadn't sent in the
patch.

This implements two psql commands: \gb and \gbn

Both fetch and output results in binary mode - \gb uses separators,
while \gbn does not. Examples:

[andrew@emma inst.psql-binout.5705]$ echo "select bytea '\\x00010203', bytea '\\x040506' \\gbn" | bin/psql | od -c
0000000 \0 001 002 003 004 005 006
0000007
[andrew@emma inst.psql-binout.5705]$ echo "select bytea '\\x00010203', bytea '\\x040506' \\gb" | bin/psql | od -c
0000000 \0 001 002 003 | 004 005 006 \n
0000011

This is an attempt to deal with the question I originally posed here:
<http://people.planetpostgresql.org/andrew/index.php?/archives/196-Clever-trick-challenge.html&gt;
and is based on a suggestion Tom later made (although anything wrong
here is of course my fault, not his.

If people are interested I'll try to finish this up and document it.

cheers

andrew

Attachments:

psql-binout.patchtext/x-patch; name=psql-binout.patchDownload+122-16