How to define empty polygon for spatial column in MySQL?
Asked Answered
H

1

7

I'm trying to create spatial index over table column (bbox polygon default NULL) but get error: All parts of a SPATIAL index must be NOT NULL.

Problem is that I supposed some rows would contain NULLs. The question is: is there a way to declare column with default empty polygon?

Heretofore answered 13/10, 2011 at 9:59 Comment(4)
ok, I'm stuck with this. I strongly need my column to hold some kind of empty values, and I want to use spatial indexing advantages. May be there any kind of another solution in my case? (mysql mandatory)Heretofore
Unfortunately EMPTY does not work in MySQL. dev.mysql.com/doc/refman/5.1/en/…Bertie
Ok, seems it is easier to move to Postgres' PostGIS rather than try GIS in MySQL.Heretofore
Decoupling the geo fields might be a sane solution (having a secondary table with id and polygon). Move the single field to an other table. Records without polygons can have no corresponding records in the other table, so a JOIN will return with null, but you will able to use spacial index the secondary table.Bertie
A
2

Just define the column NOT NULL and no default.

spatial columns have an implicit default of 'empty'.

Its unfortunate, because you get a warning on insert, saying there is no default value; but you cant have a explicit default value either.

Amphiprostyle answered 8/11, 2013 at 22:47 Comment(1)
Wow! Sorry, only just realised this question is over 2 years old... It was at the top of the unanswered list...Amphiprostyle

© 2022 - 2024 — McMap. All rights reserved.