1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

MDEV-8441 Bad SHOW CREATE TABLE output for a table with a virtual column

This commit is contained in:
Alexander Barkov
2015-08-10 11:46:41 +04:00
parent 840aefc6a3
commit 86a3613d4e
6 changed files with 85 additions and 32 deletions

View File

@@ -1810,36 +1810,37 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
else
packet->append(STRING_WITH_LEN(" VIRTUAL"));
}
if (flags & NOT_NULL_FLAG)
packet->append(STRING_WITH_LEN(" NOT NULL"));
else if (field->type() == MYSQL_TYPE_TIMESTAMP)
else
{
/*
TIMESTAMP field require explicit NULL flag, because unlike
all other fields they are treated as NOT NULL by default.
*/
packet->append(STRING_WITH_LEN(" NULL"));
if (flags & NOT_NULL_FLAG)
packet->append(STRING_WITH_LEN(" NOT NULL"));
else if (field->type() == MYSQL_TYPE_TIMESTAMP)
{
/*
TIMESTAMP field require explicit NULL flag, because unlike
all other fields they are treated as NOT NULL by default.
*/
packet->append(STRING_WITH_LEN(" NULL"));
}
if (get_field_default_value(thd, field, &def_value, 1))
{
packet->append(STRING_WITH_LEN(" DEFAULT "));
packet->append(def_value.ptr(), def_value.length(), system_charset_info);
}
if (!limited_mysql_mode &&
print_on_update_clause(field, &def_value, false))
{
packet->append(STRING_WITH_LEN(" "));
packet->append(def_value);
}
if (field->unireg_check == Field::NEXT_NUMBER &&
!(sql_mode & MODE_NO_FIELD_OPTIONS))
packet->append(STRING_WITH_LEN(" AUTO_INCREMENT"));
}
if (!field->vcol_info &&
get_field_default_value(thd, field, &def_value, 1))
{
packet->append(STRING_WITH_LEN(" DEFAULT "));
packet->append(def_value.ptr(), def_value.length(), system_charset_info);
}
if (!limited_mysql_mode && print_on_update_clause(field, &def_value, false))
{
packet->append(STRING_WITH_LEN(" "));
packet->append(def_value);
}
if (field->unireg_check == Field::NEXT_NUMBER &&
!(sql_mode & MODE_NO_FIELD_OPTIONS))
packet->append(STRING_WITH_LEN(" AUTO_INCREMENT"));
if (field->comment.length)
{
packet->append(STRING_WITH_LEN(" COMMENT "));