Skip to content

Fail to alter integer column with a foreign key #47702

@YangKeao

Description

@YangKeao

Bug Report

1. Minimal reproduce step (Required)

mysql> create table parent(id bigint(10) key);
Query OK, 0 rows affected (0.05 sec)

mysql> create table child(pid bigint(20), foreign key (pid) references parent(id));
Query OK, 0 rows affected (0.03 sec)

mysql> alter table child modify column pid bigint(1);
ERROR 1832 (HY000): Cannot change column 'pid': used in a foreign key constraint 'fk_1'

2. What did you expect to see? (Required)

mysql> create table parent(id bigint(10) key);
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> create table child(pid bigint(20), foreign key (pid) references parent(id));
Query OK, 0 rows affected, 1 warning (0.02 sec)

mysql> alter table child modify column pid bigint(1);
Query OK, 0 rows affected, 1 warning (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 1

3. What did you see instead (Required)

TiDB failed to alter table.

4. What is your TiDB version? (Required)

master 2482a6e

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions