Re: postgres8.3beta encodding problem?

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jeff Davis <pgsql(at)j-davis(dot)com>, marcelo Cortez <jmdc_marcelo(at)yahoo(dot)com(dot)ar>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: postgres8.3beta encodding problem?
Date: 2007-12-18 16:01:28
Message-ID: 4767EED8.3040609@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout wrote:
> On Tue, Dec 18, 2007 at 10:35:39AM -0500, Tom Lane wrote:
>
>> Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
>>
>>> Ok, but that doesn't apply in this case, his database appears to be
>>> LATIN1 and this character is valid for that encoding...
>>>
>> You know what, I think the test in the code is backwards.
>>
>> is_mb = pg_encoding_max_length(encoding) > 1;
>>
>> if ((is_mb && (cvalue > 255)) || (!is_mb && (cvalue > 127)))
>>

Yes.

>
> It does seem to be a bit wierd. For single character encodings anything
> up to 255 is OK, well, sort of. It depends on what you want chr() to do
> (oh no, not this discussion again). If you subscribe to the idea that
> it should use unicode code points then the test is completely bogus,
> since whether or not the character is valid has nothing to with whether
> the encoding is multibyte or not.
>

We are certainly not going to revisit that discussion at this stage. It
was thrashed out months ago.
> If you want the output of th chr() to (logically) depend on the encoding
> then the test makes more sense, but ten it's inverted. Single-byte
> encodings are by definition defined to 255 characters. And multibyte
> encodings (other than UTF-8 I suppose) can only see the ASCII subset.
>

Right. There is a simple thinko on my part in the line of code Tom
pointed to, which needs to be fixed.

cheers

andrew

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ted Byers 2007-12-18 16:07:24 Re: logging arguments to prepared statements?
Previous Message Weber, Geoffrey M. 2007-12-18 16:00:29 Problem with index not being chosen inside PL/PgSQL function...