From 836bc2638e1939c0f65748f219e5613cc0f0af06 Mon Sep 17 00:00:00 2001 From: "hf@deer.(none)" <> Date: Mon, 26 Sep 2005 14:55:52 +0500 Subject: [PATCH] Fix for bug #12267 (primary key over GEOMETRY field) --- mysql-test/r/gis.result | 5 +++++ mysql-test/t/gis.test | 8 ++++++++ sql/sql_table.cc | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 78014137b50..2748199efad 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -680,3 +680,8 @@ select astext(fn3()); astext(fn3()) POINT(1 1) drop function fn3; +create table t1(pt POINT); +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; diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index aba2f33833a..1f30407c2b7 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -395,3 +395,11 @@ show create function fn3; select astext(fn3()); drop function fn3; +# +# Bug #12267 (primary key over GIS) +# +create table t1(pt POINT); +--error 1170 +alter table t1 add primary key pti(pt); +alter table t1 add primary key pti(pt(20)); +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 635b512fe23..d9ed7165850 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1148,7 +1148,8 @@ 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)) {