From 2545c7d414b45edf890052a63ccec1594fa89bfc Mon Sep 17 00:00:00 2001 From: "gluh@eagle.intranet.mysql.r18.ru" <> Date: Wed, 29 Mar 2006 19:52:26 +0500 Subject: [PATCH 1/2] Fix for bug#15316 SET value having comma not correctly handled disallow the use of comma in SET members --- mysql-test/r/create.result | 2 ++ mysql-test/t/create.test | 6 ++++++ sql/sql_table.cc | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 6fe148adce5..aa25c55f394 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -699,3 +699,5 @@ t2 CREATE TABLE `t2` ( `a2` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1, t2; +create table t1(a set("a,b","c,d") not null); +ERROR HY000: Illegal set 'a,b' value found during parsing diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 7799200eaa0..57b16a13c01 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -603,4 +603,10 @@ show create table t2; drop table t1, t2; +# +# Bug #15316 SET value having comma not correctly handled +# +--error 1105 +create table t1(a set("a,b","c,d") not null); + # End of 4.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 616db8b0424..21f597caf94 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -540,6 +540,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->interval_list); List_iterator it(sql_field->interval_list); String conv, *tmp; + char comma_buf[2]; + int comma_length= cs->cset->wc_mb(cs, ',', (uchar*) comma_buf, + (uchar*) comma_buf + + sizeof(comma_buf)); + DBUG_ASSERT(comma_length > 0); for (uint i= 0; (tmp= it++); i++) { if (String::needs_conversion(tmp->length(), tmp->charset(), @@ -559,6 +564,18 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, interval->type_lengths[i]); interval->type_lengths[i]= lengthsp; ((uchar *)interval->type_names[i])[lengthsp]= '\0'; + if (sql_field->sql_type == FIELD_TYPE_SET) + { + if (cs->coll->instr(cs, interval->type_names[i], + interval->type_lengths[i], + comma_buf, comma_length, NULL, 0)) + { + my_printf_error(ER_UNKNOWN_ERROR, + "Illegal %s '%-.64s' value found during parsing", + MYF(0), "set", tmp->ptr()); + DBUG_RETURN(-1); + } + } } sql_field->interval_list.empty(); // Don't need interval_list anymore } From 70a8f32d81c92f79f445a4084881bbec059ddb4e Mon Sep 17 00:00:00 2001 From: "gluh@eagle.intranet.mysql.r18.ru" <> Date: Thu, 30 Mar 2006 09:13:25 +0500 Subject: [PATCH 2/2] post-merge fix --- mysql-test/r/create.result | 2 +- mysql-test/t/create.test | 2 +- sql/sql_table.cc | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index c11160c6727..27a6c8a9d03 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -747,7 +747,7 @@ t2 CREATE TABLE `t2` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1, t2; create table t1(a set("a,b","c,d") not null); -ERROR HY000: Illegal set 'a,b' value found during parsing +ERROR 22007: Illegal set 'a,b' value found during parsing create table t1 (i int) engine=myisam max_rows=100000000000; show create table t1; Table Create Table diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index f647e7461a7..e22c2b5c426 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -649,7 +649,7 @@ drop table t1, t2; # # Bug #15316 SET value having comma not correctly handled # ---error 1105 +--error 1367 create table t1(a set("a,b","c,d") not null); # End of 4.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8f13e612050..0fd0c8e25e1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -770,9 +770,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, interval->type_lengths[i], comma_buf, comma_length, NULL, 0)) { - my_printf_error(ER_UNKNOWN_ERROR, - "Illegal %s '%-.64s' value found during parsing", - MYF(0), "set", tmp->ptr()); + my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "set", tmp->ptr()); DBUG_RETURN(-1); } }