Check constraints missing from information_schema.table_constraints
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
The check constraints are not listed in `information_schema.table_constraints` making it hard to link constraints to tables.
### 1. Minimal reproduce step (Required)
For TiDB: Enable check constraints first via `set global tidb_enable_check_constraint=on`.
```sql
create table t1 (id int primary key, check (id>10));
select * from information_schema.check_constraints where constraint_schema='test';
select * from information_schema.table_constraints where table_schema='test';
```
### 2. What did you expect to see? (Required)
MySQL:
```
mysql-9.4.0> create table t1 (id int primary key, check (id>10));
Query OK, 0 rows affected (0.029 sec)
mysql-9.4.0> select * from information_schema.check_constraints where constraint_schema='test';
+--------------------+-------------------+-----------------+--------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | CHECK_CLAUSE |
+--------------------+-------------------+-----------------+--------------+
| def | test | t1_chk_1 | (`id` > 10) |
+--------------------+-------------------+-----------------+--------------+
1 row in set (0.001 sec)
mysql-9.4.0> select * from information_schema.table_constraints where table_schema='test';
+--------------------+-------------------+-----------------+--------------+------------+-----------------+----------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | TABLE_SCHEMA | TABLE_NAME | CONSTRAINT_TYPE | ENFORCED |
+--------------------+-------------------+-----------------+--------------+------------+-----------------+----------+
| def | test | PRIMARY | test | t1 | PRIMARY KEY | YES |
| def | test | t1_chk_1 | test | t1 | CHECK | YES |
+--------------------+-------------------+-----------------+--------------+------------+-----------------+----------+
2 rows in set (0.002 sec)
```
### 3. What did you see instead (Required)
```
mysql-8.0.11-TiDB-v8.5.3> create table t1 (id int primary key, check (id>10));
Query OK, 0 rows affected (0.091 sec)
mysql-8.0.11-TiDB-v8.5.3> select * from information_schema.check_constraints where constraint_schema='test';
+--------------------+-------------------+-----------------+--------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | CHECK_CLAUSE |
+--------------------+-------------------+-----------------+--------------+
| def | test | t1_chk_1 | (`id` > 10) |
+--------------------+-------------------+-----------------+--------------+
1 row in set (0.004 sec)
mysql-8.0.11-TiDB-v8.5.3> select * from information_schema.table_constraints where table_schema='test';
+--------------------+-------------------+-----------------+--------------+------------+-----------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | TABLE_SCHEMA | TABLE_NAME | CONSTRAINT_TYPE |
+--------------------+-------------------+-----------------+--------------+------------+-----------------+
| def | test | PRIMARY | test | t1 | PRIMARY KEY |
+--------------------+-------------------+-----------------+--------------+------------+-----------------+
1 row in set (0.004 sec)
```
### 4. What is your TiDB version? (Required)
```
Release Version: v8.5.3
Edition: Community
Git Commit Hash: dc2548aac79a712265e831cff2a3a896bc0a5a38
Git Branch: HEAD
UTC Build Time: 2025-07-31 13:54:43
GoVersion: go1.23.8
Race Enabled: false
Check Table Before Drop: false
Store: tikv
```
Contributor guide
Assessment
This issue has not been assessed yet.