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