summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-10-09 17:12:26 +0200
committerSergei Golubchik <serg@mariadb.org>2015-10-09 17:12:26 +0200
commitcfeedbfd3e292f61c7da8f0a7f86307cbeeddb64 (patch)
tree3629d1de148b14915a35a21f809e1a2ea6a08619 /sql/sql_insert.cc
parentbff1af983ad7b0bed6c3973e4d13297df5fe2791 (diff)
parent16c4b3c68b06653592a9500050ad977a38f4ebae (diff)
downloadmariadb-git-cfeedbfd3e292f61c7da8f0a7f86307cbeeddb64.tar.gz
Merge branch '5.5' into 10.0
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc56
1 files changed, 40 insertions, 16 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 1ec33a0a0ac..522f55cd102 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2014, SkySQL Ab.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2015, MariaDB
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
@@ -3852,7 +3852,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
/* Add selected items to field list */
List_iterator_fast<Item> it(*items);
Item *item;
- Field *tmp_field;
DBUG_ENTER("create_table_from_items");
tmp_table.alias= 0;
@@ -3867,24 +3866,49 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
while ((item=it++))
{
- Create_field *cr_field;
- Field *field, *def_field;
+ Field *tmp_table_field;
if (item->type() == Item::FUNC_ITEM)
{
if (item->result_type() != STRING_RESULT)
- field= item->tmp_table_field(&tmp_table);
+ tmp_table_field= item->tmp_table_field(&tmp_table);
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
- field= create_tmp_field(thd, &tmp_table, item, item->type(),
- (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0,
- 0);
- if (!field ||
- !(cr_field=new Create_field(field,(item->type() == Item::FIELD_ITEM ?
- ((Item_field *)item)->field :
- (Field*) 0))))
- DBUG_RETURN(0);
+ {
+ Field *from_field, * default_field;
+ tmp_table_field= create_tmp_field(thd, &tmp_table, item, item->type(),
+ (Item ***) NULL, &from_field, &default_field,
+ 0, 0, 0, 0, 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)
cr_field->flags &= ~NOT_NULL_FLAG;
alter_info->create_list.push_back(cr_field);
@@ -3974,7 +3998,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
{
if (!thd->is_error()) // CREATE ... IF NOT EXISTS
my_ok(thd); // succeed, but did nothing
- DBUG_RETURN(0);
+ DBUG_RETURN(NULL);
}
DEBUG_SYNC(thd,"create_table_select_before_lock");