summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2010-02-24 16:52:27 +0300
committerAlexander Nozdrin <alik@sun.com>2010-02-24 16:52:27 +0300
commitb3018e86132ff94ef7bde5d593b0c529cb10eced (patch)
tree46d0af1ca06ba43198a4cde04fa6f0a3937b0118 /sql/item.cc
parent5fb9f61e4faf24cbc364108c0709fa935f2c3a09 (diff)
parent4709825c608fdcf2af29a472a61be6cfe7040d5e (diff)
downloadmariadb-git-b3018e86132ff94ef7bde5d593b0c529cb10eced.tar.gz
Manual merge from mysql-trunk-merge.
Conflicts: - client/mysql.cc - client/mysqldump.c - configure.in - mysql-test/r/csv.result - mysql-test/r/func_time.result - mysql-test/r/show_check.result - mysql-test/r/sp-error.result - mysql-test/r/sp.result - mysql-test/r/sp_trans.result - mysql-test/r/type_blob.result - mysql-test/r/type_timestamp.result - mysql-test/r/warnings.result - mysql-test/suite/rpl/r/rpl_sp.result - sql/mysql_priv.h - sql/mysqld.cc - sql/sp.cc - sql/sql_base.cc - sql/sql_table.cc - sql/sql_trigger.cc - sql/sql_view.cc - sql/table.h - sql/share/errmsg.txt - mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc33
1 files changed, 25 insertions, 8 deletions
diff --git a/sql/item.cc b/sql/item.cc
index e785f0addde..8a2c4e86dc8 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4467,17 +4467,33 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
It's not an Item_field in the select list so we must make a new
Item_ref to point to the Item in the select list and replace the
Item_field created by the parser with the new Item_ref.
+
+ NOTE: If we are fixing an alias reference inside ORDER/GROUP BY
+ item tree, then we use new Item_ref as an intermediate value
+ to resolve referenced item only.
+ In this case the new Item_ref item is unused.
*/
Item_ref *rf= new Item_ref(context, db_name,table_name,field_name);
if (!rf)
return 1;
- thd->change_item_tree(reference, rf);
+
+ bool save_group_fix_field= thd->lex->current_select->group_fix_field;
/*
- Because Item_ref never substitutes itself with other items
- in Item_ref::fix_fields(), we can safely use the original
- pointer to it even after fix_fields()
- */
- return rf->fix_fields(thd, reference) || rf->check_cols(1);
+ No need for recursive resolving of aliases.
+ */
+ thd->lex->current_select->group_fix_field= 0;
+
+ bool ret= rf->fix_fields(thd, (Item **) &rf) || rf->check_cols(1);
+ thd->lex->current_select->group_fix_field= save_group_fix_field;
+ if (ret)
+ return TRUE;
+
+ if (save_group_fix_field && alias_name_used)
+ thd->change_item_tree(reference, *rf->ref);
+ else
+ thd->change_item_tree(reference, rf);
+
+ return FALSE;
}
}
}
@@ -5312,7 +5328,7 @@ int Item::save_in_field(Field *field, bool no_conversions)
field->set_notnull();
error=field->store(nr, unsigned_flag);
}
- return error ? error : (field->table->in_use->is_error() ? 2 : 0);
+ return error ? error : (field->table->in_use->is_error() ? 1 : 0);
}
@@ -6704,7 +6720,8 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions)
{
if (!arg)
{
- if (field_arg->flags & NO_DEFAULT_VALUE_FLAG)
+ if (field_arg->flags & NO_DEFAULT_VALUE_FLAG &&
+ field_arg->real_type() != MYSQL_TYPE_ENUM)
{
if (field_arg->reset())
{