mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Fixed bug #31471: decimal_bin_size: Assertion `scale >= 0 &&
precision > 0 && scale <= precision'. A sign of a resulting item of the IFNULL function was not updated and the maximal length of this result was calculated improperly. Correct algorithm was copy&pasted from the IF function implementation. sql/item_cmpfunc.cc: Fixed bug #31471. The Item_func_ifnull::fix_length_and_dec method has been modified to update the Item_func_ifnull::unsigned_flag field and to take this field into account when calculating the Item_func_ifnull::max_length value. (See Item_func_if::fix_length_and_dec for reference). mysql-test/t/null.test: Added test case for bug #31471. mysql-test/r/null.result: Added test case for bug #31471. mysql-test/r/create.result: Update test case after the bugfix of bug #31471.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Initialise
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
drop table if exists t1, t2;
|
||||
--enable_warnings
|
||||
|
||||
#
|
||||
@@ -231,4 +231,27 @@ drop table bug19145a;
|
||||
drop table bug19145b;
|
||||
drop table bug19145c;
|
||||
|
||||
# End of 4.1 tests
|
||||
--echo # End of 4.1 tests
|
||||
|
||||
--echo #
|
||||
--echo # Bug #31471: decimal_bin_size: Assertion `scale >= 0 &&
|
||||
--echo # precision > 0 && scale <= precision'
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a DECIMAL (1, 0) ZEROFILL, b DECIMAL (1, 0) ZEROFILL);
|
||||
INSERT INTO t1 (a, b) VALUES (0, 0);
|
||||
|
||||
CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1;
|
||||
DESCRIBE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1;
|
||||
DESCRIBE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1;
|
||||
DESCRIBE t2;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo # End of 5.0 tests
|
||||
|
||||
Reference in New Issue
Block a user