summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorigor@olga.mysql.com <>2007-03-11 23:34:40 -0700
committerigor@olga.mysql.com <>2007-03-11 23:34:40 -0700
commite7284ace4f0f25fef34a72c16e34c30e11fdf6b4 (patch)
tree02abad69b98470e037973567d0574730ca30eda8 /sql/item.cc
parentf3e56b5adb2208f5db63c8821b9bf44f7568b4af (diff)
downloadmariadb-git-e7284ace4f0f25fef34a72c16e34c30e11fdf6b4.tar.gz
Fixed bug #26963: invalid optimization of the pushdown conditions
after single-row table substitution could lead to a wrong result set. The bug happened because the function Item_field::replace_equal_field erroniously assumed that any field included in a multiple equality with a constant has been already substituted for this constant. This not true for fields becoming constant after row substitutions for constant tables.
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc
index ec33bf1ddc7..11a5039ca19 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4075,7 +4075,9 @@ bool Item_field::set_no_const_sub(byte *arg)
DESCRIPTION
The function returns a pointer to an item that is taken from
the very beginning of the item_equal list which the Item_field
- object refers to (belongs to).
+ object refers to (belongs to) unless item_equal contains a constant
+ item. In this case the function returns this constant item,
+ (if the substitution does not require conversion).
If the Item_field object does not refer any Item_equal object
'this' is returned
@@ -4084,7 +4086,8 @@ bool Item_field::set_no_const_sub(byte *arg)
of the thransformer method.
RETURN VALUES
- pointer to a replacement Item_field if there is a better equal item;
+ pointer to a replacement Item_field if there is a better equal item or
+ a pointer to a constant equal item;
this - otherwise.
*/
@@ -4092,6 +4095,14 @@ Item *Item_field::replace_equal_field(byte *arg)
{
if (item_equal)
{
+ Item *const_item= item_equal->get_const();
+ if (const_item)
+ {
+ if (cmp_context != (Item_result)-1 &&
+ const_item->cmp_context != cmp_context)
+ return this;
+ return const_item;
+ }
Item_field *subst= item_equal->get_first();
if (subst && !field->eq(subst->field))
return subst;