Fix for bug#14271 I_S: columns has no size for (var)binary columns

  set character_octet_length, character_maximum_length for
  binary and varbinary field types
parent f4b05284
......@@ -1067,3 +1067,10 @@ show indexes from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 f1 1 f1 A NULL NULL NULL YES BTREE
drop table t1;
create table t1(f1 binary(32), f2 varbinary(64));
select character_maximum_length, character_octet_length
from information_schema.columns where table_name='t1';
character_maximum_length character_octet_length
32 32
64 64
drop table t1;
......@@ -759,3 +759,11 @@ show columns from t1;
describe t1;
show indexes from t1;
drop table t1;
#
# Bug#14271 I_S: columns has no size for (var)binary columns
#
create table t1(f1 binary(32), f2 varbinary(64));
select character_maximum_length, character_octet_length
from information_schema.columns where table_name='t1';
drop table t1;
......@@ -2616,7 +2616,9 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
table->field[6]->store((const char*) pos,
strlen((const char*) pos), cs);
is_blob= (field->type() == FIELD_TYPE_BLOB);
if (field->has_charset() || is_blob)
if (field->has_charset() || is_blob ||
field->real_type() == MYSQL_TYPE_VARCHAR || // For varbinary type
field->real_type() == MYSQL_TYPE_STRING) // For binary type
{
longlong char_max_len= is_blob ?
(longlong) field->max_length() / field->charset()->mbminlen :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment