diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-10-31 18:07:02 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-10-31 18:07:02 -0400 |
commit | 4d1511296288782df0e3d9373396724e250b24c1 (patch) | |
tree | 9fa47d141b71933859d6c2da585e5bb5e52db212 /sql/sql_insert.cc | |
parent | 17b0b45b1de41a1b188c5de6c3e9d8e6ecc48a72 (diff) | |
parent | d775ecdd010daad4dc6147fba58acd006bf2c60c (diff) | |
download | mariadb-git-4d1511296288782df0e3d9373396724e250b24c1.tar.gz |
Merge tag 'mariadb-10.0.22' into 10.0-galera
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 6af2c0646ba..4e033f21b25 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 @@ -58,7 +58,6 @@ #include <my_global.h> /* NO_EMBEDDED_ACCESS_CHECKS */ #include "sql_priv.h" -#include "unireg.h" // REQUIRED: for other includes #include "sql_insert.h" #include "sql_update.h" // compare_record #include "sql_base.h" // close_thread_tables @@ -3899,7 +3898,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; @@ -3914,24 +3912,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); @@ -4021,7 +4044,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"); |