← Back to team overview

maria-developers team mailing list archive

Re: [Commits] Rev 3966: MDEV-4439 ALTER TABLE .. [ADD|DROP] FOREIGN KEY IF [NOT] EXISTS does not work if constraint name is not used. in file:///home/hf/wmar/10-hf/

 

Hi, Jan!

> How you would detect the difference between no object name given and
> object name given, remember that InnoDB does not store the key
> identifier (a and b above). Thus the actual foreign key name is
> similar to one generated when no key identifier is not given ?
> E.g:
> 
> alter table t2 add foreign key if not exists (id) references t1 (id);
> alter table t2 add foreign key if not exists a(id) references t1(id);
> alter table t2 add foreign key if not exists b(id) references t1(id);
> 
> For InnoDB point of view there are all similar foreign keys but all have 
> different object name and all actual names are generated
> on the engine.

Hmm. I didn't know that, I thought InnoDB only generates a name when no
was explicitly given by the user.

What names will be shown in SHOW CREATE TABLE and various I_S tables?
I mean, "a" and "b" or generated ones?

Regards,
Sergei



References