mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Bug #26794: 5.1 part
It was syntactically correct to define spatial keys over parts of columns (e.g. ALTER TABLE t1 ADD x GEOMETRY NOT NULL, ADD SPATIAL KEY (x(32))). This may lead to undefined results and/or interpretation. Fixed by not allowing partial column specification in a SPATIAL index definition. mysql-test/r/alter_table.result: Bug #26794: 5.1 part test case mysql-test/r/gis-rtree.result: Bug #26794: 5.1 part updated the tests to the new syntax mysql-test/t/alter_table.test: Bug #26794: 5.1 part test case mysql-test/t/gis-rtree.test: Bug #26794: 5.1 part updated the tests to the new syntax sql/sql_table.cc: Bug #26794: 5.1 part Disable defining SPATIAL KEYS with sub-key parts
This commit is contained in:
@@ -2791,6 +2791,12 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
{
|
||||
column->length*= sql_field->charset->mbmaxlen;
|
||||
|
||||
if (key->type == Key::SPATIAL && column->length)
|
||||
{
|
||||
my_error(ER_WRONG_SUB_KEY, MYF(0));
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
if (f_is_blob(sql_field->pack_flag) ||
|
||||
(f_is_geom(sql_field->pack_flag) && key->type != Key::SPATIAL))
|
||||
{
|
||||
@@ -5861,6 +5867,8 @@ view_err:
|
||||
if (!Field::type_can_have_key_part(cfield->field->type()) ||
|
||||
(!Field::type_can_have_key_part(cfield->sql_type) &&
|
||||
!f_is_geom (cfield->pack_flag)) ||
|
||||
/* spatial keys can't have sub-key length */
|
||||
(key_info->flags & HA_SPATIAL) ||
|
||||
(cfield->field->field_length == key_part_length &&
|
||||
!f_is_blob(key_part->key_type)) ||
|
||||
(cfield->length && (cfield->length < key_part_length /
|
||||
|
||||
Reference in New Issue
Block a user