Bug #26829 SPATIAL index on columns containing empty string causes error
Submitted: 3 Mar 2007 22:35 Modified: 6 Mar 2007 13:05
Reporter: Baron Schwartz (Basic Quality Contributor) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.24a-Debian_9-log OS:Linux (Ubuntu)
Assigned to: CPU Architecture:Any
Tags: empty string, qc, spatial index

[3 Mar 2007 22:35] Baron Schwartz
Description:
When I create a SPATIAL index on a spatial type, and insert the empty string into the column, it causes 'Unknown error.'  If I add spatial columns to an existing table that has rows, and then try to add the index, the same error happens.

How to repeat:
mysql> create table spatial_test(i int not null, p point not null, spatial key(p))engine=myisam;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into spatial_test(i,p) values(1,'');
ERROR 1105 (HY000): Unknown error

mysql> alter table spatial_test drop key p;
Query OK, 0 rows affected (0.06 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> insert into spatial_test(i,p) values(1,'');
Query OK, 1 row affected (0.00 sec)

mysql> alter table spatial_test add spatial key(p);
ERROR 1105 (HY000): Unknown error

Suggested fix:
Print a more informative error message.
[4 Mar 2007 6:28] MySQL Verification Team
this seems to have been fixed already.

mysql>  insert into spatial_test(i,p) values(1,'');
ERROR 1416 (22003): Cannot get geometry object from data you send to the GEOMETRY field

mysql> select version();
+--------------+
| version()    |
+--------------+
| 5.0.38-debug |
+--------------+
1 row in set (0.00 sec)

Please try a newer version of mysql and check.
[6 Mar 2007 13:05] Baron Schwartz
I don't have a machine I can upgrade to the latest version right now, but I trust that it has been fixed :-)  Thanks!  Sorry for reporting a bug against an old version!