Re: BUG #6743: BETWEEN operator does not work for char(1)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: spatarel1(at)yahoo(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6743: BETWEEN operator does not work for char(1)
Date: 2012-07-19 14:33:07
Message-ID: 20880.1342708387@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

spatarel1(at)yahoo(dot)com writes:
> I use "UTF8" charset and "Romania, Romanian" locale.

> I came across this as I wanted to test if a symbol was a letter:

> SELECT 'a' BETWEEN 'a' AND 'z'; -- true
> SELECT 'z' BETWEEN 'a' AND 'z'; -- true
> SELECT 'A' BETWEEN 'a' AND 'z'; -- true
> SELECT 'Z' BETWEEN 'a' AND 'z'; -- false (!)
> SELECT 'a' BETWEEN 'A' AND 'Z'; -- false (!)
> SELECT 'z' BETWEEN 'A' AND 'Z'; -- true
> SELECT 'A' BETWEEN 'A' AND 'Z'; -- true
> SELECT 'Z' BETWEEN 'A' AND 'Z'; -- true

> It seems that the intent is for the comparison to be case-insensitive, but
> in some limit-cases it fails.

I dunno exactly what sorting rule is implemented by Windows' Romanian
locale, but these examples are consistent with the theory that the
sort order is like aAbBcC ... zZ. In any case, you need to complain
to Microsoft if you don't like the locale's sort order. We just do
what the platform's strcoll() function tells us to.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Kapila 2012-07-20 02:57:04 Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
Previous Message Craig Ringer 2012-07-19 12:37:50 Re: [GENERAL] main log encoding problem