MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kgeorge Date:January 30 2007 3:43pm
Subject:bk commit into 5.0 tree (gkodinov:1.2387) BUG#25643
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kgeorge. When kgeorge does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-01-30 17:43:34+02:00, gkodinov@stripped +3 -0
  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).

  mysql-test/r/func_time.result@stripped, 2007-01-30 17:43:28+02:00, gkodinov@stripped +14 -0
    Bug #25643: SEC_TO_TIME function problem
     - test case

  mysql-test/t/func_time.test@stripped, 2007-01-30 17:43:29+02:00, gkodinov@stripped +12 -0
    Bug #25643: SEC_TO_TIME function problem
     - test case

  sql/item_timefunc.cc@stripped, 2007-01-30 17:43:29+02:00, gkodinov@stripped +6 -3
    Bug #25643: SEC_TO_TIME function problem
     - null handling fixed for QUARTER() and SEC_TO_TIME()

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	gkodinov
# Host:	macbook.gmz
# Root:	/Users/kgeorge/mysql/work/B25643-5.0-opt

--- 1.137/sql/item_timefunc.cc	2007-01-17 20:30:00 +02:00
+++ 1.138/sql/item_timefunc.cc	2007-01-30 17:43:29 +02:00
@@ -1054,7 +1054,8 @@ longlong Item_func_quarter::val_int()
 {
   DBUG_ASSERT(fixed == 1);
   TIME ltime;
-  (void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
+  if (get_arg0_date(&ltime, TIME_FUZZY_DATE))
+    return 0;
   return (longlong) ((ltime.month+2)/3);
 }
 
@@ -1668,6 +1669,7 @@ String *Item_func_sec_to_time::val_str(S
 {
   DBUG_ASSERT(fixed == 1);
   TIME ltime;
+  longlong arg_val= args[0]->val_int(); 
 
   if ((null_value=args[0]->null_value) || str->alloc(19))
   {
@@ -1675,7 +1677,7 @@ String *Item_func_sec_to_time::val_str(S
     return (String*) 0;
   }
 
-  sec_to_time(args[0]->val_int(), args[0]->unsigned_flag, &ltime);
+  sec_to_time(arg_val, args[0]->unsigned_flag, &ltime);
   
   make_time((DATE_TIME_FORMAT *) 0, &ltime, str);
   return str;
@@ -1686,11 +1688,12 @@ longlong Item_func_sec_to_time::val_int(
 {
   DBUG_ASSERT(fixed == 1);
   TIME ltime;
+  longlong arg_val= args[0]->val_int(); 
   
   if ((null_value=args[0]->null_value))
     return 0;
 
-  sec_to_time(args[0]->val_int(), args[0]->unsigned_flag, &ltime);
+  sec_to_time(arg_val, args[0]->unsigned_flag, &ltime);
 
   return (ltime.neg ? -1 : 1) *
     ((ltime.hour)*10000 + ltime.minute*100 + ltime.second);

--- 1.79/mysql-test/r/func_time.result	2006-11-29 11:40:57 +02:00
+++ 1.80/mysql-test/r/func_time.result	2007-01-30 17:43:28 +02:00
@@ -1207,3 +1207,17 @@ SET NAMES DEFAULT;
 select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
 str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
 NULL
+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;
+t1	t2	SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) )	QUARTER(d)
+10:00:00	NULL	NULL	NULL
+11:00:00	11:15:00	00:15:00	1
+SELECT t1, t2, SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ), QUARTER(d)
+FROM t1 ORDER BY a DESC;
+t1	t2	SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) )	QUARTER(d)
+11:00:00	11:15:00	00:15:00	1
+10:00:00	NULL	NULL	NULL
+DROP TABLE t1;

--- 1.66/mysql-test/t/func_time.test	2006-11-29 11:40:57 +02:00
+++ 1.67/mysql-test/t/func_time.test	2007-01-30 17:43:29 +02:00
@@ -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;
Thread
bk commit into 5.0 tree (gkodinov:1.2387) BUG#25643kgeorge30 Jan