mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
mysql-5.1.73 merge
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2000, 2012 Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2013 Monty Program Ab.
|
||||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2014, Monty Program Ab.
|
||||
|
||||
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
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
/**
|
||||
@file
|
||||
@@ -7393,7 +7393,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
|
||||
*simple_order=0; // Must do a temp table to sort
|
||||
else if (!(order_tables & not_const_tables))
|
||||
{
|
||||
if (order->item[0]->with_subselect &&
|
||||
if (order->item[0]->has_subquery() &&
|
||||
!(join->select_lex->options & SELECT_DESCRIBE))
|
||||
order->item[0]->val_str(&order->item[0]->str_value);
|
||||
DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));
|
||||
@@ -9815,7 +9815,7 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
|
||||
if (new_field)
|
||||
new_field->init(table);
|
||||
|
||||
if (copy_func && item->is_result_field())
|
||||
if (copy_func && item->real_item()->is_result_field())
|
||||
*((*copy_func)++) = item; // Save for copy_funcs
|
||||
if (modify_item)
|
||||
item->set_result_field(new_field);
|
||||
@@ -14130,7 +14130,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
||||
|
||||
if (best_key >= 0)
|
||||
{
|
||||
if (table->quick_keys.is_set(best_key) && best_key != ref_key)
|
||||
if (select &&
|
||||
table->quick_keys.is_set(best_key) && best_key != ref_key)
|
||||
{
|
||||
key_map map;
|
||||
map.clear_all(); // Force the creation of quick select
|
||||
@@ -16143,64 +16144,88 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
|
||||
res_selected_fields.empty();
|
||||
res_all_fields.empty();
|
||||
|
||||
uint i, border= all_fields.elements - elements;
|
||||
for (i= 0; (item= it++); i++)
|
||||
uint border= all_fields.elements - elements;
|
||||
for (uint i= 0; (item= it++); i++)
|
||||
{
|
||||
Field *field;
|
||||
|
||||
if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) ||
|
||||
(item->type() == Item::FUNC_ITEM &&
|
||||
((Item_func*)item)->functype() == Item_func::SUSERVAR_FUNC))
|
||||
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
|
||||
item_field= item;
|
||||
else
|
||||
else if (item->type() == Item::FIELD_ITEM)
|
||||
item_field= item->get_tmp_table_item(thd);
|
||||
else if (item->type() == Item::FUNC_ITEM &&
|
||||
((Item_func*)item)->functype() == Item_func::SUSERVAR_FUNC)
|
||||
{
|
||||
if (item->type() == Item::FIELD_ITEM)
|
||||
field= item->get_tmp_table_field();
|
||||
if( field != NULL)
|
||||
{
|
||||
item_field= item->get_tmp_table_item(thd);
|
||||
}
|
||||
else if ((field= item->get_tmp_table_field()))
|
||||
{
|
||||
if (item->type() == Item::SUM_FUNC_ITEM && field->table->group)
|
||||
item_field= ((Item_sum*) item)->result_item(field);
|
||||
else
|
||||
item_field= (Item*) new Item_field(field);
|
||||
if (!item_field)
|
||||
DBUG_RETURN(TRUE); // Fatal error
|
||||
|
||||
if (item->real_item()->type() != Item::FIELD_ITEM)
|
||||
field->orig_table= 0;
|
||||
item_field->name= item->name;
|
||||
if (item->type() == Item::REF_ITEM)
|
||||
{
|
||||
Item_field *ifield= (Item_field *) item_field;
|
||||
Item_ref *iref= (Item_ref *) item;
|
||||
ifield->table_name= iref->table_name;
|
||||
ifield->db_name= iref->db_name;
|
||||
}
|
||||
#ifndef DBUG_OFF
|
||||
if (!item_field->name)
|
||||
{
|
||||
char buff[256];
|
||||
String str(buff,sizeof(buff),&my_charset_bin);
|
||||
str.length(0);
|
||||
item->print(&str, QT_ORDINARY);
|
||||
item_field->name= sql_strmake(str.ptr(),str.length());
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
Replace "@:=<expression>" with "@:=<tmp table column>". Otherwise, we
|
||||
would re-evaluate <expression>, and if expression were a subquery, this
|
||||
would access already-unlocked tables.
|
||||
*/
|
||||
Item_func_set_user_var* suv=
|
||||
new Item_func_set_user_var(thd, (Item_func_set_user_var*) item);
|
||||
Item_field *new_field= new Item_field(field);
|
||||
if (!suv || !new_field)
|
||||
DBUG_RETURN(true); // Fatal error
|
||||
/*
|
||||
We are replacing the argument of Item_func_set_user_var after its value
|
||||
has been read. The argument's null_value should be set by now, so we
|
||||
must set it explicitly for the replacement argument since the null_value
|
||||
may be read without any preceeding call to val_*().
|
||||
*/
|
||||
new_field->update_null_value();
|
||||
List<Item> list;
|
||||
list.push_back(new_field);
|
||||
suv->set_arguments(list);
|
||||
item_field= suv;
|
||||
}
|
||||
else
|
||||
item_field= item;
|
||||
item_field= item;
|
||||
}
|
||||
else if ((field= item->get_tmp_table_field()))
|
||||
{
|
||||
if (item->type() == Item::SUM_FUNC_ITEM && field->table->group)
|
||||
item_field= ((Item_sum*) item)->result_item(field);
|
||||
else
|
||||
item_field= (Item*) new Item_field(field);
|
||||
if (!item_field)
|
||||
DBUG_RETURN(true); // Fatal error
|
||||
|
||||
if (item->real_item()->type() != Item::FIELD_ITEM)
|
||||
field->orig_table= 0;
|
||||
item_field->name= item->name;
|
||||
if (item->type() == Item::REF_ITEM)
|
||||
{
|
||||
Item_field *ifield= (Item_field *) item_field;
|
||||
Item_ref *iref= (Item_ref *) item;
|
||||
ifield->table_name= iref->table_name;
|
||||
ifield->db_name= iref->db_name;
|
||||
}
|
||||
#ifndef DBUG_OFF
|
||||
if (!item_field->name)
|
||||
{
|
||||
char buff[256];
|
||||
String str(buff,sizeof(buff),&my_charset_bin);
|
||||
str.length(0);
|
||||
item->print(&str, QT_ORDINARY);
|
||||
item_field->name= sql_strmake(str.ptr(),str.length());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
item_field= item;
|
||||
|
||||
res_all_fields.push_back(item_field);
|
||||
ref_pointer_array[((i < border)? all_fields.elements-i-1 : i-border)]=
|
||||
item_field;
|
||||
}
|
||||
|
||||
List_iterator_fast<Item> itr(res_all_fields);
|
||||
for (i= 0; i < border; i++)
|
||||
for (uint i= 0; i < border; i++)
|
||||
itr++;
|
||||
itr.sublist(res_selected_fields, elements);
|
||||
DBUG_RETURN(FALSE);
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user