List:Commits« Previous MessageNext Message »
From:holyfoot Date:August 11 2006 9:08am
Subject:bk commit into 5.0 tree (holyfoot:1.2234) BUG#19491
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of hf. When hf 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, 2006-08-11 14:08:40+05:00, holyfoot@stripped +5 -0
  bug #19491 (CASTing a DATETIME to DECIMAL)
  additional fix to solve the same problem with TIME type

  mysql-test/r/type_datetime.result@stripped, 2006-08-11 14:08:37+05:00, holyfoot@stripped +3 -0
    result fixed

  mysql-test/t/type_datetime.test@stripped, 2006-08-11 14:08:37+05:00, holyfoot@stripped +1 -0
    TIME type test added

  sql/item.cc@stripped, 2006-08-11 14:08:37+05:00, holyfoot@stripped +24 -0
    val_decimal_from_time implemented

  sql/item.h@stripped, 2006-08-11 14:08:37+05:00, holyfoot@stripped +1 -0
    val_decimal_from_time declared

  sql/item_strfunc.cc@stripped, 2006-08-11 14:08:37+05:00, holyfoot@stripped +10 -8
    to handle MYSQL_TYPE_TIME separately

# 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:	holyfoot
# Host:	deer.(none)
# Root:	/home/hf/work/mysql-5.0.19491

--- 1.231/sql/item.cc	2006-08-11 14:08:47 +05:00
+++ 1.232/sql/item.cc	2006-08-11 14:08:47 +05:00
@@ -296,6 +296,30 @@
 }
 
 
+my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value)
+{
+  DBUG_ASSERT(fixed == 1);
+  TIME ltime;
+  longlong date;
+  if (get_time(&ltime))
+  {
+    my_decimal_set_zero(decimal_value);
+    return 0;
+  }
+  date = (ltime.year*100L + ltime.month)*100L + ltime.day;
+  if (ltime.time_type > MYSQL_TIMESTAMP_DATE)
+   date= ((date*100L + ltime.hour)*100L+ ltime.minute)*100L + ltime.second;
+  if (int2my_decimal(E_DEC_FATAL_ERROR, date, FALSE, decimal_value))
+    return decimal_value;
+  if (ltime.second_part)
+  {
+    decimal_value->buf[2]= ltime.second_part * 100000;
+    decimal_value->frac= 4;
+  }
+  return decimal_value;
+}
+
+
 double Item::val_real_from_decimal()
 {
   /* Note that fix_fields may not be called for Item_avg_field items */

--- 1.206/sql/item.h	2006-08-11 14:08:47 +05:00
+++ 1.207/sql/item.h	2006-08-11 14:08:47 +05:00
@@ -606,6 +606,7 @@
   my_decimal *val_decimal_from_int(my_decimal *decimal_value);
   my_decimal *val_decimal_from_string(my_decimal *decimal_value);
   my_decimal *val_decimal_from_date(my_decimal *decimal_value);
+  my_decimal *val_decimal_from_time(my_decimal *decimal_value);
   longlong val_int_from_decimal();
   double val_real_from_decimal();
 

--- 1.281/sql/item_strfunc.cc	2006-08-11 14:08:47 +05:00
+++ 1.282/sql/item_strfunc.cc	2006-08-11 14:08:47 +05:00
@@ -83,14 +83,16 @@
 my_decimal *Item_str_func::val_decimal(my_decimal *decimal_value)
 {
   DBUG_ASSERT(fixed == 1);
-  char buff[64];
-  String *res, tmp(buff,sizeof(buff), &my_charset_bin);
-  enum_field_types ftype= field_type();
-
-  if ((ftype == MYSQL_TYPE_DATE) ||
-      (ftype == MYSQL_TYPE_TIME) ||
-      (ftype == MYSQL_TYPE_DATETIME))
-    return  val_decimal_from_date(decimal_value);
+  switch (field_type())
+  {
+    case MYSQL_TYPE_DATE:
+    case MYSQL_TYPE_DATETIME:
+      return  val_decimal_from_date(decimal_value);
+      
+    case MYSQL_TYPE_TIME:
+      return  val_decimal_from_time(decimal_value);
+    default:;
+  }
 
   return val_decimal_from_string(decimal_value);
 }

--- 1.32/mysql-test/r/type_datetime.result	2006-08-11 14:08:47 +05:00
+++ 1.33/mysql-test/r/type_datetime.result	2006-08-11 14:08:47 +05:00
@@ -177,3 +177,6 @@
 SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
 CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6))
 20060810101112.001400
+SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
+CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6))
+101112.000000

--- 1.19/mysql-test/t/type_datetime.test	2006-08-11 14:08:47 +05:00
+++ 1.20/mysql-test/t/type_datetime.test	2006-08-11 14:08:47 +05:00
@@ -122,3 +122,4 @@
 SELECT CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6));
 SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6));
 SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
+SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
Thread
bk commit into 5.0 tree (holyfoot:1.2234) BUG#19491holyfoot11 Aug