diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 9c3d6d40139..a38d5eddd1b 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1025,3 +1025,11 @@ select 1 from (select 1 from test.t1) a; 1 use test; drop table t1; +create table t1(a blob, b text charset utf8, c text charset ucs2); +select data_type, character_octet_length, character_maximum_length +from information_schema.columns where table_name='t1'; +data_type character_octet_length character_maximum_length +blob 65535 65535 +text 65535 65535 +text 65535 32767 +drop table t1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 9fb57fc187b..614cc5e6f9b 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -727,3 +727,12 @@ use information_schema; select 1 from (select 1 from test.t1) a; use test; drop table t1; + +# +# Bug #14290: character_maximum_length for text fields +# + +create table t1(a blob, b text charset utf8, c text charset ucs2); +select data_type, character_octet_length, character_maximum_length + from information_schema.columns where table_name='t1'; +drop table t1; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 69b824f8cd9..72bb8cdb4cf 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2559,8 +2559,9 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, is_blob= (field->type() == FIELD_TYPE_BLOB); if (field->has_charset() || is_blob) { - longlong char_max_len= is_blob ? (longlong) field->max_length() : - (longlong) field->max_length()/field->charset()->mbmaxlen; + longlong char_max_len= is_blob ? + (longlong) field->max_length() / field->charset()->mbminlen : + (longlong) field->max_length() / field->charset()->mbmaxlen; table->field[8]->store(char_max_len, TRUE); table->field[8]->set_notnull(); table->field[9]->store((longlong) field->max_length(), TRUE);