Description:
mysql> create table sb(a bigint unsigned);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into sb values(~1);
Query OK, 1 row affected (0.00 sec)
mysql> select -a from sb;
ERROR 1690 (22003): BIGINT value is out of range in '-(`test`.`sb`.`a`)'
mysql> drop table sb;
Query OK, 1 row affected (0.00 sec)
mysql> create table sb(a int);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into sb values(1);
Query OK, 1 row affected (0.00 sec)
mysql> select -(~a) from sb;
ERROR 1690 (22003): BIGINT value is out of range in '-(~(`test`.`sb`.`a`))'
but, when we type this
mysql> select -~1;
we get :
+-----------------------+
| -~1 |
+-----------------------+
| -18446744073709551614 |
+-----------------------+
1 row in set (0.00 sec)
How to repeat:
drop table if exists sb;
create table sb(a bigint unsigned);
insert into sb values(~1);
select -a from sb;
drop table if exists sb;
create table sb(a int);
insert into sb values(1);
select -(~a) from sb;
select -(~1);
Suggested fix:
select -(~1) failed with ERROR 1690
or
select -(~a) from sb; successed