diff options
author | Evgeny Potemkin <epotemkin@mysql.com> | 2010-10-07 11:07:56 +0400 |
---|---|---|
committer | Evgeny Potemkin <epotemkin@mysql.com> | 2010-10-07 11:07:56 +0400 |
commit | 4bfec5733d8a6c5096a65032a6036e17ddbdbd3e (patch) | |
tree | faa94ed990e76cab367149941d91bce0b95a772d /mysql-test/t/func_time.test | |
parent | c70a6f5c234dc18744a3305d5a601630bfd4ae75 (diff) | |
download | mariadb-git-4bfec5733d8a6c5096a65032a6036e17ddbdbd3e.tar.gz |
Bug#57039: constant subtime expression returns incorrect result.
The subtime function wasn't able to produce correct int representation of
its result. For constant expressions the Item_datetime_cache is used to
speedup evaluation and Item_datetime_cache expects underlying item to return
correct int representation of DATETIME value. These two factors combined led
to a wrong query result.
Now the Item_func_add_time has function val_datetime which performs the
calculation and saves result into given MYSQL_TIME struct, it also sets
null_value to appropriate value. val_int and val_str member functions
convert the result obtained from val_datetime to int or string respectively
and returns it.
Diffstat (limited to 'mysql-test/t/func_time.test')
-rw-r--r-- | mysql-test/t/func_time.test | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 1f6001219a3..08c09adb093 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -833,3 +833,14 @@ SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a); DROP TABLE t1; --echo End of 5.1 tests + +--echo # +--echo # Bug#57039: constant subtime expression returns incorrect result. +--echo # +CREATE TABLE t1 (`date_date` datetime NOT NULL); +INSERT INTO t1 VALUES ('2008-01-03 00:00:00'), ('2008-01-03 00:00:00'); +SELECT * FROM t1 WHERE date_date >= subtime(now(), "00:30:00"); +SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1" HOUR_SECOND), "00:20:00"); +DROP TABLE t1; +--echo # + |