Commit 552b1c8a authored by Ajo Robert's avatar Ajo Robert

Merge branch 'mysql-5.1' into mysql-5.5

parents 1d317440 f3dce250
/* /*
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -3668,7 +3668,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, ...@@ -3668,7 +3668,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
/* Add selected items to field list */ /* Add selected items to field list */
List_iterator_fast<Item> it(*items); List_iterator_fast<Item> it(*items);
Item *item; Item *item;
Field *tmp_field;
DBUG_ENTER("create_table_from_items"); DBUG_ENTER("create_table_from_items");
tmp_table.alias= 0; tmp_table.alias= 0;
...@@ -3685,22 +3684,49 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, ...@@ -3685,22 +3684,49 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
while ((item=it++)) while ((item=it++))
{ {
Create_field *cr_field; Field *tmp_table_field;
Field *field, *def_field;
if (item->type() == Item::FUNC_ITEM) if (item->type() == Item::FUNC_ITEM)
{
if (item->result_type() != STRING_RESULT) if (item->result_type() != STRING_RESULT)
field= item->tmp_table_field(&tmp_table); tmp_table_field= item->tmp_table_field(&tmp_table);
else else
field= item->tmp_table_field_from_field_type(&tmp_table, 0); tmp_table_field= item->tmp_table_field_from_field_type(&tmp_table,
false);
}
else else
field= create_tmp_field(thd, &tmp_table, item, item->type(), {
(Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0, Field *from_field, * default_field;
0); tmp_table_field= create_tmp_field(thd, &tmp_table, item, item->type(),
if (!field || (Item ***) NULL, &from_field, &default_field,
!(cr_field=new Create_field(field,(item->type() == Item::FIELD_ITEM ? 0, 0, 0, 0, 0);
((Item_field *)item)->field : }
(Field*) 0))))
DBUG_RETURN(0); if (!tmp_table_field)
DBUG_RETURN(NULL);
Field *table_field;
switch (item->type())
{
/*
We have to take into account both the real table's fields and
pseudo-fields used in trigger's body. These fields are used
to copy defaults values later inside constructor of
the class Create_field.
*/
case Item::FIELD_ITEM:
case Item::TRIGGER_FIELD_ITEM:
table_field= ((Item_field *) item)->field;
break;
default:
table_field= NULL;
}
Create_field *cr_field= new Create_field(tmp_table_field, table_field);
if (!cr_field)
DBUG_RETURN(NULL);
if (item->maybe_null) if (item->maybe_null)
cr_field->flags &= ~NOT_NULL_FLAG; cr_field->flags &= ~NOT_NULL_FLAG;
alter_info->create_list.push_back(cr_field); alter_info->create_list.push_back(cr_field);
...@@ -3765,7 +3791,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, ...@@ -3765,7 +3791,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
} }
} }
if (!table) // open failed if (!table) // open failed
DBUG_RETURN(0); DBUG_RETURN(NULL);
} }
DEBUG_SYNC(thd,"create_table_select_before_lock"); DEBUG_SYNC(thd,"create_table_select_before_lock");
......
...@@ -10122,6 +10122,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, ...@@ -10122,6 +10122,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
} }
case Item::FIELD_ITEM: case Item::FIELD_ITEM:
case Item::DEFAULT_VALUE_ITEM: case Item::DEFAULT_VALUE_ITEM:
case Item::TRIGGER_FIELD_ITEM:
{ {
Item_field *field= (Item_field*) item; Item_field *field= (Item_field*) item;
bool orig_modify= modify_item; bool orig_modify= modify_item;
......
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