Re: Reading bytea field

From: Volkan YAZICI <volkan(dot)yazici(at)gmail(dot)com>
To: Jochen Kokemüller <jochen(at)kokemueller(dot)de>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Reading bytea field
Date: 2005-10-21 23:30:02
Message-ID: 7104a7370510211630s294123f6te3465b593c5e32a9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces pgsql-sql

Hi,

On 10/21/05, Jochen Kokemüller <jochen(at)kokemueller(dot)de> wrote:
> I read that it is better to use PQexecParams instead of PQescape. In the
> bytea field is then the picture with every Byte escaped. So the first
> few bytes look like this:
>
> \377\330\377\340\000\020JFIF ...
>
> I wouldn't bother if i knew how to unescape this sequence. I supposed
> that this is more or less an internal representation, but when i try to
> retrieve the data. i get it like this.

If you'd use PQexecParams() for SELECT query with resultType = 1, you
shouldn't have any problem. Take a look at the examples in the
attachment.

Attachment Content-Type Size
recv.c text/x-csrc 958 bytes
send.c text/x-csrc 1.3 KB

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Louis Castoria 2005-10-25 17:04:33 libpq status question
Previous Message Stefan T. Peters 2005-10-21 20:28:11 Re: libpq won't connect when client is built with MinGW

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-10-22 03:23:48 Re: Blank-padding (was: Oracle buys Innobase)
Previous Message Dean Gibson (DB Administrator) 2005-10-21 23:28:48 Blank-padding (was: Oracle buys Innobase)