X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C523653DAC for ; Thu, 28 Apr 2005 10:58:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18883-04 for ; Thu, 28 Apr 2005 13:58:23 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8F09053C95 for ; Thu, 28 Apr 2005 10:58:20 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j3SDwM5n010943; Thu, 28 Apr 2005 09:58:22 -0400 (EDT) To: Anders Hermansen Cc: Guillaume Cottenceau , pgsql-jdbc@postgresql.org Subject: Re: ERROR: could not convert UTF-8 character 0x00ef to ISO8859-1 possiblesolution In-reply-to: <20050428071833.GB13436@online.no> References: <426E685F.1020600@ingenian.com> <87d5sgecyi.fsf@meuh.mnc.ch> <20050427104944.GB25361@online.no> <87y8b4cv7j.fsf@meuh.mnc.ch> <20050427115434.GB30285@online.no> <873btccqgw.fsf@meuh.mnc.ch> <22055.1114612618@sss.pgh.pa.us> <20050428071833.GB13436@online.no> Comments: In-reply-to Anders Hermansen message dated "Thu, 28 Apr 2005 09:18:33 +0200" Date: Thu, 28 Apr 2005 09:58:22 -0400 Message-ID: <10942.1114696702@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/197 X-Sequence-Number: 12804 Anders Hermansen writes: > * Tom Lane (tgl@sss.pgh.pa.us) wrote: >> Looking at the source code, it's clear that it's reporting just the >> first byte of the sequence; the 00 is redundant and probably shouldn't >> be in the message. > Yes. Maybe the error messages can be changed so that what actually went > wrong is more clear? And possibly printing the whole 3-byte sequence? Any volunteers for that? The specific message in question is in src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c else if ((c & 0xe0) == 0xe0) elog(ERROR, "could not convert UTF8 character 0x%04x to ISO8859-1", c); Aside from being unhelpful as to the exact input data, this is wrong in another way: it ought to be an ereport() not elog(), because it's certainly not a can't-happen kind of error. A little bit of grepping turns up a number of similarly deficient elog and ereport calls in the src/backend/utils/mb/ tree. There is more useful code for constructing a character description in pg_verifymbstr() in src/backend/utils/mb/wchar.c. Probably what ought to happen is to split out a small subroutine along the lines of char *describe_mb_char(const unsigned char *mbstr, int len) (returning a palloc'd string "0x....") and then make all the places that complain about bad multibyte input use it. Don't have time to deal with it myself, but it seems like a pretty easy project for anyone wanting to dip their toes in the backend. regards, tom lane