From 05750704a83bc3388e007145e16907c0b61abaa2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jun 2006 16:01:54 +0500 Subject: 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') --- mysql-test/r/func_str.result | 7 +++++++ mysql-test/t/func_str.test | 8 ++++++++ sql/item_strfunc.cc | 11 +++++++++++ sql/item_strfunc.h | 1 + 4 files changed, 27 insertions(+) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 6fefbb16353..1feda854014 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -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; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 81d5daaf0ba..0e7ab70940a 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -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; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f070382e5c1..2ea693e94a3 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -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 &fields) { if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index ece15484fd9..482a941c55b 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -372,6 +372,7 @@ public: 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);} }; -- cgit v1.2.1 From 95939476ab600f2e19ac6780fc985b0500b60b9c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Jun 2006 13:03:29 +0500 Subject: Fix for bug #20496: func_time.test failure mysql-test/r/func_time.result: Fix for bug #20496: func_time.test failure - floating point calculations removed. mysql-test/t/func_time.test: Fix for bug #20496: func_time.test failure - floating point calculations removed. --- mysql-test/r/func_time.result | 13 ++++++++++--- mysql-test/t/func_time.test | 6 ++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index e7a00b71961..c90a4258036 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -671,7 +671,14 @@ select f1 from t1 where makedate(2006,2) between date(f1) and date(f3); f1 2006-01-02 drop table t1; -select now() - now() + 0, curtime() - curtime() + 0, +create table t1 select now() - now(), curtime() - curtime(), sec_to_time(1) + 0, from_unixtime(1) + 0; -now() - now() + 0 curtime() - curtime() + 0 sec_to_time(1) + 0 from_unixtime(1) + 0 -0.000000 0.000000 1.000000 19700101030001.000000 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `now() - now()` double(23,6) NOT NULL default '0.000000', + `curtime() - curtime()` double(23,6) NOT NULL default '0.000000', + `sec_to_time(1) + 0` double(23,6) default NULL, + `from_unixtime(1) + 0` double(23,6) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 23e3b9d982a..d69545712c8 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -347,7 +347,9 @@ drop table t1; # Bug #16546 # -select now() - now() + 0, curtime() - curtime() + 0, - sec_to_time(1) + 0, from_unixtime(1) + 0; +create table t1 select now() - now(), curtime() - curtime(), + sec_to_time(1) + 0, from_unixtime(1) + 0; +show create table t1; +drop table t1; # End of 4.1 tests -- cgit v1.2.1