Commit 05750704 authored by unknown's avatar unknown

Fix for bug #12728: Very strange behaviour of ELT


mysql-test/r/func_str.result:
  Fix for bug #12728: Very strange behaviour of ELT
    - test case
mysql-test/t/func_str.test:
  Fix for bug #12728: Very strange behaviour of ELT
    - test result
sql/item_strfunc.cc:
  Fix for bug #12728: Very strange behaviour of ELT
    - Item_func_elt::eq() introduced: check 'item' member as well
      (to distinguish for instance elt(1, 'a', 'b') and elt(2, 'a', 'b')
sql/item_strfunc.h:
  Fix for bug #12728: Very strange behaviour of ELT
    - Item_func_elt::eq() introduced: check 'item' member as well
      (to distinguish for instance elt(1, 'a', 'b') and elt(2, 'a', 'b')
parent 65fcdee5
...@@ -436,3 +436,10 @@ id aes_decrypt(str, 'bar') ...@@ -436,3 +436,10 @@ id aes_decrypt(str, 'bar')
1 foo 1 foo
2 NULL 2 NULL
DROP TABLE t1, t2; DROP TABLE t1, t2;
create table t1(a varchar(8), primary key(a));
insert into t1 values('bar'), ('foo');
select a from t1 where a=elt(1, 'foo', 'bar') or a=elt(2, 'foo', 'bar');
a
bar
foo
drop table t1;
...@@ -254,3 +254,11 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id ...@@ -254,3 +254,11 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# Bug #12728: strange elt() behavior
#
create table t1(a varchar(8), primary key(a));
insert into t1 values('bar'), ('foo');
select a from t1 where a=elt(1, 'foo', 'bar') or a=elt(2, 'foo', 'bar');
drop table t1;
...@@ -1599,6 +1599,17 @@ String *Item_func_elt::val_str(String *str) ...@@ -1599,6 +1599,17 @@ String *Item_func_elt::val_str(String *str)
} }
bool Item_func_elt::eq(const Item *par_item, bool binary_cmp) const
{
/*
We can use (Item_func_elt*) typecast here because the check is done
in the Item_func::eq().
*/
return Item_func::eq(par_item, binary_cmp) &&
item->eq(((Item_func_elt*) par_item)->item, binary_cmp);
}
void Item_func_make_set::split_sum_func(List<Item> &fields) void Item_func_make_set::split_sum_func(List<Item> &fields)
{ {
if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) if (item->with_sum_func && item->type() != SUM_FUNC_ITEM)
......
...@@ -372,6 +372,7 @@ public: ...@@ -372,6 +372,7 @@ public:
void fix_length_and_dec(); void fix_length_and_dec();
void update_used_tables(); void update_used_tables();
const char *func_name() const { return "elt"; } const char *func_name() const { return "elt"; }
bool eq(const Item *par_item, bool binary_cmp) const;
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment