summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2003-08-06 16:52:47 +0200
committerunknown <serg@serg.mylan>2003-08-06 16:52:47 +0200
commit3ee893cc3d0fb755a6d435a7cc41e0e819781761 (patch)
tree34df152f1ae282d071c2dbc1d46413719fd7f022
parentb90ec2492681fffa1748c6f2b1f3db37493c66c1 (diff)
parente50930d36c33c4457d9ba6d68e5f6b2c6e622f11 (diff)
downloadmariadb-git-3ee893cc3d0fb755a6d435a7cc41e0e819781761.tar.gz
Merge bk-internal:/home/bk/mysql-4.0/
into serg.mylan:/usr/home/serg/Abk/mysql-4.0
-rw-r--r--mysql-test/r/type_date.result2
-rw-r--r--mysql-test/t/type_date.test1
-rw-r--r--sql/item_timefunc.cc10
3 files changed, 7 insertions, 6 deletions
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 214328eab47..8dfe14bc1a2 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -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),
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 68c2d55aac9..bd6d8c49c22 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -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;
#
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 84e7a44ac61..caea79314de 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -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()