← Back to team overview

maria-developers team mailing list archive

Re: 43296f4: MDEV-17599 ALTER TABLE DROP CONSTRAINT does not work for foreign keys.

 

Hi, Alexey!

On Jan 31, Alexey Botchkov wrote:
> >  can a CHECK constraint have the same name as an existing FK?
> 
> Yes, it can.
> So in this case the 'ALTER ... DROP CONSTRAINT c' drops the FOREIGN KEY. On
> the second call this ALTER
> removes the CHECK.
> How do you like that?
> I think it's ok as the very idea of same names for constraints seems sick.

Let's handle it separately. Could you please report it as a bug?
A table shouldn't have two constraints with the same name.

> > what about UNIQUE constraint?
> 
> The 'ALTER TABLE ADD CONSTRAINT UNIQUE unique_key' just adds UNIQUE
> key.  So i'm in doubt how we should handle the 'DROP CONSTRAINT
> unique_key' statement.

By dropping the unique key, why, is there another option?
UNIQUE index is a constraint, not just an optimization helper, like a
non-unique index.

You already have a loop over all drop constraints, checking for unique
shouldn't be a problem. It should drop PRIMARY KEY too, I suppose. We
allow ADD CONSTRAINT PRIMARY KEY.

Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx


References