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

The phenomenon of executing DML after setting 'sql_mode' to non 'strict_mode' in tidb is not as expected #56381

Closed
BrianLiu955 opened this issue Sep 27, 2024 · 1 comment · Fixed by #55477
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@BrianLiu955
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t1(id int primary key,name varchar(20) not null);
Query OK, 0 rows affected (0.05 sec)

mysql> insert into t1 values(1,null);
ERROR 1048 (23000): Column 'name' cannot be null
mysql>
mysql> set session sql_mode = "";
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values(1,null);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+------------------------------+
| Level | Code | Message |
+---------+------+------------------------------+
| Warning | 1048 | Column 'name' cannot be null |
+---------+------+------------------------------+
1 row in set (0.00 sec)

mysql> select * from t1;
+----+------+
| id | name |
+----+------+
| 1 | |
+----+------+
1 row in set (0.01 sec)

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

mysql> insert into t1 values(1,null);
ERROR 1048 (23000): Column 'name' cannot be null

3. What did you see instead (Required)

mysql> insert into t1 values(1,null);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+------------------------------+
| Level | Code | Message |
+---------+------+------------------------------+
| Warning | 1048 | Column 'name' cannot be null |
+---------+------+------------------------------+
1 row in set (0.00 sec)

mysql> select * from t1;
+----+------+
| id | name |
+----+------+
| 1 | |
+----+------+
1 row in set (0.01 sec)

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.4.0-alpha-290-gf2ed822
Edition: Community
Git Commit Hash: f2ed822
Git Branch: HEAD
UTC Build Time: 2024-09-27 01:14:04
GoVersion: go1.21.13
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

@BrianLiu955 BrianLiu955 added the type/bug The issue is confirmed as a bug. label Sep 27, 2024
@BrianLiu955 BrianLiu955 changed the title The phenomenon of executing DML after setting 'sql_made' to non 'strict_made' in tidb is not as expected The phenomenon of executing DML after setting 'sql_mode' to non 'strict_mode' in tidb is not as expected Sep 27, 2024
@YangKeao
Copy link
Member

When the SQL_MODE is not strict, and the column doesn't have a default value, TiDB shouldn't allow to insert NULL values into this column.

This bug is introduced by #21237

@YangKeao YangKeao added affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. labels Sep 27, 2024
@ti-chi-bot ti-chi-bot bot added the affects-8.5 This bug affects the 8.5.x(LTS) versions. label Nov 1, 2024
@ti-chi-bot ti-chi-bot bot closed this as completed in 91beef4 Nov 19, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this issue Nov 20, 2024
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.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
2 participants