pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16789: Wrong order by output
2+ messages / 2 participants
[nested] [flat]

* BUG #16789: Wrong order by output
@ 2020-12-22 20:06 PG Bug reporting form <noreply@postgresql.org>
  2020-12-22 21:50 ` Re: BUG #16789: Wrong order by output Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2020-12-22 20:06 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: pmanousis@gmail.com

The following bug has been logged on the website:

Bug reference:      16789
Logged by:          Petros Manousis
Email address:      pmanousis@gmail.com
PostgreSQL version: 13.1
Operating system:   Linux (OpenSuse TumbleWeed)
Description:        

I also tried my data in http://sqlfiddle.com/#!17/55afc5/3 with version 9.6
of postgres and the issue seems to be there too.

Here is my example:
create table players ( name varchar(64), url varchar(256), primary key
(name));
insert into players values('Theo Akwuba', 'a');
insert into players values('Theo Bouteille', 'b');
insert into players values('Theodor Dlugos', 'c');
insert into players values('Theodor Kirov', 'd');
insert into players values('Theodoros Tsiloulis', 'e');
insert into players values('Theodoros Zaras', 'f');
insert into players values('Theo John', 'g');
insert into players values('Theo Leon', 'h');
insert into players values('Theo Magrit', 'i');
insert into players values('Theo Maledon', 'j');
insert into players values('Theo Pinson', 'k');
insert into players values('Theo Rey', 'l');
SELECT name from players ORDER BY name ;

I would expect as result the following:
Theo Akwuba
Theo Bouteille
Theo John
Theo Leon
Theo Magrit
Theo Maledon
Theo Pinson
Theo Rey
Theodor Dlugos
Theodor Kirov
Theodoros Tsiloulis
Theodoros Zaras

BUT what I got is this:
 Theo Akwuba
 Theo Bouteille
 Theodor Dlugos
 Theodor Kirov
 Theodoros Tsiloulis
 Theodoros Zaras
 Theo John
 Theo Leon
 Theo Magrit
 Theo Maledon
 Theo Pinson
 Theo Rey

I don't know if there is anything specific to do for having a proper ordered
output, but the result seems wrong to me. I also tried the same query in
sqlite and had no issues, as well as with libreoffice sorting and all was as
expected.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #16789: Wrong order by output
  2020-12-22 20:06 BUG #16789: Wrong order by output PG Bug reporting form <noreply@postgresql.org>
@ 2020-12-22 21:50 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2020-12-22 21:50 UTC (permalink / raw)
  To: pmanousis@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> I don't know if there is anything specific to do for having a proper ordered
> output, but the result seems wrong to me.

You need to use a locale (collation) that matches your expectations.

FWIW, I get the same ordering you show with COLLATE "en_US" on a
Linux box, and it's likely that glibc would use similar ordering
rules for some other languages.  The behavior you say you want
looks like it'd match COLLATE "C", though that might act a little
funny with non-ASCII characters.

(I'm not here to defend glibc's sorting rules, but I think what
they're doing in this example is ignoring spaces in the first pass.)

You can find more about this topic in

https://www.postgresql.org/docs/current/charset.html

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-12-22 21:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 20:06 BUG #16789: Wrong order by output PG Bug reporting form <noreply@postgresql.org>
2020-12-22 21:50 ` Tom Lane <tgl@sss.pgh.pa.us>

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