tough locale bug

From: Goran Thyni <goran(at)kirra(dot)net>
To: PostgreSQL Hackers <hackers(at)postgreSQL(dot)org>
Cc: svn(at)bildbasen(dot)se
Subject: tough locale bug
Date: 1999-01-28 21:47:12
Message-ID: 36B0DAE0.C2F9A42E@kirra.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I have found a bug and tried to trace the source but now I need some
pointers.

ENV: Pgsql 6.4.2 (and current) compiled with locale (using Swedish
locale)

BUG:
A small table: CREATE TABLE x(txt text);

goran=> SELECT * FROM x;
txt
------
abc
åäö
Grön
Gunnar
GUNNAR
Göran
göran
GÖRAN
(8 rows)

but:

goran=> select * from x WHERE txt LIKE 'G%';
txt
------
Grön
Gunnar
GUNNAR
(3 rows)

the same goes for: "select * from x WHERE txt ~ '^G'" which is the same
as above LIKE-stmt in the backend.
Otherwise regex works correct.

To sum up:
Case sensitive regex anchored with '^' and where the first char
following
the match is a non-ascii char gives misses.

I have tracked it down to the following, 3 functions are called to test
the expression:
1. textregexeq OK for 5 instances
2. text_ge('G','G') also OK
3. text_lt('G','G\0xFF') this is not correct!

Case 3 work not work with strcoll(), in varstr_cmp().
If I change it to strcoll() to strncmp() it works as expected,
but it probably breaks sorting etc big time.

Any suggestions how to proceed?

TIA,
--
---------------------------------------------
Göran Thyni, JMS Bildbasen, Kiruna
This is Penguin Country. On a quiet night you can hear Windows NT
reboot!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Edmund Mergl 1999-01-28 21:49:26 [Fwd: DBD::Pg::db do failed: pqReadData() Error]
Previous Message Goran Thyni 1999-01-28 21:44:33 tough locale bug