Egy érdekes problémába futottam, leszűkítettem amennyire tudtam, a végeredményt írom, amire nem tudok magyarázatot.
select search_betu,lower(title) from lexikon WHERE LOWER(lexikon.title) REGEXP '^ő'; --megtalálja az űrsíklót.
pl.:
+-------------+-------------------------------------------------------------------------------------------------------------------+
| search_betu | lower(title) |
+-------------+-------------------------------------------------------------------------------------------------------------------+
...
| o | őszibarackfa |
| o | ősz |
| u | űrsikló (space shuttle) |
| o | őszapó |
...
+-------------+-------------------------------------------------------------------------------------------------------------------+
select search_betu,lower(title) from lexikon WHERE LOWER(lexikon.title) REGEXP '^ű'; --ez csak az ű söket találja mEG!!!
+-------------+---------------------------+
| search_betu | lower(title) |
+-------------+---------------------------+
| u | űrbél |
| u | űrlap |
| u | űrsikló (space shuttle) |
+-------------+---------------------------+
tehát: az ő -re megtalálja az ű-t, de fordítva nem!!!!!!!!!
Tisztában vagyok vele, hogy a mysql regexp byteokon működik:
Warning
The REGEXP and RLIKE operators work in byte-wise fashion, so they are not multi-byte safe and may produce unexpected results with multi-byte character sets. In addition, these operators compare characters by their byte values and accented characters may not compare as equal even if a given collation treats them as equal.
De itt nem ez a probléma, [ő] esetén lehetne mondjuk, mert 2 byteos.
A title oszlop, és maga a table is utf-8 hungarian_ci collation.
Konstansra jó minden kombináció:
mysql> select 'űrsikló (space shuttle)' regexp '^ő';
+------------------------------------------+
| 'űrsikló (space shuttle)' regexp '^ő' |
+------------------------------------------+
| 0 |
+------------------------------------------+
1 row in set (0.00 sec)
minden utf-8, a konzol, a mysql kliens kódolása, a szerver default kódolása...
Gentoo mysql:
[ebuild R ] dev-db/mysql-5.1.56 USE="cluster community ssl -big-tables -debug -embedded -extraengine -latin1 -max-idx-128 -minimal -pbxt -perl -profiling (-selinux) -static -test -xtradb" 0 kB
--------------------------------------------
szerk: utf8_general_ci esetén a hiba nem jelentkezik! találomra pl. utf8_lithuanian_ci nél is hibás :D