Bug #37 RTREE UNIQUE index allows non-unique values
Submitted: 25 Jan 2003 16:06 Modified: 15 Feb 2003 23:40
Reporter: Alexander Keremidarski Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S1 (Critical)
Version:4.1 OS:Any (any)
Assigned to: CPU Architecture:Any

[25 Jan 2003 16:06] Alexander Keremidarski
Description:
When used as UNIQUE or PRIMARY KEY RTREE allows duplicates without any error.

This causes mysqld crash indifferent places - one of them reported in original email

In example below I tried to insert several rows untill at row 86 mysqld crashed at:

myisam/rt_split.c:80
static double count_square(
...
   square *= a[1] - a[0];

mysqld also crashes with:

DELETE FROM rt WHERE a<1;
causes crash at:
myisam/mi_key.c:215

uint _mi_pack_key()
...
     while (length--)
      {
        *key++ = *--pos;

...

How to repeat:
mysql> CREATE TABLE `rt` (
    ->   `a` int(11) NOT NULL default '0',
    ->   `b` int(11) NOT NULL default '0',
    ->   UNIQUE KEY `a` USING RTREE (`a`,`b`)
    -> ) TYPE=MyISAM CHARSET=latin1;
Query OK, 0 rows affected (0.03 sec)

mysql> INSERT INTO rt VALUES (1,1),(1,1);
Query OK, 2 rows affected (0.04 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from rt;
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 1 | 1 |
+---+---+

mysql> CREATE TABLE `rt` (
    -> `a` int(11) NOT NULL default '0',
    -> `b` int(11) NOT NULL default '0',
    -> PRIMARY KEY `a` USING RTREE (`a`, `b`)
    -> ) TYPE=MyISAM CHARSET=latin1;
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT INTO rt VALUES (1,1),(1,1);
Query OK, 2 rows affected (0.03 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from rt;
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 1 | 1 |
+---+---+
[15 Feb 2003 23:40] Michael Widenius
We have disabled RTREE index in 4.1 as these where not yet 100 % ready and  
moved development off these to the 5.0 tree. 
(We may backport the code to 4.1 as soon as we are satisfied with it) 
  
RTREE indexes are now in 4.1 only used internally by GEOMETRY fields.