Re: Sorting Discrepancy in PostgreSQL 14.13

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: [3반]김민지_4904 <hzuiw33(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Sorting Discrepancy in PostgreSQL 14.13
Date: 2024-11-14 14:48:36
Message-ID: 69c7ee62-f9de-4365-b325-7e493203a7ae@vondra.me
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On 11/14/24 13:49, [3반]김민지_4904 wrote:
>
> ...
>
> The minimized PoC is:
>
> ```sql
> CREATE TABLE t0 (c0 TEXT);
> INSERT INTO t0 (c0) VALUES ('-10'), ('20'), ('-5'), ('15'), ('-25');
> SELECT c0 FROM t0 ORDER BY c0;
> ```
>
> In PostgreSQL 14.13, the order is incorrect:
> ```
> -10
> 15
> 20
> -25
> -5
> ```
>
> While the correct order should be:
>
> ```
> -10
> -25
> -5
> 10
> 20
> ```
>
> as '-' is smaller than '1', or '2' in ascii.
>
> I'm doubtful this is a collation issue, as most collations basically
> respect ASCII order.
>

This is 99.999% due to the collation, so which collations are being used
on these systems? Also, I don't get this "incorrect" behavior on 14.13,
it behaves the same as 17 for me, producing the expected result.

regards

--
Tomas Vondra

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Aleksander Alekseev 2024-11-14 14:50:23 Re: BUG #18708: regex problem: (?:[^\d\D]){0} asserts with "lp->nouts == 0 && rp->nins == 0"
Previous Message Alexander Kukushkin 2024-11-14 14:38:20 Re: pg_rewind WAL segments deletion pitfall