BUG #1996: DISTINCT fails with national character varying

Started by Ludmil Tinkovover 20 years ago3 messagesbugs
Jump to latest
#1Ludmil Tinkov
ludmil@fyrex.com

The following bug has been logged online:

Bug reference: 1996
Logged by: Ludmil Tinkov
Email address: ludmil@fyrex.com
PostgreSQL version: 7.3.2
Operating system: RedHat 9.0
Description: DISTINCT fails with national character varying
Details:

create table depression(ID int, name national character varying(50))

insert into depression values(1, 'Ана');
insert into depression values(2, 'Ива');
insert into depression values(3, 'Ина');
insert into depression values(4, 'Яна');

select distinct name from depression

--the last statement returns only a single row
--namely: Ана
--it should return 4 rows!

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ludmil Tinkov (#1)
Re: BUG #1996: DISTINCT fails with national character varying

"Ludmil Tinkov" <ludmil@fyrex.com> writes:

select distinct name from depression

--the last statement returns only a single row
--namely: Ана
--it should return 4 rows!

This has been seen to happen when you select a database encoding that
does not match the encoding expected by the postmaster's LC_CTYPE locale
setting. It's really a bug in the locale definitions, if you ask me,
but good luck getting the glibc guys to change those :-(. In the
meantime, make sure your locale and encoding agree.

regards, tom lane

#3Ludmil Tinkov
ludmil@fyrex.com
In reply to: Tom Lane (#2)
Re: BUG #1996: DISTINCT fails with national character varying

Thanks, Tom!

I'll tackle this issue this weekend.
I'll also upgrade to PostgreSQL 8 (most probably)

Thanks once again for your comprehensive reply!

Best regards,
Ludmil Tinkov

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Tuesday, October 25, 2005 5:34 AM
To: Ludmil Tinkov
Cc: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #1996: DISTINCT fails with national character varying

"Ludmil Tinkov" <ludmil@fyrex.com> writes:

select distinct name from depression

--the last statement returns only a single row
--namely: Ана
--it should return 4 rows!

This has been seen to happen when you select a database encoding that
does not match the encoding expected by the postmaster's LC_CTYPE locale
setting. It's really a bug in the locale definitions, if you ask me,
but good luck getting the glibc guys to change those :-(. In the
meantime, make sure your locale and encoding agree.

regards, tom lane