-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Open
Labels
affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.component/ddlThis issue is related to DDL of TiDB.This issue is related to DDL of TiDB.severity/majortype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
set global tidb_enable_check_constraint = 'ON';
CREATE TABLE t1 (CHECK (c1 <> c2), c1 INT CHECK (c1 > 10), c2 INT CONSTRAINT c2_positive_for_t1 CHECK (c2 > 0));
set global tidb_enable_check_constraint = 'OFF';
alter table t1 drop check c2_positive_for_t1;
It'll return a warning and don't actually drop the check constraint.
To avoid X-Y problem, let me describe why we might need to drop without enabling tidb_enable_check_constraint:
If a cluster creates constraints with the same name in a single database before #48062 is introduced, and upgrade to a newer version with #48062, it will fail to backup/restore. The restore will produce an error: Duplicate check constraint name ....
I have two proposal / options for this issue:
- Modify the DDL to allow drop check even when
tidb_enable_check_constraintis off. - Modify the BR to automatically clean up the check constraints when
tidb_enable_check_constraintis off. It sounds weird but the behavior is the same withCREATE TABLEDDL SQL.
I personally prefer the first one, but not sure.
2. What did you expect to see? (Required)
The constraint is dropped.
3. What did you see instead (Required)
It's not dropped and a warning is returned.
4. What is your TiDB version? (Required)
Metadata
Metadata
Assignees
Labels
affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.component/ddlThis issue is related to DDL of TiDB.This issue is related to DDL of TiDB.severity/majortype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.