diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sql/field.cc b/sql/field.cc index 73f442a868e..dafb3dc25da 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4778,11 +4778,18 @@ void Field_varstring::sort_string(char *to,uint length) void Field_varstring::sql_type(String &res) const { + THD *thd= table->in_use; CHARSET_INFO *cs=res.charset(); - ulong length= cs->cset->snprintf(cs,(char*) res.ptr(), - res.alloced_length(),"varchar(%u)", - field_length / charset()->mbmaxlen); + ulong length; + + length= cs->cset->snprintf(cs,(char*) res.ptr(), + res.alloced_length(), "%s(%d)", + (has_charset() ? "varchar" : "varbinary"), + (int) field_length / charset()->mbmaxlen); res.length(length); + if ((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) && + has_charset() && (charset()->state & MY_CS_BINSORT)) + res.append(" binary"); } |