bytea insert difference between 8.3 and 9.x

From: Gregg Jaskiewicz <gryzman(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: bytea insert difference between 8.3 and 9.x
Date: 2011-09-26 10:51:20
Message-ID: CAJY59_h85m4B7enZ6bmHVeghHzwbq_R4tNdv90wM1UUXbWJfQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Venkat Balaji 2011-09-26 11:41:47 : PostgreSQL Online Backup
Previous Message Andreas Kretschmer 2011-09-26 10:16:07 Re: changing from postgreSQL 8.3 to 9.0