1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

sql_table.cc:

Fix bug #3749: if there were several indexs that made an automatically generated FOREIGN KEY index redundant, then MySQL miscalculated the number of keys, and the AUTO_INCREMENT flag was forgotten by MySQL from a PRIMARY KEY. There were probably a multitude of other errors caused by this.


sql/sql_table.cc:
  Fix bug #3749: if there were several indexs that made an automatically generated FOREIGN KEY index redundant, then MySQL miscalculated the number of keys, and the AUTO_INCREMENT flag was forgotten by MySQL from a PRIMARY KEY. There were probably a multitude of other errors caused by this.
This commit is contained in:
unknown
2004-05-14 09:02:06 +03:00
parent 65755a9cb7
commit 6f0946d6dd

View File

@@ -683,6 +683,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{
while ((key2 = key_iterator2++) != key)
{
/*
foreign_key_prefix(key, key2) returns 0 if key or key2, or both, is
'generated', and a generated key is a prefix of the other key. Then we
do not need the generated shorter key.
*/
if ((key2->type != Key::FOREIGN_KEY && !foreign_key_prefix(key, key2)))
{
/* TO DO: issue warning message */
@@ -693,10 +698,17 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
key->name= ignore_key;
else
{
/* Remove the previous, generated key */
key2->name= ignore_key;
key_parts-= key2->columns.elements;
(*key_count)--;
/*
Remove the previous, generated key if it has not yet been
removed. Note that if we have several identical generated keys,
the last one will remain and others get removed here.
*/
if (key2->name != ignore_key)
{
key2->name= ignore_key;
key_parts-= key2->columns.elements;
(*key_count)--;
}
}
break;
}