Bug #8768 | Functions: For any unsigned data type, -ve values can be passed and returned. | ||
---|---|---|---|
Submitted: | 24 Feb 2005 8:56 | Modified: | 7 Dec 2005 20:10 |
Reporter: | Disha | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S2 (Serious) |
Version: | 5.0.13-BK | OS: | Any (any) |
Assigned to: | Alexander Nozdrin | CPU Architecture: | Any |
[24 Feb 2005 8:56]
Disha
[24 Feb 2005 9:09]
Disha
Updated OS
[24 Feb 2005 9:27]
Disha
Updated the synopsis.
[29 Apr 2005 12:36]
Per-Erik Martin
It now truncates the value: mysql> Select fn1(-2500)// +------------+ | fn1(-2500) | +------------+ | -128 | +------------+ 1 row in set (0.00 sec) I will however keep this open until we have decided if this is still a bug or an acceptable result. (Should perhaps be an error in some modes.)
[13 May 2005 15:43]
Trudy Pelzer
When sql_mode='traditional', the function should return an error when the value is out-of-range for the specified data type. For numeric data types, the error should be ERROR 1264 SQLSTATE 22003 Out of range value ...
[14 Sep 2005 13:26]
Valeriy Kravchuk
The problem still exists in 5.0.13-BK: mysql> create function fn2 (a tinyint unsigned) returns tinyint begin return a ; end// Query OK, 0 rows affected (0,01 sec) mysql> select fn2(-2500)// +------------+ | fn2(-2500) | +------------+ | -128 | +------------+ 1 row in set (0,03 sec) mysql> create table ttt (c1 tinyint unsigned)// Query OK, 0 rows affected (0,01 sec) mysql> insert into ttt values(-2500)// Query OK, 1 row affected, 1 warning (0,00 sec) mysql> show warnings// +---------+------+------------------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------------------+ | Warning | 1264 | Out of range value adjusted for column 'c1' at row 1 | +---------+------+------------------------------------------------------+ 1 row in set (0,00 sec) mysql> select * from ttt// +------+ | c1 | +------+ | 0 | +------+ 1 row in set (0,00 sec) So, I think the behaviour cosistent with table's one is really needed.
[7 Dec 2005 20:10]
Paul DuBois
Note in 5.0.18 changelog.