List:Bugs« Previous MessageNext Message »
From:Linus Upson Date:July 4 2004 1:47am
Subject:RE: unique key and utf8
View as plain text  
Many of the mysql test cases fail when I configure 4.1.3 with
'--with-charset=utf8'. The symptoms are similar to the index truncation
problem I reported with 4.1.1.

Here is how mysql was configured:

C compiler:    gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-34)
C++ compiler:  g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-34)
Environment:
System: Linux seek 2.4.21-15.0.2.ELsmp #1 SMP Wed Jun 16 22:52:07 EDT 2004
i686 i686 i386 GNU/Linux
Architecture: i686

./configure --prefix=/home/linus/mysql/utf8 --with-tcp-port=8506
--with-unix-socket-path=/home/linus/mysql/utf8/tmp/mysql.sock
--with-charset=utf8

The full test results from the following command are attached.

$ ./mysql-test-run --force > test-utf8.txt

I also tried to configure mysql using the same configure command but without
the '--with-charset=utf8' option. More of the tests ran, but it eventually
failed with:

...
ctype_mb                       [ pass ]
ctype_recoding                 [ pass ]
ctype_sjis                     [ skipped ]
ERROR: /home/linus/mysql/utf8/mysql-test/var/run/master.pid was not created
in 30 seconds;  Aborting

I've attached the complete test output as test-default-charset.txt.

Thanks,
Linus


-----Original Message-----
From: Sergei Golubchik [mailto:serg@stripped] 
Sent: Wednesday, June 30, 2004 2:09 PM
To: Linus Upson
Cc: bugs@stripped; bar@stripped
Subject: Re: unique key and utf8


Hi!

On Jun 30, Linus Upson wrote:
> The following was tested with MySQL 4.1.1 running on RedHat ES 3. This 
> message was sent in UTF-8.
> 
> The unique key index prefix length is misleading when you use the utf8 
> character set. If you specify a prefix of N characters the uniqueness 
> constraint appears to be enforced for the first 3*N bytes of column, 
> not the first N characters.

Oops.
I agree, it's confusing.
We'll fix it.
 
> I discovered this problem because mysql silently shortened the unique 
> index prefix on one of my utf8 varchar columns. When I execute the 
> following statement:
> 
> CREATE TABLE `t` (
>   `c` varchar(150) NOT NULL default '',
>   UNIQUE KEY `c` (`c`(150))
> ) TYPE=MyISAM DEFAULT CHARSET=utf8
> 
> there are no errors or warnings, but the result is:
> 
> mysql> show create table t \G
> *************************** 1. row ***************************
>        Table: t
> Create Table: CREATE TABLE `t` (
>   `c` varchar(150) NOT NULL default '',
>   UNIQUE KEY `c` (`c`(64))
> ) TYPE=MyISAM DEFAULT CHARSET=utf8
> 1 row in set (0.00 sec)
> 
> The 150 character prefix should still fit within the 500 byte index 
> limit of 4.1.1 since 3 * 150 = 450, but for some reason the prefix has 
> been reduced to 64.

I wasn't able to repeat in in MySQL 4.1.3 - index was created as expected.
MySQL *never* silently truncates a UNIQUE index (if it does, it's a bug).
 
Regards,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  MySQL AB, Senior Software Developer /_/
/_/\_, /___/\___\_\___/  Osnabrueck, Germany
       <___/  www.mysql.com