Loading mysql-test/r/gis.result +8 −0 Original line number Diff line number Diff line Loading @@ -680,3 +680,11 @@ select astext(fn3()); astext(fn3()) POINT(1 1) drop function fn3; create table t1(pt POINT); alter table t1 add primary key pti(pt); drop table t1; create table t1(pt GEOMETRY); alter table t1 add primary key pti(pt); ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length alter table t1 add primary key pti(pt(20)); drop table t1; mysql-test/t/gis.test +11 −0 Original line number Diff line number Diff line Loading @@ -395,3 +395,14 @@ show create function fn3; select astext(fn3()); drop function fn3; # # Bug #12267 (primary key over GIS) # create table t1(pt POINT); alter table t1 add primary key pti(pt); drop table t1; create table t1(pt GEOMETRY); --error 1170 alter table t1 add primary key pti(pt); alter table t1 add primary key pti(pt(20)); drop table t1; sql/sql_table.cc +5 −1 Original line number Diff line number Diff line Loading @@ -1149,13 +1149,17 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, { column->length*= sql_field->charset->mbmaxlen; if (f_is_blob(sql_field->pack_flag)) if (f_is_blob(sql_field->pack_flag) || (f_is_geom(sql_field->pack_flag) && key->type != Key::SPATIAL)) { if (!(file->table_flags() & HA_CAN_INDEX_BLOBS)) { my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name); DBUG_RETURN(-1); } if (f_is_geom(sql_field->pack_flag) && sql_field->geom_type == Field::GEOM_POINT) column->length= 21; if (!column->length) { my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name); Loading sql/sql_yacc.yy +3 −1 Original line number Diff line number Diff line Loading @@ -2970,7 +2970,9 @@ type: spatial_type: GEOMETRY_SYM { $$= Field::GEOM_GEOMETRY; } | GEOMETRYCOLLECTION { $$= Field::GEOM_GEOMETRYCOLLECTION; } | POINT_SYM { $$= Field::GEOM_POINT; } | POINT_SYM { Lex->length= (char*)"21"; $$= Field::GEOM_POINT; } | MULTIPOINT { $$= Field::GEOM_MULTIPOINT; } | LINESTRING { $$= Field::GEOM_LINESTRING; } | MULTILINESTRING { $$= Field::GEOM_MULTILINESTRING; } Loading Loading
mysql-test/r/gis.result +8 −0 Original line number Diff line number Diff line Loading @@ -680,3 +680,11 @@ select astext(fn3()); astext(fn3()) POINT(1 1) drop function fn3; create table t1(pt POINT); alter table t1 add primary key pti(pt); drop table t1; create table t1(pt GEOMETRY); alter table t1 add primary key pti(pt); ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length alter table t1 add primary key pti(pt(20)); drop table t1;
mysql-test/t/gis.test +11 −0 Original line number Diff line number Diff line Loading @@ -395,3 +395,14 @@ show create function fn3; select astext(fn3()); drop function fn3; # # Bug #12267 (primary key over GIS) # create table t1(pt POINT); alter table t1 add primary key pti(pt); drop table t1; create table t1(pt GEOMETRY); --error 1170 alter table t1 add primary key pti(pt); alter table t1 add primary key pti(pt(20)); drop table t1;
sql/sql_table.cc +5 −1 Original line number Diff line number Diff line Loading @@ -1149,13 +1149,17 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, { column->length*= sql_field->charset->mbmaxlen; if (f_is_blob(sql_field->pack_flag)) if (f_is_blob(sql_field->pack_flag) || (f_is_geom(sql_field->pack_flag) && key->type != Key::SPATIAL)) { if (!(file->table_flags() & HA_CAN_INDEX_BLOBS)) { my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name); DBUG_RETURN(-1); } if (f_is_geom(sql_field->pack_flag) && sql_field->geom_type == Field::GEOM_POINT) column->length= 21; if (!column->length) { my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name); Loading
sql/sql_yacc.yy +3 −1 Original line number Diff line number Diff line Loading @@ -2970,7 +2970,9 @@ type: spatial_type: GEOMETRY_SYM { $$= Field::GEOM_GEOMETRY; } | GEOMETRYCOLLECTION { $$= Field::GEOM_GEOMETRYCOLLECTION; } | POINT_SYM { $$= Field::GEOM_POINT; } | POINT_SYM { Lex->length= (char*)"21"; $$= Field::GEOM_POINT; } | MULTIPOINT { $$= Field::GEOM_MULTIPOINT; } | LINESTRING { $$= Field::GEOM_LINESTRING; } | MULTILINESTRING { $$= Field::GEOM_MULTILINESTRING; } Loading