Re: PQfformat question and retrieving bytea data in C

From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PQfformat question and retrieving bytea data in C
Date: 2012-08-29 13:33:05
Message-ID: CAPTjJmoOAHgGKUJzoLcQgTQNUgsbr+W737KSHqQzVRAfKEQj2Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Aug 29, 2012 at 10:30 PM, Jason Armstrong <ja(at)riverdrums(dot)com> wrote:
> I see the following:
> 30 5c 33 33 32 5c 30 30 30 5c 30 31 31 5c 30 30
>
> But when I look at the same data in the database:
>
> psql> select encode(substr(data, 0, 16), 'hex') from data_table where id='xxx';
> encode
> --------------------------------
> 30da00090132420520203137323030

Here's what you're seeing:

0\332\000\011\00

5c is a backslash, the rest are all digits. The backslashes introduce
octal escape codes - that's what bytea_output = 'escape' means. 0332
is 0xda, 011 is 0x09, etc. You're seeing the same values come up in
the cases where they don't need to be escaped, like the 0x30 at the
beginning.

ChrisA

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2012-08-29 13:35:39 Re: calling a C function from pgsql function
Previous Message Merlin Moncure 2012-08-29 13:20:48 Re: PQfformat question and retrieving bytea data in C