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

Change column type NOT NULL does not respect strict mode disabled #31428

Open
espresso98 opened this issue Jan 6, 2022 · 0 comments
Open

Change column type NOT NULL does not respect strict mode disabled #31428

espresso98 opened this issue Jan 6, 2022 · 0 comments
Assignees
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@espresso98
Copy link
Collaborator

Bug Report

When strict mode disabled, TiDB return an error while MySQL gives a warning.

1. Minimal reproduce step

CREATE TABLE t1 (a INT) ENGINE = InnoDB;
INSERT INTO t1 VALUES (1),(NULL),(2);
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
ALTER TABLE t1 CHANGE a a INT NOT NULL;
SELECT * FROM t1;
DROP TABLE t1;

2. What did you expect to see?

In MySQL

mysql> SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)

mysql> ALTER TABLE t1 CHANGE a a INT NOT NULL;
Query OK, 3 rows affected, 1 warning (0.04 sec)
Records: 3  Duplicates: 0  Warnings: 1

mysql> SELECT * FROM t1;
+---+
| a |
+---+
| 1 |
| 0 |
| 2 |
+---+
3 rows in set (0.00 sec)

mysql> SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'a' at row 2 |
+---------+------+----------------------------------------+
1 row in set (0.00 sec)

3. What did you see instead

In TiDB

mysql> SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)

mysql> ALTER TABLE t1 CHANGE a a INT NOT NULL;
ERROR 1265 (01000): Data truncated for column 'a' at row 1
mysql> SELECT * FROM t1;
+------+
| a    |
+------+
|    1 |
| NULL |
|    2 |
+------+
3 rows in set (0.00 sec)

4. What is your TiDB version?

tidb_version(): Release Version: v5.5.0-alpha-34-g9cc1b169f
Edition: Community
Git Commit Hash: 9cc1b169f9080b34eda8468d7a974d2a387673dd
Git Branch: master
UTC Build Time: 2022-01-05 19:21:07
GoVersion: go1.17.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@espresso98 espresso98 added the type/bug The issue is confirmed as a bug. label Jan 6, 2022
@morgo morgo changed the title TiDB does not support strict mode disabled correctly Change column type NOT NULL does not respect strict mode disabled Jan 6, 2022
@tiancaiamao tiancaiamao added the sig/sql-infra SIG: SQL Infra label Jan 7, 2022
@djshow832 djshow832 added the affects-5.4 This bug affects the 5.4.x(LTS) versions. label Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

7 participants