diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-10-12 10:03:04 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-10-12 10:03:04 +0200 |
commit | e19a6f3dca7509eb8e042796a9311dba937ad9d7 (patch) | |
tree | 8eb1587285f8d06f57f1915c7ac212ef3e4d4a60 /sql/sql_insert.cc | |
parent | 0b4c3ad8181b909a3af04847e229900b1e9c5232 (diff) | |
parent | dfb74dea300f83880c11600dc726a9cae559f356 (diff) | |
download | mariadb-git-e19a6f3dca7509eb8e042796a9311dba937ad9d7.tar.gz |
Merge branch 'bb-10.1-serg' into 10.1
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 6aa6deaaa08..488826acd70 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 @@ -3944,15 +3944,35 @@ static TABLE *create_table_from_items(THD *thd, while ((item=it++)) { - Create_field *cr_field; - Field *field= item->create_field_for_create_select(thd, &tmp_table); - if (!field || - !(cr_field= (new (thd->mem_root) - Create_field(thd, field, - (item->type() == Item::FIELD_ITEM ? - ((Item_field *) item)->field : - (Field *) 0))))) - DBUG_RETURN(0); + Field *tmp_field= item->create_field_for_create_select(thd, &tmp_table); + + if (!tmp_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 (thd->mem_root) + Create_field(thd, tmp_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, thd->mem_root); @@ -4042,7 +4062,7 @@ static TABLE *create_table_from_items(THD *thd, { 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"); |