Re: BUG #17676: Text comparison appears to be wrong

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: robj(at)hightouchinc(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17676: Text comparison appears to be wrong
Date: 2022-11-03 20:12:35
Message-ID: CAKFQuwYXiXeWq6=MWbM2Hm8i1v95c1mrkbNYeaCw0o2tQdeuHQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Nov 3, 2022 at 12:56 PM PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 17676
> Logged by: Rob Johnson
> Email address: robj(at)hightouchinc(dot)com
> PostgreSQL version: 14.5
> Operating system: Ubuntu
> Description:
>
> No tables are needed. Just ran this, comparing strings with lower-case 'x'
> and period '.' characters. The first two columns are false as expected,
> the
> last column is true, which appears to be wrong.
>
> => select '.' > 'x' as first, '.x' > 'x.' as second, '.xx' > 'x..' as
> third;
>
> List of databases
> Name | Owner | Encoding | Collate | Ctype | Access
> privileges | Size | Tablespace | Description
>
> ---------+----------+----------+-------------+-------------+-------------------+-------+------------+-------------
> nigeldb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
>
> | 48 MB | pg_default |
>
>
Not a bug.

This just seems to be how UTF-8 Collation works; punctuation produces
non-obvious sorting outcomes.

https://superuser.com/questions/227925/in-utf-8-collation-why-11-is-less-then-1

I confirmed that explicitly adding COLLATE "C" produces the expected
outcome for third.

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Vik Fearing 2022-11-03 23:19:16 Wrong result with constant quals
Previous Message PG Bug reporting form 2022-11-03 19:54:42 BUG #17676: Text comparison appears to be wrong