Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.11, 11.4, 11.6(EOL)
-
None
Description
This script returns an error unexpectedly:
DROP TABLE IF EXISTS t1; |
CREATE TABLE t1 ( |
c1 BIGINT UNSIGNED, |
c2 BIGINT UNSIGNED |
);
|
INSERT INTO t1 VALUES (20030516235329,20000127231341); |
SELECT c2-c1 FROM t1; |
ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(`test`.`t1`.`c2` - `test`.`t1`.`c1`)'
|
It tries to create a BIGIN UNSIGNED column as a result:
DROP TABLE IF EXISTS t2; |
CREATE TABLE t2 AS SELECT c2-c1 FROM t1 LIMIT 0; |
SHOW CREATE TABLE t2; |
+-------+-------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+-------------------------------------------------------------------------------------------------------+
|
| t2 | CREATE TABLE `t2` (
|
`c2-c1` bigint(21) unsigned DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+-------------------------------------------------------------------------------------------------------+
|
The choice beween BIGINT and UNSIGNED BIGINT is controlled by the NO_UNSIGNED_SUBTRACTION flag in sql_mode.
There should probably be a way to create a DECIMAL column instead.
Attachments
Issue Links
- is duplicated by
-
MDEV-23481 BIGINT UNSIGNED value is out of range in '`test`.`edge`.`x1` - 1'
- Closed
- relates to
-
MDEV-5847 MySQL Bug#13596893 - "ERROR 1690 (22003): BIGINT UNSIGNED VALUE IS OUT OF RANGE" ON DATE OPERATION
- Confirmed
-
MDEV-12858 Out-of-range error for CREATE..SELECT unsigned_int_column+1
- Closed
-
MDEV-16196 GREATEST incorrectly checks a fields' datatype during calculations
- Closed