Commit 97562d74 authored by ramil@mysql.com's avatar ramil@mysql.com
Browse files

Fix for bug #12728: Very strange behaviour of ELT

parent e09910f9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -436,3 +436,10 @@ id aes_decrypt(str, 'bar')
1	foo
2	NULL
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;
+8 −0
Original line number Diff line number Diff line
@@ -254,3 +254,11 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id

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;
+11 −0
Original line number Diff line number Diff line
@@ -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)
{
  if (item->with_sum_func && item->type() != SUM_FUNC_ITEM)
+1 −0
Original line number Diff line number Diff line
@@ -372,6 +372,7 @@ class Item_func_elt :public Item_str_func
  void fix_length_and_dec();
  void update_used_tables();
  const char *func_name() const { return "elt"; }
  bool eq(const Item *par_item, bool binary_cmp) const;
  unsigned int size_of() { return sizeof(*this);}  
};