summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_time.test
diff options
context:
space:
mode:
authorgkodinov/kgeorge@macbook.gmz <>2007-01-30 17:43:34 +0200
committergkodinov/kgeorge@macbook.gmz <>2007-01-30 17:43:34 +0200
commita7af53838aaa925cef23bb695512f399a89c8f95 (patch)
tree5c7cb0cb4906ff6bc2e08245db1b6d5f5d6c589c /mysql-test/t/func_time.test
parent4908cf0772166d3b93297601265ba52f34bca7f2 (diff)
downloadmariadb-git-a7af53838aaa925cef23bb695512f399a89c8f95.tar.gz
Bug #25643: SEC_TO_TIME function problem
Checking for NULL before calling the val_xxx() methods only checks for such arguments that are known to be NULLs at compile time. The arguments that may or may not contain NULLs (e.g. function calls and possibly others) are not checked at all. Fixed by first calling the val_xxx() method and then checking for null in SEC_TO_TIME(). In addition QUARTER() was not returning 0 (as all the val_int() functions do when processing a NULL value).
Diffstat (limited to 'mysql-test/t/func_time.test')
-rw-r--r--mysql-test/t/func_time.test12
1 files changed, 12 insertions, 0 deletions
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index a69cbb67c5b..1aa4b434a83 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -713,3 +713,15 @@ SET NAMES DEFAULT;
#
select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
+
+#
+# Bug #25643: SEC_TO_TIME function problem
+#
+CREATE TABLE t1 (a int, t1 time, t2 time, d date, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (1, '10:00:00', NULL, NULL),
+ (2, '11:00:00', '11:15:00', '1972-02-06');
+SELECT t1, t2, SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ), QUARTER(d)
+ FROM t1;
+SELECT t1, t2, SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ), QUARTER(d)
+ FROM t1 ORDER BY a DESC;
+DROP TABLE t1;