dolthub / go-mysql-server

A MySQL-compatible relational database with a storage agnostic query engine. Implemented in pure Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alter table drop constraint name complains the contraint does not exist

twhiteman opened this issue · comments

I get the following error:
ERROR 1105 (HY000): Constraint "user_id_unique" does not exist

This works against a regular mysql server, but not against GMS (with EnablePrimaryKeyIndexes enabled).

SQL:

CREATE TABLE `user`
(
    `user_id` VARCHAR(10) NOT NULL
);

ALTER TABLE `user` ADD CONSTRAINT `user_id_unique` UNIQUE (`user_id`);

ALTER TABLE `user` DROP CONSTRAINT `user_id_unique`;

I noticed the following differences when performing a show create table:
Mysql:

UNIQUE KEY `user_id_unique` (`user_id`)

GMS:

 UNIQUE KEY `user_id` (`user_id`)

This is also not an issue in Dolt so it has something to do with the way GMS does in memory unique indexes.

Hey @twhiteman, I believe this issue is related: dolthub/dolt#5479
The problem was in our parser, which we fixed in this PR: dolthub/vitess#225

So, I think the updated GMS should handle constraint names correctly now. Lemme know if this resolves your issue.

That was it - nice work! All working great now!