mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
store/show vcols as item->print()
otherwise we'd need to store sql_mode *per vcol* (consider CREATE INDEX...) and how SHOW CREATE TABLE would support that? Additionally, get rid of vcol::expr_str, just to make sure the string is always generated and never leaked in the original form.
This commit is contained in:
@ -3339,45 +3339,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
if (prepare_blob_field(thd, sql_field))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
if (sql_field->default_value)
|
||||
{
|
||||
Virtual_column_info *def= sql_field->default_value;
|
||||
|
||||
if (!sql_field->has_default_expression())
|
||||
def->expr_str= null_lex_str;
|
||||
|
||||
if (!def->expr_item->basic_const_item() && !def->flags)
|
||||
{
|
||||
Item *expr= def->expr_item;
|
||||
int err= !expr->fixed && // may be already fixed if ALTER TABLE
|
||||
expr->fix_fields(thd, &expr);
|
||||
if (!err)
|
||||
{
|
||||
if (expr->result_type() == REAL_RESULT)
|
||||
{ // don't convert floats to string and back, it can be lossy
|
||||
double res= expr->val_real();
|
||||
if (expr->null_value)
|
||||
expr= new (thd->mem_root) Item_null(thd);
|
||||
else
|
||||
expr= new (thd->mem_root) Item_float(thd, res, expr->decimals);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuffer<MAX_FIELD_WIDTH> buf;
|
||||
String *res= expr->val_str(&buf);
|
||||
if (expr->null_value)
|
||||
expr= new (thd->mem_root) Item_null(thd);
|
||||
else
|
||||
{
|
||||
char *str= (char*) thd->strmake(res->ptr(), res->length());
|
||||
expr= new (thd->mem_root) Item_string(thd, str, res->length(), res->charset());
|
||||
}
|
||||
}
|
||||
thd->change_item_tree(&def->expr_item, expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Convert the default value from client character
|
||||
set into the column character set if necessary.
|
||||
@ -4205,11 +4166,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
if (check_string_char_length(&check->name, 0, NAME_CHAR_LEN,
|
||||
system_charset_info, 1))
|
||||
{
|
||||
my_error(ER_TOO_LONG_IDENT, MYF(0), key->name.str);
|
||||
my_error(ER_TOO_LONG_IDENT, MYF(0), check->name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (check_expression(check, "CONSTRAINT CHECK",
|
||||
check->name.str ? check->name.str : "", 0))
|
||||
if (check_expression(check, check->name.str, VCOL_CHECK_TABLE))
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user