matrixorigin / matrixorigin/matrixone

[Bug]: ALTER TABLE ADD/DROP CHECK is not compatible with MySQL

Open
#25,387 1 comment 0 reactions 1 assignee Claimed by @aptend View on GitHub
kind/bug needs-triage
Dominant language
Go
Stars
1.9k
Forks
311
Avg merge
1d 3h
Merged PRs (30d)
768

Description

### Is there an existing issue for the same bug?

- [X] I have checked the existing issues.

### Branch Name

main

### Commit ID

51656deb6

### Other Environment Information

```Markdown
- MO version: 8.0.30-MatrixOne-v
- MySQL version: 8.0.45
- Verify date: 2026-07-02
```

### Actual Behavior

`ALTER TABLE ... ADD CHECK` and `ALTER TABLE ... DROP CHECK` are not compatible with MySQL.

MatrixOne rejects adding a CHECK constraint through `ALTER TABLE`, and rejects `DROP CHECK` syntax. Because the constraint is not added, a row that MySQL rejects is accepted.

MO errors:

```text
ERROR 20101 (HY000): internal error: unsupported alter option in inplace mode: check (v > 0)
ERROR 1064 (HY000): SQL parser error ... near " check chk_v_pos"
```

### Expected Behavior

MySQL accepts `ALTER TABLE ... ADD CONSTRAINT ... CHECK (...)`, enforces the constraint, and accepts `ALTER TABLE ... DROP CHECK ...`.

### Steps to Reproduce

```sql
drop database if exists mysql_compat_model11_min2;
create database mysql_compat_model11_min2;
use mysql_compat_model11_min2;

create table t_check (id int primary key, v int);
alter table t_check add constraint chk_v_pos check (v > 0);
insert into t_check values (1, 1);
insert into t_check values (2, -1);
select * from t_check order by id;
alter table t_check drop check chk_v_pos;
insert into t_check values (3, -1);
select * from t_check order by id;
```

MySQL 8.0.45:

```text
ERROR 3819 (HY000): Check constraint 'chk_v_pos' is violated.

id v
1 1

id v
1 1
3 -1
```

MatrixOne main `51656deb6`:

```text
ERROR 20101 (HY000): unsupported alter option in inplace mode: check (v > 0)
ERROR 1064 (HY000): syntax error near " check chk_v_pos"

id v
1 1
2 -1

id v
1 1
2 -1
3 -1
```

### Additional information

This is separate from the existing CREATE TABLE CHECK enforcement issue because this one covers the ALTER TABLE ADD/DROP CHECK DDL path.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.