Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff'

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Chris Worley <chris(dot)worley(at)timco(dot)aero>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff'
Date: 2009-04-21 17:39:44
Message-ID: 49EE04E0.6070702@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris Worley wrote:
> Hello,
>
> I get the following error when running a sql script containing a COPY command:
>
> ERROR: invalid byte sequence for encoding "UTF8": 0xff...
>
> The data I have contains binary data from a tcp dump....
>
> Does anybody know how the dump pulls a column with binary data? It is
> a varchar column
No, if it it binary data, you need a column of type bytea and you need
to escape the appropriate characters in your input. For example, if I
create a table with a single bytea column called "foo" and insert the a
record with value "^F^O^O" then dump it, the dump will have the following:

COPY byteatest (foo) FROM stdin;
\\006\\017\\017
\.

See http://www.postgresql.org/docs/8.3/static/datatype-binary.html for
the characters that need to be escaped.

Cheers,
Steve

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Worley 2009-04-21 18:15:45 Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff'
Previous Message Robert Morton 2009-04-21 17:32:36 Re: round behavior differs between 8.1.5 and 8.3.7