-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generated columns do not wrap unsigned values to signed #21654
Comments
I figured out how to permit the insert and correctly read back the value with:
But there is another bug with generated columns. The value generated is incorrect:
|
I think it's a bug in MySQL: mysql> CREATE TABLE t1 (a BIGINT UNSIGNED NOT NULL, b INT AS (a) NOT NULL);
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO t1 (a) VALUES (9223372036854775808);
ERROR 1264 (22003): Out of range value for column 'b' at row 1 MySQL fails to check the overflow when the generated column is mysql> set sql_mode="";
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO t1 (a) VALUES (9223372036854775808);
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> select * from t1;
+---------------------+------------+
| a | b |
+---------------------+------------+
| 9223372036854775808 | 2147483647 |
+---------------------+------------+
1 row in set (0.00 sec) |
Interesting in MySQL: mysql> CREATE TABLE t2 (a INT UNSIGNED NOT NULL, b INT AS (a) NOT NULL);
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO t2 (a) VALUES (4294967295);
Query OK, 1 row affected (0.01 sec)
mysql> select * from t2;
+------------+----+
| a | b |
+------------+----+
| 4294967295 | -1 |
+------------+----+
1 row in set (0.00 sec)
mysql> INSERT INTO t2 (a) VALUES (4294967296);
ERROR 1264 (22003): Out of range value for column 'a' at row 1 |
Yeah, I think you are right - I will report it as a MySQL bug tomorrow and see what they think. |
@morgo If this is a bug in MySQL, we can close this issue, or remove the bug label and add a compatibility label for it. |
This is filed as https://bugs.mysql.com/bug.php?id=101976 - I will close this issue as soon as the MySQL bug is marked verified. |
Alright, it's been verified as a MySQL bug. Closing this issue. |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: