From: [EMAIL PROTECTED]
To:   [EMAIL PROTECTED]
Subject: MYSQL bug with if and datetime fields

>Description:
        In queries where datetime field is in "WHERE" condition, the same
field
        in "IF" statement causes incorrect query result.
>How-To-Repeat:
#---------------------------------------------------------------------------
---------------------------------------------
  mysql> select * from test ;
  +------+---------------------+
  | id   | dt                  |
  +------+---------------------+
  |    1 | 2001-08-14 00:00:00 |
  |    2 | 2001-08-15 00:00:00 |
  |    3 | 2001-08-16 00:00:00 |
  +------+---------------------+
  3 rows in set (0.00 sec)
 
  mysql> select * from test where dt='2001-08-14 00:00:00' and dt =
if(id=1,'2001-08-14 00:00:00','1999-08-15');
  Empty set (0.95 sec)
 
  mysql> select * from test where dt='2001-08-14' and dt =
if(id=1,'2001-08-14 00:00:00','1999-08-15');
  Empty set (0.01 sec)
#---------------------------------------------------------------------------
--------------------------------------------
>Fix:
#---------------------------------------------------------------------------
--------------------------------------------
  mysql> select * from test where dt like '2001-08-14 00:00:00' and dt =
if(id=1,'2001-08-14 00:00:00','1999-08-15');
  +------+---------------------+
  | id   | dt                  |
  +------+---------------------+
  |    1 | 2001-08-14 00:00:00 |
  +------+---------------------+
  1 row in set (0.76 sec)
#---------------------------------------------------------------------------
---------------------------------------------
>Submitter-Id:  <submitter ID>
>Originator:    Arturs Aboltins
>Organization: (Private)
>MySQL support: [none]
>Synopsis:      Buf with DATETIME fields and IF.
>Severity:      [ serious ]
>Priority:      [ medium ] 
>Category:      mysql
>Class:         [ sw-bug ]
>Release:       mysql-3.23.36 (Binary distribution from RedHat 7.1)

>Environment: i686, Linux,
System: Linux aaboltin.telekom.lv 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001
i686 unknown
Architecture: i686

Some paths:  /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc
/usr/bin/cc

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to