Skip to content

The behavior of NO_UNSIGNED_SUBTRACTION is not consistent with MySQL #59787

@YangKeao

Description

@YangKeao

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; CREATE TABLE t15 (a INT SIGNED, b INT UNSIGNED); INSERT INTO t15 VALUES (10, 20); SELECT * FROM t15 WHERE a - b < 0; DROP TABLE t15; SET SQL_MODE=default;

2. What did you expect to see? (Required)

mysql> SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; CREATE TABLE t15 (a INT SIGNED, b INT UNSIGNED); INSERT INTO t15 VALUES (10, 20); SELECT * FROM t15 WHERE a - b < 0; DROP TABLE t15; SET SQL_MODE=default;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.06 sec)

Query OK, 1 row affected (0.01 sec)

+------+------+
| a    | b    |
+------+------+
|   10 |   20 |
+------+------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.02 sec)

Query OK, 0 rows affected (0.00 sec)

3. What did you see instead (Required)


mysql> SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; CREATE TABLE t15 (a INT SIGNED, b INT UNSIGNED); INSERT INTO t15 VALUES (10, 20); SELECT * FROM t15 WHERE a - b < 0; DROP TABLE t15; SET SQL_MODE=default;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.06 sec)

Query OK, 1 row affected (0.01 sec)

ERROR 1690 (22003): BIGINT value is out of range in '(10 - 20)'
Query OK, 0 rows affected (0.07 sec)

Query OK, 0 rows affected (0.00 sec)

4. What is your TiDB version? (Required)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions