-
-
Notifications
You must be signed in to change notification settings - Fork 499
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
Default constraint symbol value is not same as MySQL, lead to replication breaks #7650
Comments
Hey, @zing22845 thanks for reporting this issue! We will look into getting our default foreign key name generation to align with MySQL's. In the meantime, you could add a name to foreign key constraints: tmp/main*> create table parent (i int primary key);
tmp/main*> create table child (j int primary key, constraint `fk1` foreign key (j) references parent(i));
tmp/main*> show create table child;
+-------+------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------+
| child | CREATE TABLE `child` ( |
| | `j` int NOT NULL, |
| | PRIMARY KEY (`j`), |
| | CONSTRAINT `fk1` FOREIGN KEY (`j`) REFERENCES `parent` (`i`) |
| | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+-------+------------------------------------------------------------------+
1 row in set (0.00 sec)
tmp/main*> alter table child drop constraint fk1;
tmp/main*> show create table child;
+-------+------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------+
| child | CREATE TABLE `child` ( |
| | `j` int NOT NULL, |
| | PRIMARY KEY (`j`) |
| | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+-------+------------------------------------------------------------------+
1 row in set (0.00 sec) |
Hey, @jycor Thank you so much for taking time to review my issue and providing such a detailed response. I really appreciate your prompt attention and format the output for clarity. |
Hey @zing22845, thanks again for the bug report! We initially strayed away from MySQL's naming convention to avoid issues with merging different foreign keys with the same name. To address the merge issues, we have added new syntax (that isn't part of MySQL) to easily rename foreign key constraints. These changes are all in dolt main, and we'll have a release for you later this week. |
I build a MySQL to Dolt replication, and create a table which has a foreign key with default constraint symbol, then drop the constraint with the default constraint symbol created by MySQL, the replication broken.
MySQL operations:
Dolt
the default constraint name
80hln0fi
is different from the name in MySQL:orders_ibfk_1
and the replication is broken with error, when drop CONSTRAINT is executed:
Last_Error: Error executing query: Constraint "orders_ibfk_1" does not exist
The text was updated successfully, but these errors were encountered: