From 0aab3a9ebab7a6835117c5dab5623ec9d58ce648 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Thu, 11 Mar 2004 18:21:57 +0400 Subject: [PATCH] a fix (bug #2885: like datetime) --- mysql-test/r/func_like.result | 6 ++++++ mysql-test/t/func_like.test | 8 ++++++++ sql/item_cmpfunc.cc | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/mysql-test/r/func_like.result b/mysql-test/r/func_like.result index 7f722622be1..75692738caf 100644 --- a/mysql-test/r/func_like.result +++ b/mysql-test/r/func_like.result @@ -46,6 +46,12 @@ select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b'; a a\b drop table t1; +create table t1 (a datetime); +insert into t1 values ('2004-03-11 12:00:21'); +select * from t1 where a like '2004-03-11 12:00:21'; +a +2004-03-11 12:00:21 +drop table t1; SET NAMES koi8r; CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r); INSERT INTO t1 VALUES ('ÆÙ×Á'),('æÙ×Á'),('Æù×Á'),('ÆÙ÷Á'),('ÆÙ×á'),('æù÷á'); diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index 8b719b077f2..91f55af48cc 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -35,6 +35,14 @@ select * from t1 where a like 'a\\%' escape '#'; select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b'; drop table t1; +# +# Bug #2885: like and datetime +# + +create table t1 (a datetime); +insert into t1 values ('2004-03-11 12:00:21'); +select * from t1 where a like '2004-03-11 12:00:21'; +drop table t1; # # Test like with non-default character set diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f0bc73e9501..1f11d050c1f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -225,6 +225,13 @@ void Item_bool_func2::fix_length_and_dec() } // Make a special case of compare with fields to get nicer DATE comparisons + + if (functype() == LIKE_FUNC) // Disable conversion in case of LIKE function. + { + set_cmp_func(); + return; + } + if (args[0]->type() == FIELD_ITEM) { Field *field=((Item_field*) args[0])->field;