Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: bytea and c...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 8 Topic 15460 of 16557
Post > Topic >>

Re: bytea and character encoding when inserting escaped

by lee@[EMAIL PROTECTED] (Lee Feigenbaum) May 5, 2008 at 02:03 PM

Asche wrote:
> Hi Lee,
> 
>> Thanks for the suggestion. I should have mentioned in my original 
>> message that as per your suggestion and the suggestion in the 
>> do***entation, I have tried escaping the backslashes. When I do this, 
>> I get the error:
>>
>>  ERROR: invalid input syntax for type bytea
>>
>> I tried also doing
>>
>>  INSERT INTO myTable VALUES (..., 
>> E'\\x15\\x1C\\x2F\\x00\\x02...'::bytea, ...) ;
>>
>> but get the same errors.
> 
> I think i see another problem with your query. You should convert to 
> three-digit octal (something like \\001\\002...) not \\x01 (hex?).

Hi Jan,

Thanks, I think I finally see what's happening here (and understand the 
docs) - the bytea type has its own string-serialization (escape format) 
_separate_ from postgresql's normal string literal escaping. So while 
E'\xC0' is postgresql serialization of a string containing whatever 
character maps from 0xC0 in the current encoding, that byte cannot 
directly go into a bytea. Instead, I need to have a doubly-escaped octal 
(specifically) string so that the first escape generates a string like 
\000\001\002 which the bytea processor (somewhere) then re-parses as a 
sequence of bytes.

Would be nice if the bytea parser understood hex representation too, but 
beggars can't be choosers :)

thanks for the help,
Lee

> 
> Jan
> 
> 

-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 8 Posts in Topic:
bytea and character encoding when inserting escaped literals
lee@[EMAIL PROTECTED] (L  2008-05-05 11:07:12 
Re: bytea and character encoding when inserting escaped literals
asche.public@[EMAIL PROTE  2008-05-05 17:21:16 
Re: bytea and character encoding when inserting escaped
lee@[EMAIL PROTECTED] (L  2008-05-05 11:30:29 
Re: bytea and character encoding when inserting escaped
asche.public@[EMAIL PROTE  2008-05-05 17:37:22 
Re: bytea and character encoding when inserting escaped
lee@[EMAIL PROTECTED] (L  2008-05-05 14:03:09 
Re: bytea and character encoding when inserting escaped literals
tgl@[EMAIL PROTECTED] (T  2008-05-05 15:34:20 
Re: bytea and character encoding when inserting escaped literals
aanderson@[EMAIL PROTECTE  2008-05-05 11:42:27 
Re: bytea and character encoding when inserting escaped
rod@[EMAIL PROTECTED] (&  2008-05-07 13:30:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 13:06:48 CDT 2008.