bytea insert difference between 8.3 and 9.x - Mailing list pgsql-general

From Gregg Jaskiewicz
Subject bytea insert difference between 8.3 and 9.x
Date
Msg-id CAJY59_h85m4B7enZ6bmHVeghHzwbq_R4tNdv90wM1UUXbWJfQA@mail.gmail.com
Whole thread Raw
Responses Re: bytea insert difference between 8.3 and 9.x
List pgsql-general
So consider this code C++, using libpqxx:

string = "INSERT INTO foo(x) VALUES( E'" + T.esc_raw(data) + "' )";

foo(x) is bytea , before you ask.

On 8.3, it works fine.
On 9.x:

ERROR:  invalid byte sequence for encoding "UTF8": 0x00 (if \000 is in
the string).

Now, I can take out the E'' and it will work fine on 9.X, but will
whine about it on 8.3. (HINT:  Use the escape string syntax for
escapes, e.g., E'\r\n'.)


I need one piece of code that will work on both, what should I do in
this case ?

Thanks.

--
GJ

pgsql-general by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: changing from postgreSQL 8.3 to 9.0
Next
From: Venkat Balaji
Date:
Subject: : PostgreSQL Online Backup