Bug #50574 5.5.x allows spatial indexes on non-spatial columns, causing crashes!
Submitted: 24 Jan 2010 19:06 Modified: 15 Mar 2010 15:53
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S1 (Critical)
Version:5.5.1-m2,5.5.99-m3 OS:Any
Assigned to: Magne Mæhre CPU Architecture:Any
Tags: crash, regression, spatial

[24 Jan 2010 19:06] Shane Bester
Description:
Might be related to bug #50542

stack trace from 5.5.1-m2:

mysqld.exe!sp_get_geometry_mbr()[sp_key.c:201]
mysqld.exe!sp_mbr_from_wkb()[sp_key.c:113]
mysqld.exe!sp_make_key()[sp_key.c:58]
mysqld.exe!_mi_make_key()[mi_key.c:66]
mysqld.exe!mi_write()[mi_write.c:126]
mysqld.exe!ha_myisam::write_row()[ha_myisam.cc:781]
mysqld.exe!handler::ha_write_row()[handler.cc:4739]
mysqld.exe!write_record()[sql_insert.cc:1627]
mysqld.exe!mysql_insert()[sql_insert.cc:853]
mysqld.exe!mysql_execute_command()[sql_parse.cc:3312]
mysqld.exe!mysql_parse()[sql_parse.cc:6211]
mysqld.exe!dispatch_command()[sql_parse.cc:1242]
mysqld.exe!do_command()[sql_parse.cc:877]
mysqld.exe!handle_one_connection()[sql_connect.cc:1154]
mysqld.exe!pthread_start()[my_winthread.c:61]
mysqld.exe!_callthreadstartex()[threadex.c:348]
mysqld.exe!_threadstartex()[threadex.c:326]
kernel32.dll!FlsSetValue()

How to repeat:
drop table if exists `t1`;
create table `t1`(
`col0` binary not null ,
`col2` timestamp,spatial index `idx0` (`col0`)
)engine=myisam;
insert into t1 values (),();
[25 Jan 2010 0:48] MySQL Verification Team
C:\DBS>c:\dbs\5.5\bin\mysql -uroot --port=3540 --prompt="mysql 5.5 >"
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.2-m2-Win X64 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.5 >use test
Database changed
mysql 5.5 >drop table if exists `t1`;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql 5.5 >create table `t1`(
    -> `col0` binary not null ,
    -> `col2` timestamp,spatial index `idx0` (`col0`)
    -> )engine=myisam;
Query OK, 0 rows affected (0.11 sec)

mysql 5.5 >insert into t1 values (),();
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql 5.5 >

100124 22:44:01 [Note] Plugin 'FEDERATED' is disabled.
100124 22:44:01 [Note] Event Scheduler: Loaded 0 events
100124 22:44:01 [Note] C:\DBS\5.5\bin\mysqld: ready for connections.
Version: '5.5.2-m2-Win X64'  socket: ''  port: 3540  Source distribution
100124 22:44:47 - mysqld got exception 0xc0000005 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8384512
read_buffer_size=131072
max_used_connections=1
max_threads=151
threads_connected=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338124 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0xd22570
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
000000014028B99F    mysqld.exe!thr_write_keys()
000000014028BE02    mysqld.exe!sp_make_key()
00000001402818A7    mysqld.exe!_mi_make_key()
0000000140269DB4    mysqld.exe!mi_write()
000000014025D8B2    mysqld.exe!?write_row@ha_myisam@@UEAAHPEAE@Z()
00000001400AD1FD    mysqld.exe!?ha_write_row@handler@@QEAAHPEAE@Z()
0000000140181487    mysqld.exe!?write_record@@YAHPEAVTHD@@PEAUTABLE@@PEAUst_copy_info@@@Z()
0000000140187242    mysqld.exe!?mysql_insert@@YA_NPEAVTHD@@PEAUTABLE_LIST@@AEAV?$List@VItem@@@@AEAV?$List@V?$List@VItem@@@@@@22W4enum_duplicates@@_N@Z()
0000000140074DDE    mysqld.exe!?mysql_execute_command@@YAHPEAVTHD@@@Z()
0000000140078159    mysqld.exe!?mysql_parse@@YAXPEAVTHD@@PEBDIPEAPEBD@Z()
0000000140078DFA    mysqld.exe!?dispatch_command@@YA_NW4enum_server_command@@PEAVTHD@@PEADI@Z()
0000000140079D4B    mysqld.exe!?do_command@@YA_NPEAVTHD@@@Z()
00000001400A60F7    mysqld.exe!handle_one_connection()
00000001402D04BE    mysqld.exe!win_pthread_mutex_trylock()
00000001403533D7    mysqld.exe!_callthreadstartex()[threadex.c:348]
00000001403534AF    mysqld.exe!_threadstartex()[threadex.c:326]
000000007734BE3D    kernel32.dll!BaseThreadInitThunk()
0000000077486A51    ntdll.dll!RtlUserThreadStart()
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0000000000D2CDE0=insert into t1 values (),()
thd->thread_id=1
thd->killed=NOT_KILLED
[25 Jan 2010 10:43] MySQL Verification Team
Thank you for the bug report.
[26 Jan 2010 19:52] Omer Barnir
triage: setting tag to SRMR02, SR55RC (dos if GA)
[3 Feb 2010 21:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/99167

2933 Magne Mahre	2010-02-03
      Bug#50574 5.5.x allows spatial indexes on non-spatial columns, 
                causing crashes!
      
      Adding a SPATIAL INDEX on non-geometrical columns caused a
      segmentation fault when the table was subsequently 
      inserted into.
      
      A test was added in mysql_prepare_create_table to explicitly
      check whether non-geometrical columns are used in a
      spatial index, and throw an error if so.
[11 Feb 2010 12:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/99930

2940 Magne Mahre	2010-02-11
      Bug#50574 5.5.x allows spatial indexes on non-spatial columns, 
                causing crashes!
            
      Adding a SPATIAL INDEX on a non-geometrical column caused a
      segmentation fault when the table was subsequently 
      inserted into.
      
      A test was added in mysql_prepare_create_table to explicitly
      check whether non-geometrical columns are used in a
      spatial index, and throw an error if so.
     @ mysql-test/t/gis.test
        Added test cases to verify that only geometrical
        columns can get a spatial index.
        
        In addition, verify that only a single geom.
        column can participate in a spatial index.
[11 Feb 2010 17:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/99990

2941 Magne Mahre	2010-02-11
      Bug#50574 5.5.x allows spatial indexes on non-spatial columns, 
                causing crashes!
      
      Adding a SPATIAL INDEX on a non-geometrical column caused a
      segmentation fault when the table was subsequently 
      inserted into.
            
      A test was added in mysql_prepare_create_table to explicitly
      check whether non-geometrical columns are used in a
      spatial index, and throw an error if so.
     @ mysql-test/t/gis.test
        Added test cases to verify that only geometrical
        columns can get a spatial index.
                
        In addition, verify that only a single geom.
        column can participate in a spatial index.
[12 Feb 2010 17:40] Bugs System
Pushed into 5.5.2-m2 (revid:joerg@mysql.com-20100212164100-jnurxdw5z88m472s) (version source revid:joerg@mysql.com-20100212164100-jnurxdw5z88m472s) (merge vers: 5.5.2-m2) (pib:16)
[13 Feb 2010 8:36] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100213083436-9pesg4h55w1mekxc) (version source revid:alik@sun.com-20100212100039-eh6atbvijcm71eyb) (merge vers: 6.0.14-alpha) (pib:16)
[13 Feb 2010 8:38] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100213083327-cee4ao3jpg33eggv) (version source revid:alik@sun.com-20100212095912-k3fklaqrxzzls9cd) (pib:16)
[13 Feb 2010 18:06] Paul DuBois
Noted in 5.5.2, 6.0.14 changelogs.

SPATIAL indexes were allowed on columns with non-spatial data types,
resulting in a server crash for subsequent table inserts.

Setting report to Need Merge pending push of Celosia to release tree.
[15 Mar 2010 15:53] Paul DuBois
This is in mysql-trunk now. Closing.