From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: COPY fails on 8.1 with invalid byte sequences in text |
Date: | 2006-10-27 22:38:05 |
Message-ID: | 1161988685.31124.148.camel@dogma.v10.wvs |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Fri, 2006-10-27 at 14:42 -0700, Jeff Davis wrote:
> It seems to be essentially a data corruption issue if applications
> insert binary data in text fields using escape sequences. Shouldn't
> PostgreSQL reject an invalid UTF8 sequence in any text type?
>
Another note: PostgreSQL rejects invalid UTF8 sequences in other
contexts. For instance, if you use PQexecParams() and insert using type
text and any format (text or binary), it will reject invalid sequences.
It will of course allow anything to be sent when the type is bytea.
Also, I thought I'd publish the workaround that I'm using.
I created a function that seems to work for validating text data as
being valid UTF8.
CREATE OR REPLACE FUNCTION valid_utf8(TEXT) returns BOOLEAN
LANGUAGE plperlu AS
$valid_utf8$
use utf8;
return utf8::decode($_[0]) ? 1 : 0;
$valid_utf8$;
I just add a check constraint on all of my text attributes in all of my
tables. Not fun, but it works.
Regards,
Jeff Davis
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas H. | 2006-10-27 22:50:57 | Re: COPY fails on 8.1 with invalid byte sequences in text |
Previous Message | Jeff Davis | 2006-10-27 21:42:41 | COPY fails on 8.1 with invalid byte sequences in text types |