Re: how to load text file that has embeded nul character

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Sun Dong <dongdongsun(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to load text file that has embeded nul character
Date: 2008-12-16 13:18:10
Message-ID: 20081216131810.GE4741@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sun Dong wrote:

> When I tried to load it, I always get this error:
> invalid byte sequence for encoding "UTF8": 0x00
>
> how could I load this into postgresql database?

I'm afraid you'll have to preprocess the file to convert the 0x00 into
\000. Obviously, if you're inserting this file into a text field or
similar, the data will be truncated at that point; if you want the data
after the NUL to be preserved, you'll need a bytea field (or change the
NUL to something else).

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-12-16 13:44:21 Re: what happens to indexes when TRUNCATEing
Previous Message Adam Witney 2008-12-16 12:38:49 Is this a security risk?