Skip site navigation (1) Skip section navigation (2)

psql binary output

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: psql binary output
Date: 2013-01-13 18:18:58
Message-ID: 50F2FA92.9040000@dunslane.net (view raw or flat)
Thread:
Lists: pgsql-hackers
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(at)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(at)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> 
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



Attachment: psql-binout.patch
Description: text/x-patch (9.2 KB)

pgsql-hackers by date

Next:From: Tom LaneDate: 2013-01-13 18:41:36
Subject: Re: [PATCH] unified frontend support for pg_malloc et al and palloc/pfree mulation (was xlogreader-v4)
Previous:From: Andres FreundDate: 2013-01-13 18:07:33
Subject: Re: [PATCH] unified frontend support for pg_malloc et al and palloc/pfree mulation (was xlogreader-v4)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group