`ALTER TABLE ... PARTITION BY ...` should avoid foreign key in table
Open
found-by-ai
severity/moderate
sig/sql-infra
type/bug
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```sql
CREATE TABLE parent (id INT PRIMARY KEY);
CREATE TABLE child (pid INT, FOREIGN KEY (pid) REFERENCES parent(id));
ALTER TABLE parent PARTITION BY HASH(id) PARTITIONS 4; -- Success
INSERT INTO parent VALUES (1);
INSERT INTO child VALUES (1); -- ERROR 1452(no referenced row)
```
### 2. What did you expect to see? (Required)
Return `ErrForeignKeyOnPartitioned`.
### 3. What did you see instead (Required)
The DDL `ALTER TABLE parent PARTITION BY HASH(id) PARTITIONS 4` succeed.
### 4. What is your TiDB version? (Required)
Contributor guide
Assessment
This issue has not been assessed yet.