Re: [GENERAL] how to save a bytea value into a file? - Mailing list pgsql-admin

From Merlin Moncure
Subject Re: [GENERAL] how to save a bytea value into a file?
Date
Msg-id CAHyXU0y06Q-ujZG+jcvbOuycdv1x9MgeDxfmnWSmqfYK0Bu0uw@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] how to save a bytea value into a file?  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
List pgsql-admin
On Mon, Oct 10, 2011 at 9:26 AM, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
> I wrote:
> [fanlijing wants to write bytea to file]
>> A simple
>>    COPY (SELECT byteacol WROM mytab WHERE ...) TO 'filename' (FORMAT
> binary)
>> should do the trick.
>
> Corrections:
> a) "binary" must be surrounded by single quotes.
> b) that won't dump just the binary data - you would have
>   to remove the first 25 bytes and the last 2 bytes...
>
> So maybe using the functions I mentioned would be the
> best way after all.
>
> You could also write your own user defined function in C.

A user defined function,  or a binary wire format speaking client side
extractor in C/libpq.  The basic rule of thumb for me regarding C
inside the server is 'only when no other reasonable solution exists'.

merlin

pgsql-admin by date:

Previous
From: "Albe Laurenz"
Date:
Subject: Re: [GENERAL] how to save a bytea value into a file?
Next
From: Akash Kodibail
Date:
Subject: Postgres Server crashed