List:Commits« Previous MessageNext Message »
From:holyfoot Date:May 6 2007 2:36pm
Subject:bk commit into 5.0 tree (holyfoot:1.2474) BUG#27921
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, 2007-05-06 17:36:07+05:00, holyfoot@stripped +3 -0
  bug #27921 (View ignores precision for CAST)
  
  Item_decimal_typecast::print method wasn't properly implemented,
  so VIEW internal implementation didn't get proper precision/scale

  mysql-test/r/view.result@stripped, 2007-05-06 17:36:05+05:00, holyfoot@stripped +8 -0
    result added

  mysql-test/t/view.test@stripped, 2007-05-06 17:36:05+05:00, holyfoot@stripped +9 -0
    testcase

  sql/item_func.cc@stripped, 2007-05-06 17:36:05+05:00, holyfoot@stripped +19 -1
    Item_decimal_typecast::print method implemented properly

# 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:	hfmain.(none)
# Root:	/home/hf/work/27921/my50-27921

--- 1.335/sql/item_func.cc	2007-05-06 17:36:11 +05:00
+++ 1.336/sql/item_func.cc	2007-05-06 17:36:11 +05:00
@@ -1048,9 +1048,27 @@ my_decimal *Item_decimal_typecast::val_d
 
 void Item_decimal_typecast::print(String *str)
 {
+  char len_buf[20*3 + 1];
+  uint32 str_len;
+  CHARSET_INFO *cs= str->charset();
+
+  uint precision= my_decimal_length_to_precision(max_length, decimals,
+                                                 unsigned_flag);
   str->append(STRING_WITH_LEN("cast("));
   args[0]->print(str);
-  str->append(STRING_WITH_LEN(" as decimal)"));
+  str->append(STRING_WITH_LEN(" as decimal("));
+
+  str_len=(uint32) (cs->cset->long10_to_str)
+                     (cs,len_buf,sizeof(len_buf),10,precision);
+  str->append(len_buf, str_len);
+
+  str->append(STRING_WITH_LEN(", "));
+
+  str_len=(uint32) (cs->cset->long10_to_str)
+                     (cs,len_buf,sizeof(len_buf),10,decimals);
+  str->append(len_buf, str_len);
+
+  str->append(STRING_WITH_LEN("))"));
 }
 
 

--- 1.199/mysql-test/r/view.result	2007-05-06 17:36:11 +05:00
+++ 1.200/mysql-test/r/view.result	2007-05-06 17:36:11 +05:00
@@ -3354,4 +3354,12 @@ id	select_type	table	type	possible_keys	
 NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	Using filesort
 DROP VIEW v1;
 DROP TABLE t1;
+CREATE VIEW v1 AS SELECT CAST( 1.23456789 AS DECIMAL( 7,5 ) ) AS col;
+SELECT * FROM v1;
+col
+1.23457
+DESCRIBE v1;
+Field	Type	Null	Key	Default	Extra
+col	decimal(7,5)	NO		0.00000	
+DROP VIEW v1;
 End of 5.0 tests.

--- 1.182/mysql-test/t/view.test	2007-05-06 17:36:11 +05:00
+++ 1.183/mysql-test/t/view.test	2007-05-06 17:36:11 +05:00
@@ -3221,4 +3221,13 @@ EXPLAIN SELECT * FROM t1 UNION SELECT * 
 DROP VIEW v1;
 DROP TABLE t1;
 
+#
+# Bug #27921 View ignores precision for CAST()
+#
+CREATE VIEW v1 AS SELECT CAST( 1.23456789 AS DECIMAL( 7,5 ) ) AS col;
+SELECT * FROM v1;
+DESCRIBE v1;
+
+DROP VIEW v1;
+
 --echo End of 5.0 tests.
Thread
bk commit into 5.0 tree (holyfoot:1.2474) BUG#27921holyfoot6 May