Re: PQfformat question and retrieving bytea data in C - Mailing list pgsql-general

From Chris Angelico
Subject Re: PQfformat question and retrieving bytea data in C
Date
Msg-id CAPTjJmoOAHgGKUJzoLcQgTQNUgsbr+W737KSHqQzVRAfKEQj2Q@mail.gmail.com
Whole thread Raw
In response to PQfformat question and retrieving bytea data in C  (Jason Armstrong <ja@riverdrums.com>)
Responses Re: PQfformat question and retrieving bytea data in C
List pgsql-general
On Wed, Aug 29, 2012 at 10:30 PM, Jason Armstrong <ja@riverdrums.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


pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: PQfformat question and retrieving bytea data in C
Next
From: Craig Ringer
Date:
Subject: Re: calling a C function from pgsql function