List:Internals« Previous MessageNext Message »
From:Alexander Barkov Date:March 12 2007 9:55am
Subject:Czech "CH" and unique prefix keys
View as plain text  
Hello all,

We need help from Czech speaking part of MySQL community.

Imagine a table with a prefix key:

mysql> create table t1 (a varchar(10), unique key (a(1))) character set 
utf8 collate utf8_czech_ci;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values ('c');
Query OK, 1 row affected (0.00 sec)

mysql> insert into t1 values ('ch');
ERROR 1062 (23000): Duplicate entry 'c' for key 1

How do you think, is this error correct?

'ch' is actually a *single* letter, it is not *two* letters 'c' + 'h',
and it is not equal to 'c'.

Should't 'ch' be considered as a single letter for the the
prefix key a(1)?

Now it is cut to 'c' before inserting into the index,
and this is why it raises the duplicate entry error.
Have anyone noticed such behaviour?
If yes, did you consider it as an advantage, or rather as a problem?



Consider also similar situation, but now with a column size limit:

mysql> create table t1 (a char(1)) character set utf8 collate utf8_czech_ci;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values ('ch');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'a' at row 1 |
+---------+------+----------------------------------------+
1 row in set (0.00 sec)

mysql> select * from t1;
+------+
| a    |
+------+
| c    |
+------+
1 row in set (0.00 sec)


Is it correct? Should't a Czech char(1) column be able to store 'ch'?


Many thanks!

Thread
Czech "CH" and unique prefix keysAlexander Barkov12 Mar