Details
Description
sql_mode='NO_UNSIGNED_SUBTRACTION' is supposed to allow the subtraction of two unsigned integers. However, in MariaDB it seems to allow only subtractions involving only ONE unsigned integer (if the result is negative).
SET SQL_MODE='NO_UNSIGNED_SUBTRACTION';
|
|
SELECT CAST(0 AS UNSIGNED) - 1;
|
+-------------------------+
|
| CAST(0 AS UNSIGNED) - 1 |
|
+-------------------------+
|
| -1 |
|
+-------------------------+
|
|
SELECT 2-CAST(3 AS UNSIGNED);
|
+-----------------------+
|
| 2-CAST(3 AS UNSIGNED) |
|
+-----------------------+
|
| -1 |
|
+-----------------------+
|
|
SELECT CAST(1 AS UNSIGNED) - CAST(2 AS UNSIGNED);
|
ERROR 1690 (22003): BIGINT value is out of range in 'cast(1 as unsigned) - cast(2 as unsigned)'
|
This works in MySQL (tested version 5.6.40 and 8.0.39)
Error originally reported on https://mariadb.com/kb/en/scope-of-no_unsigned_subtraction/
Attachments
Issue Links
- relates to
-
MDEV-30272 trigger sql_mode set to 'NO_UNSIGNED_SUBTRACTION' has no effect after upgrade from 10.3.37 to 10.4.27
-
- Open
-