Commit 73bb79db authored by serg@serg.mylan's avatar serg@serg.mylan

Bug #792 combination of date-interval and between with mixed constant and non-constant

parent 3396c1a8
......@@ -32,6 +32,8 @@ datum
2000-01-02
2000-01-03
2000-01-04
SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND datum - INTERVAL 100 DAY;
datum
DROP TABLE t1;
CREATE TABLE t1 (
user_id char(10),
......
......@@ -34,6 +34,7 @@ INSERT INTO t1 VALUES ( "2000-1-3" );
INSERT INTO t1 VALUES ( "2000-1-4" );
INSERT INTO t1 VALUES ( "2000-1-5" );
SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND "2000-1-4";
SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND datum - INTERVAL 100 DAY;
DROP TABLE t1;
#
......
......@@ -1058,14 +1058,12 @@ String *Item_date_add_interval::val_str(String *str)
longlong Item_date_add_interval::val_int()
{
TIME ltime;
longlong date;
if (Item_date_add_interval::get_date(&ltime,0))
return (longlong) 0;
return ((longlong) (((ulong) ltime.year)*10000L+
(((uint) ltime.month)*100+
(uint) ltime.day))*(longlong) 1000000L+
(longlong) ((ulong) ((uint) ltime.hour)*10000L+
(ulong) (((uint)ltime.minute)*100L+
(uint) ltime.second)));
date = (ltime.year*100L + ltime.month)*100L + ltime.day;
return ltime.time_type == TIMESTAMP_DATE ? date :
((date*100L + ltime.hour)*100L+ ltime.minute)*100L + ltime.second;
}
void Item_extract::fix_length_and_dec()
......
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