diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2008-12-09 13:53:23 +0400 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2008-12-09 13:53:23 +0400 |
commit | eb46763654e3f432d2e654681e9c079cbc3d4af0 (patch) | |
tree | 33da36ac9bdd13cdb4a24dc34ca6927be17a98b0 /sql/sql_show.cc | |
parent | b7139581325fe41ed584dfa653a2a66d211d4d67 (diff) | |
download | mariadb-git-eb46763654e3f432d2e654681e9c079cbc3d4af0.tar.gz |
Bug#35796 SHOW CREATE TABLE and default value for BIT field
show default value for BIT field in printable format
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 4e3d209f674..59082e0a295 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -798,7 +798,7 @@ static bool get_field_default_value(THD *thd, TABLE *table, { bool has_default; bool has_now_default; - + enum enum_field_types field_type= field->type(); /* We are using CURRENT_TIMESTAMP instead of NOW because it is more standard @@ -806,7 +806,7 @@ static bool get_field_default_value(THD *thd, TABLE *table, has_now_default= table->timestamp_field == field && field->unireg_check != Field::TIMESTAMP_UN_FIELD; - has_default= (field->type() != FIELD_TYPE_BLOB && + has_default= (field_type != FIELD_TYPE_BLOB && !(field->flags & NO_DEFAULT_VALUE_FLAG) && field->unireg_check != Field::NEXT_NUMBER && !((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) @@ -821,7 +821,19 @@ static bool get_field_default_value(THD *thd, TABLE *table, { // Not null by default char tmp[MAX_FIELD_WIDTH]; String type(tmp, sizeof(tmp), field->charset()); - field->val_str(&type); + if (field_type == MYSQL_TYPE_BIT) + { + longlong dec= field->val_int(); + char *ptr= longlong2str(dec, tmp + 2, 2); + uint32 length= (uint32) (ptr - tmp); + tmp[0]= 'b'; + tmp[1]= '\''; + tmp[length]= '\''; + type.length(length + 1); + quoted= 0; + } + else + field->val_str(&type); if (type.length()) { String def_val; |