summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@sun.com>2010-02-09 12:59:38 +0500
committerAlexey Kopytov <Alexey.Kopytov@sun.com>2010-02-09 12:59:38 +0500
commit0888e40fa316b040cb43f6fad112a0cdcd443155 (patch)
tree18b0423763f9cac0e0b38ba5a2175afe5f429844 /sql/item.cc
parent7e0d0dd04037a626c0d984553473a1fed4b9fb56 (diff)
parent6124451d9534b1a03e58724411c492d9de980cb4 (diff)
downloadmariadb-git-0888e40fa316b040cb43f6fad112a0cdcd443155.tar.gz
Manual merge of mysql-5.1-bugteam into mysql-trunk-merge.
Conflicts: Text conflict in .bzr-mysql/default.conf Text conflict in mysql-test/suite/rpl/r/rpl_slow_query_log.result Text conflict in mysql-test/suite/rpl/t/rpl_slow_query_log.test Conflict adding files to server-tools. Created directory. Conflict because server-tools is not versioned, but has versioned children. Versioned directory. Conflict adding files to server-tools/instance-manager. Created directory. Conflict because server-tools/instance-manager is not versioned, but has versioned children. Versioned directory. Contents conflict in server-tools/instance-manager/options.cc Text conflict in sql/mysqld.cc
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc28
1 files changed, 22 insertions, 6 deletions
diff --git a/sql/item.cc b/sql/item.cc
index b52619ceee0..4b6b77860d6 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;
}
}
}