1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fix for bug #22026: Warning when using IF statement and large unsigned bigint

We use INT_RESULT type if all arguments are of type INT for 'if', 'case', 
'coalesce' functions regardless of arguments' unsigned flag, so sometimes we can
exceed the INT bounds.
This commit is contained in:
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
2007-01-22 14:52:23 +04:00
parent 8e6f3ab33b
commit a079f20aa8
3 changed files with 63 additions and 3 deletions

View File

@ -3634,3 +3634,33 @@ INSERT into t1 values (1), (2), (3);
SELECT * FROM t1 LIMIT 2, -1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1
DROP TABLE t1;
create table t1 (a bigint unsigned);
insert into t1 values
(if(1, 9223372036854775808, 1)),
(case when 1 then 9223372036854775808 else 1 end),
(coalesce(9223372036854775808, 1));
select * from t1;
a
9223372036854775808
9223372036854775808
9223372036854775808
drop table t1;
create table t1 select
if(1, 9223372036854775808, 1) i,
case when 1 then 9223372036854775808 else 1 end c,
coalesce(9223372036854775808, 1) co;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` decimal(19,0) NOT NULL default '0',
`c` decimal(19,0) NOT NULL default '0',
`co` decimal(19,0) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select
if(1, cast(1111111111111111111 as unsigned), 1) i,
case when 1 then cast(1111111111111111111 as unsigned) else 1 end c,
coalesce(cast(1111111111111111111 as unsigned), 1) co;
i c co
1111111111111111111 1111111111111111111 1111111111111111111
End of 5.0 tests