Bug #95978 Some operations silently truncate values

Submitted: 25 Jun 2019 13:03 Modified: 26 Jun 2019 6:32
Reporter: Iwo P Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.7.26, 8.0.16 OS:Any
Assigned to: CPU Architecture:Any

[25 Jun 2019 13:03] Iwo P
Description:
If the value of `num' parameter in CONV() function is larger than ULONG_MAX, then MySQL:
5.7)
 silently truncates the value,
8)
 truncates the value and report a warning.

Moreover, that's also true for other operations like bitwise-and for example, however in this case both 5.7 and 8.0 return a warning.

How to repeat:
5.7)

mysql> select conv('18446744073709551615',10,16);
+------------------------------------+
| conv('18446744073709551615',10,16) |
+------------------------------------+
| FFFFFFFFFFFFFFFF                   |
+------------------------------------+
1 row in set (0.00 sec)

mysql> select conv('18446744073709551616',10,16);
+------------------------------------+
| conv('18446744073709551616',10,16) |
+------------------------------------+
| FFFFFFFFFFFFFFFF                   |
+------------------------------------+
1 row in set (0.00 sec)

mysql> select conv('18446744073709551620',10,16);
+------------------------------------+
| conv('18446744073709551620',10,16) |
+------------------------------------+
| FFFFFFFFFFFFFFFF                   |
+------------------------------------+
1 row in set (0.00 sec)

8)
mysql [localhost:8015] {msandbox} ((none)) > select conv('18446744073709551615',10,16);
+------------------------------------+
| conv('18446744073709551615',10,16) |
+------------------------------------+
| FFFFFFFFFFFFFFFF                   |
+------------------------------------+
1 row in set (0.00 sec)

mysql [localhost:8015] {msandbox} ((none)) > select conv('18446744073709551616',10,16);
+------------------------------------+
| conv('18446744073709551616',10,16) |
+------------------------------------+
| FFFFFFFFFFFFFFFF                   |
+------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql [localhost:8015] {msandbox} ((none)) > select conv('18446744073709551620',10,16);
+------------------------------------+
| conv('18446744073709551620',10,16) |
+------------------------------------+
| FFFFFFFFFFFFFFFF                   |
+------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql [localhost:8015] {msandbox} ((none)) > select 18446744073709551620 &  18446744073709551620;
+----------------------------------------------+
| 18446744073709551620 &  18446744073709551620 |
+----------------------------------------------+
|                          9223372036854775807 |
+----------------------------------------------+

Suggested fix:
Return NULL and warning.
[26 Jun 2019 6:32] MySQL Verification Team
Hello Iwo P,

Thank you for the report and feedback.

Thanks,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.