pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Anders Hermansen <anders@yoyo.no>
Cc: Guillaume Cottenceau <gc@mnc.ch>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: ERROR: could not convert UTF-8 character 0x00ef to ISO8859-1 possiblesolution
Date: Thu, 28 Apr 2005 09:58:22 -0400
Message-ID: <10942.1114696702@sss.pgh.pa.us> (raw)
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>

Anders Hermansen <anders@yoyo.no> 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



view thread (12+ messages)

Message-ID: <10942.1114696702@sss.pgh.pa.us>
Permalink:  ../10942.1114696702@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10942.1114696702@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: tgl@sss.pgh.pa.us, anders@yoyo.no, gc@mnc.ch
  Subject: Re: ERROR: could not convert UTF-8 character 0x00ef to ISO8859-1 possiblesolution
  In-Reply-To: <10942.1114696702@sss.pgh.pa.us>
  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> <10942.1114696702@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox