Bug #95978 Some operations silently truncate values
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.
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.
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.