Skip to content
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 column is not compatible with mysql #40066

Closed
xiongjiwei opened this issue Dec 20, 2022 · 1 comment · Fixed by #40157
Closed

generated column is not compatible with mysql #40066

xiongjiwei opened this issue Dec 20, 2022 · 1 comment · Fixed by #40157
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@xiongjiwei
Copy link
Contributor

xiongjiwei commented Dec 20, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> CREATE TABLE table_name (
    ->     column1 INT,
    ->     column2 INT UNSIGNED GENERATED ALWAYS AS (column1 - 100)
    -> );
mysql> insert into table_name(column1) values (99);
ERROR 1690 (22003): constant -1 overflows int
mysql> set @@sql_mode='';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into table_name(column1) values (99);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from table_name;
+---------+------------+
| column1 | column2    |
+---------+------------+
|     101 |          1 |
|      99 | 4294967295 |
+---------+------------+
2 rows in set, 1 warning (0.00 sec)

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

mysql> CREATE TABLE table_name (
    ->     column1 INT,
    ->     column2 INT UNSIGNED GENERATED ALWAYS AS (column1 - 100)
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> insert into table_name(column1) values (101);
Query OK, 1 row affected (0.00 sec)

mysql> insert into table_name(column1) values (99);
ERROR 1264 (22003): Out of range value for column 'column2' at row 1
mysql> set @@sql_mode='';
Query OK, 0 rows affected (0.01 sec)

mysql> insert into table_name(column1) values (99);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+--------------------------------------------------+
| Level   | Code | Message                                          |
+---------+------+--------------------------------------------------+
| Warning | 1264 | Out of range value for column 'column2' at row 1 |
+---------+------+--------------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from t;
Empty set (0.00 sec)

mysql> select * from table_name;
+---------+---------+
| column1 | column2 |
+---------+---------+
|     101 |       1 |
|      99 |       0 |
+---------+---------+
2 rows in set (0.00 sec)

as you can see there are 2 issues

  1. error message is not the same
  2. the query result is different

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

@xiongjiwei xiongjiwei added the type/bug The issue is confirmed as a bug. label Dec 20, 2022
@xiongjiwei xiongjiwei changed the title generate column is not compatible with mysql generated column is not compatible with mysql Dec 20, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 labels Dec 20, 2022
@jiyfhust
Copy link
Contributor

/assign

@ChenPeng2013 ChenPeng2013 added affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 labels Jan 10, 2023
@ti-chi-bot ti-chi-bot removed the may-affects-5.2 This bug maybe affects 5.2.x versions. label Jan 10, 2023
@ti-chi-bot ti-chi-bot removed may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-6.0 may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 labels Jan 10, 2023
@mjonss mjonss added affects-4.0 This bug affects 4.0.x versions. and removed may-affects-4.0 This bug maybe affects 4.0.x versions. labels Jan 11, 2023
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this issue Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
7 participants