* Dmitry Lenev <dlenev@stripped> [08/06/24 15:48]:
> 2675 Dmitry Lenev 2008-06-24
> Fix for #35532 "Foreign keys: errors with automatic constraint
> names".
>
> Name conflict occured and apropriate error was emitted when one
> tried to perform thousands of add/drop foreign key operations
> without specifying explicit foreign key names on the same table
> or used explicit foreign key names in the same name-space as
> automatically generated foreign key names.
>
> This problem is caused by the fact that our current approach
> to generating unique names for foreign keys without explicit
> names relies on using table name prefix, connection id and
> value from pseudo-random generator and that we do not try
> to generate another name when we find out our generated name
> is already occupied.
>
> Since we can't easily implement retry logic due to current
> limitations of metadata locking protocol we try to alleviate
> this problem by increasing range for the random component of
> the name by 3 orders. Also we have switched to base-36 system
> for encoding of this component to keep generated names
> shorter and got rid of connection id component in the names
> (the latter didn't help too much and complicated code/tests).
>
> This patch also ensures that generated name always stays
> within NAME_CHAR_LEN character limit (otherwise such names
> are going to be truncated in I_S table and we won't be able
> to restore them from mysqldump dumps).
The patch is OK to push.
--