Re: Error "invalid byte sequence for encoding UTF8" on insert into BYTEA column - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Error "invalid byte sequence for encoding UTF8" on insert into BYTEA column
Date
Msg-id 20100122001312.GB22947@svana.org
Whole thread Raw
In response to Error "invalid byte sequence for encoding UTF8" on insert into BYTEA column  (Alan Millington <admillington@yahoo.co.uk>)
Responses Re: Error "invalid byte sequence for encoding UTF8" on insert into BYTEA column  (Alan Millington <admillington@yahoo.co.uk>)
List pgsql-general
On Thu, Jan 21, 2010 at 11:54:32AM -0800, Alan Millington wrote:
> Today for the first time since upgrading to Postgres 8.4.1 I tried
> out part of the code which inserts some binary data into a table. The
> insert failed with the error "invalid byte sequence for encoding
> UTF8". That is odd, because the column into which the insert was made
> is of type bytea: the data is meant to be binary data, not
> UTF8-encoded Unicode.

Inserting in bytea needs an extra level of escaping when the parameters
are sent inline. See

http://www.postgresql.org/docs/8.4/interactive/datatype-binary.html

> When I was using Postgres 8.1.4 the same code worked. My code, the
> mxODBC code and the driver are all unaltered: only the Postgres
> version has changed.. Is there something I can tweak to get it to
> work on Postgres 8.4.1?

Very odd. The syntax for this hasn't changed in a long time. And I
would have thought you'd be sending your paramters out of line anyway.
Can you check that?

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

pgsql-general by date:

Previous
From: Andrej
Date:
Subject: Re: array element replace ?
Next
From: Greg Smith
Date:
Subject: Re: \dt+ sizes don't include TOAST data