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

Support CHECK constraint #41711

Closed
CbcWestwolf opened this issue Feb 24, 2023 · 5 comments
Closed

Support CHECK constraint #41711

CbcWestwolf opened this issue Feb 24, 2023 · 5 comments
Assignees
Labels
affects-7.2 type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@CbcWestwolf
Copy link
Member

https://dev.mysql.com/doc/refman/8.0/en/create-table-check-constraints.html

@Benjamin2037
Copy link
Collaborator

Do we have same behavior as MySQL on check constraint?

@fzzf678
Copy link
Contributor

fzzf678 commented Jun 26, 2023

Do we have same behavior as MySQL on check constraint?

Mostly same, I will supply unsupported behavior in doc later

@dveeden
Copy link
Contributor

dveeden commented Jul 7, 2023

Looks like this has been implemented in v7.2. Can we close this issue?

mysql> SELECT TIDB_VERSION()\G
*************************** 1. row ***************************
TIDB_VERSION(): Release Version: v7.2.0
Edition: Community
Git Commit Hash: 9fd5f4a8e4f273a60fbe7d3848f85a1be8f0600b
Git Branch: heads/refs/tags/v7.2.0
UTC Build Time: 2023-06-27 15:04:42
GoVersion: go1.20.5
Race Enabled: false
Check Table Before Drop: false
Store: tikv
1 row in set (0.00 sec)

mysql> SET GLOBAL tidb_enable_check_constraint=ON;
Query OK, 0 rows affected (0.04 sec)

mysql> CREATE TABLE t1 (id INT PRIMARY KEY, CHECK (id > 10), CHECK (id < 20));
Query OK, 0 rows affected (0.20 sec)

mysql> INSERT INTO t1 VALUES (1);
ERROR 3819 (HY000): Check constraint 't1_chk_1' is violated.
mysql> INSERT INTO t1 VALUES (15);
Query OK, 1 row affected (0.02 sec)

mysql> INSERT INTO t1 VALUES (25);
ERROR 3819 (HY000): Check constraint 't1_chk_2' is violated.

@CbcWestwolf
Copy link
Member Author

@dveeden Sure!

@shawn0915
Copy link
Contributor

@CbcWestwolf could you help confirm is that a bug? #47567

@dveeden dveeden assigned fzzf678 and unassigned fzzf678 Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.2 type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants