Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem 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
1.1988 05/09/20 14:15:51 pem@stripped +3 -0
Fixed BUG#12589: Assert when creating temp. table from decimal stored
procedure variable
The problem was that the Item_decimal got the wrong max_length (from using
the signedness the wrong way), which caused the precision to later become
too small. (One less than it should be.) In the test case with the type
violation the value is defaulted to decimal 0 (with the due warning) which
then got the precision 0.
(The location for the fix was pinpointed with the help from Holyfoot.)
Note that the type used for the template is from the value, not the declared
type of the variable. (This is a different, type checking, issue.)
sql/item.cc
1.179 05/09/20 14:15:43 pem@stripped +2 -3
Don't use decimal_value.sign() as unsigned_flag argument, as this gives the wrong
length and subsequently the wrong precision (shorter than it should be).
mysql-test/t/sp.test
1.152 05/09/20 14:15:43 pem@stripped +51 -0
New test cases for BUG#12589.
mysql-test/r/sp.result
1.156 05/09/20 14:15:43 pem@stripped +45 -0
New test cases for BUG#12589.
# 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: pem
# Host: mysql.comhem.se
# Root: /usr/home/pem/mysql-5.0
--- 1.178/sql/item.cc 2005-09-14 08:10:12 +02:00
+++ 1.179/sql/item.cc 2005-09-20 14:15:43 +02:00
@@ -1845,7 +1845,7 @@
decimals= (uint8) decimal_value.frac;
fixed= 1;
max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
- decimals, !decimal_value.sign());
+ decimals, FALSE);
}
@@ -1855,8 +1855,7 @@
&decimal_value, precision, scale);
decimals= (uint8) decimal_value.frac;
fixed= 1;
- max_length= my_decimal_precision_to_length(precision, decimals,
- !decimal_value.sign());
+ max_length= my_decimal_precision_to_length(precision, decimals, FALSE);
}
--- 1.155/mysql-test/r/sp.result 2005-09-14 12:54:42 +02:00
+++ 1.156/mysql-test/r/sp.result 2005-09-20 14:15:43 +02:00
@@ -3348,4 +3348,49 @@
internal_var
NULL
drop procedure bug12979_2|
+drop procedure if exists bug12589_1|
+drop procedure if exists bug12589_2|
+drop procedure if exists bug12589_3|
+create procedure bug12589_1()
+begin
+declare spv1 decimal(3,3);
+set spv1= 123.456;
+set spv1 = 'test';
+create temporary table tm1 as select spv1;
+show create table tm1;
+drop temporary table tm1;
+end|
+create procedure bug12589_2()
+begin
+declare spv1 decimal(6,3);
+set spv1= 123.456;
+create temporary table tm1 as select spv1;
+show create table tm1;
+drop temporary table tm1;
+end|
+create procedure bug12589_3()
+begin
+declare spv1 decimal(6,3);
+set spv1= -123.456;
+create temporary table tm1 as select spv1;
+show create table tm1;
+drop temporary table tm1;
+end|
+call bug12589_1()|
+Table Create Table
+tm1 CREATE TEMPORARY TABLE `tm1` (
+ `spv1` decimal(1,0) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: 'test'
+call bug12589_2()|
+Table Create Table
+tm1 CREATE TEMPORARY TABLE `tm1` (
+ `spv1` decimal(6,3) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+call bug12589_3()|
+Table Create Table
+tm1 CREATE TEMPORARY TABLE `tm1` (
+ `spv1` decimal(6,3) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1,t2;
--- 1.151/mysql-test/t/sp.test 2005-09-14 12:54:42 +02:00
+++ 1.152/mysql-test/t/sp.test 2005-09-20 14:15:43 +02:00
@@ -4208,6 +4208,57 @@
#
+# BUG#12589: Assert when creating temp. table from decimal stored procedure
+# variable
+#
+--disable_warnings
+drop procedure if exists bug12589_1|
+drop procedure if exists bug12589_2|
+drop procedure if exists bug12589_3|
+--enable_warnings
+create procedure bug12589_1()
+begin
+ declare spv1 decimal(3,3);
+ set spv1= 123.456;
+
+ set spv1 = 'test';
+ create temporary table tm1 as select spv1;
+ show create table tm1;
+ drop temporary table tm1;
+end|
+
+create procedure bug12589_2()
+begin
+ declare spv1 decimal(6,3);
+ set spv1= 123.456;
+
+ create temporary table tm1 as select spv1;
+ show create table tm1;
+ drop temporary table tm1;
+end|
+
+create procedure bug12589_3()
+begin
+ declare spv1 decimal(6,3);
+ set spv1= -123.456;
+
+ create temporary table tm1 as select spv1;
+ show create table tm1;
+ drop temporary table tm1;
+end|
+
+# Note: The type of the field will match the value, not the declared
+# type of the variable. (This is a type checking issue which
+# might be changed later.)
+
+# Warning expected from "set spv1 = 'test'", the value is set to decimal "0".
+call bug12589_1()|
+# No warnings here
+call bug12589_2()|
+call bug12589_3()|
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
| Thread |
|---|
| • bk commit into 5.0 tree (pem:1.1988) BUG#12589 | pem | 20 Sep |