Bug #11827369: ASSERTION FAILED: !THD->LEX->CONTEXT_ANALYSIS_ONLY
Manual up-merge from 5.1 to 5.5.
This commit is contained in:
commit
4743ba00bb
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -472,7 +472,7 @@ Item::Item(THD *thd, Item *item):
|
|||||||
fixed(item->fixed),
|
fixed(item->fixed),
|
||||||
is_autogenerated_name(item->is_autogenerated_name),
|
is_autogenerated_name(item->is_autogenerated_name),
|
||||||
collation(item->collation),
|
collation(item->collation),
|
||||||
with_subselect(item->with_subselect),
|
with_subselect(item->has_subquery()),
|
||||||
cmp_context(item->cmp_context)
|
cmp_context(item->cmp_context)
|
||||||
{
|
{
|
||||||
next= thd->free_list; // Put in free list
|
next= thd->free_list; // Put in free list
|
||||||
|
18
sql/item.h
18
sql/item.h
@ -1,7 +1,7 @@
|
|||||||
#ifndef ITEM_INCLUDED
|
#ifndef ITEM_INCLUDED
|
||||||
#define ITEM_INCLUDED
|
#define ITEM_INCLUDED
|
||||||
|
|
||||||
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -1249,6 +1249,11 @@ public:
|
|||||||
Return TRUE if the item points to a column of an outer-joined table.
|
Return TRUE if the item points to a column of an outer-joined table.
|
||||||
*/
|
*/
|
||||||
virtual bool is_outer_field() const { DBUG_ASSERT(fixed); return FALSE; }
|
virtual bool is_outer_field() const { DBUG_ASSERT(fixed); return FALSE; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Checks if this item or any of its decendents contains a subquery.
|
||||||
|
*/
|
||||||
|
virtual bool has_subquery() const { return with_subselect; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -2528,6 +2533,10 @@ public:
|
|||||||
Field *get_tmp_table_field()
|
Field *get_tmp_table_field()
|
||||||
{ return result_field ? result_field : (*ref)->get_tmp_table_field(); }
|
{ return result_field ? result_field : (*ref)->get_tmp_table_field(); }
|
||||||
Item *get_tmp_table_item(THD *thd);
|
Item *get_tmp_table_item(THD *thd);
|
||||||
|
bool const_item() const
|
||||||
|
{
|
||||||
|
return (*ref)->const_item() && (used_tables() == 0);
|
||||||
|
}
|
||||||
table_map used_tables() const
|
table_map used_tables() const
|
||||||
{
|
{
|
||||||
return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables();
|
return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables();
|
||||||
@ -2603,6 +2612,13 @@ public:
|
|||||||
return (*ref)->is_outer_field();
|
return (*ref)->is_outer_field();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Checks if the item tree that ref points to contains a subquery.
|
||||||
|
*/
|
||||||
|
virtual bool has_subquery() const
|
||||||
|
{
|
||||||
|
return (*ref)->has_subquery();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -4366,7 +4366,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
|
|||||||
const_item_cache= FALSE;
|
const_item_cache= FALSE;
|
||||||
}
|
}
|
||||||
with_sum_func= with_sum_func || item->with_sum_func;
|
with_sum_func= with_sum_func || item->with_sum_func;
|
||||||
with_subselect|= item->with_subselect;
|
with_subselect|= item->has_subquery();
|
||||||
if (item->maybe_null)
|
if (item->maybe_null)
|
||||||
maybe_null=1;
|
maybe_null=1;
|
||||||
}
|
}
|
||||||
@ -4691,7 +4691,7 @@ longlong Item_func_isnull::val_int()
|
|||||||
Handle optimization if the argument can't be null
|
Handle optimization if the argument can't be null
|
||||||
This has to be here because of the test in update_used_tables().
|
This has to be here because of the test in update_used_tables().
|
||||||
*/
|
*/
|
||||||
if (!used_tables_cache && !with_subselect)
|
if (const_item_cache)
|
||||||
return cached_value;
|
return cached_value;
|
||||||
return args[0]->is_null() ? 1: 0;
|
return args[0]->is_null() ? 1: 0;
|
||||||
}
|
}
|
||||||
@ -4700,7 +4700,7 @@ longlong Item_is_not_null_test::val_int()
|
|||||||
{
|
{
|
||||||
DBUG_ASSERT(fixed == 1);
|
DBUG_ASSERT(fixed == 1);
|
||||||
DBUG_ENTER("Item_is_not_null_test::val_int");
|
DBUG_ENTER("Item_is_not_null_test::val_int");
|
||||||
if (!used_tables_cache && !with_subselect)
|
if (const_item_cache)
|
||||||
{
|
{
|
||||||
owner->was_null|= (!cached_value);
|
owner->was_null|= (!cached_value);
|
||||||
DBUG_PRINT("info", ("cached: %ld", (long) cached_value));
|
DBUG_PRINT("info", ("cached: %ld", (long) cached_value));
|
||||||
@ -4721,10 +4721,12 @@ longlong Item_is_not_null_test::val_int()
|
|||||||
*/
|
*/
|
||||||
void Item_is_not_null_test::update_used_tables()
|
void Item_is_not_null_test::update_used_tables()
|
||||||
{
|
{
|
||||||
|
const_item_cache= false;
|
||||||
if (!args[0]->maybe_null)
|
if (!args[0]->maybe_null)
|
||||||
{
|
{
|
||||||
used_tables_cache= 0; /* is always true */
|
used_tables_cache= 0; /* is always true */
|
||||||
cached_value= (longlong) 1;
|
cached_value= (longlong) 1;
|
||||||
|
const_item_cache= true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -4733,6 +4735,7 @@ void Item_is_not_null_test::update_used_tables()
|
|||||||
{
|
{
|
||||||
/* Remember if the value is always NULL or never NULL */
|
/* Remember if the value is always NULL or never NULL */
|
||||||
cached_value= (longlong) !args[0]->is_null();
|
cached_value= (longlong) !args[0]->is_null();
|
||||||
|
const_item_cache= true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4986,6 +4989,7 @@ Item_func_regex::fix_fields(THD *thd, Item **ref)
|
|||||||
args[1]->fix_fields(thd, args + 1)) || args[1]->check_cols(1))
|
args[1]->fix_fields(thd, args + 1)) || args[1]->check_cols(1))
|
||||||
return TRUE; /* purecov: inspected */
|
return TRUE; /* purecov: inspected */
|
||||||
with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func;
|
with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func;
|
||||||
|
with_subselect= args[0]->has_subquery() || args[1]->has_subquery();
|
||||||
max_length= 1;
|
max_length= 1;
|
||||||
decimals= 0;
|
decimals= 0;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -221,7 +221,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
|
|||||||
used_tables_cache|= item->used_tables();
|
used_tables_cache|= item->used_tables();
|
||||||
not_null_tables_cache|= item->not_null_tables();
|
not_null_tables_cache|= item->not_null_tables();
|
||||||
const_item_cache&= item->const_item();
|
const_item_cache&= item->const_item();
|
||||||
with_subselect|= item->with_subselect;
|
with_subselect|= item->has_subquery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fix_length_and_dec();
|
fix_length_and_dec();
|
||||||
|
@ -7449,7 +7449,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
|
|||||||
*simple_order=0; // Must do a temp table to sort
|
*simple_order=0; // Must do a temp table to sort
|
||||||
else if (!(order_tables & not_const_tables))
|
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))
|
!(join->select_lex->options & SELECT_DESCRIBE))
|
||||||
order->item[0]->val_str(&order->item[0]->str_value);
|
order->item[0]->val_str(&order->item[0]->str_value);
|
||||||
DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));
|
DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user