1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Better fix for bug #3749 (bug in deleting automatic generated foreign keys)

mysql-test/r/func_encrypt.result:
  Update tests (left after sanjas last push)
mysql-test/r/innodb.result:
  Added test for bug #3749 (bug in deleting automatic generated foreign keys)
mysql-test/t/innodb.test:
  Added test for bug #3749 (bug in deleting automatic generated foreign keys)
sql/sql_class.cc:
  Updated comment
tests/client_test.c:
  Added missing mysql_stmt_close()
This commit is contained in:
unknown
2004-05-15 11:57:40 +03:00
parent dd4be0244d
commit c9667f1146
6 changed files with 54 additions and 20 deletions

View File

@@ -684,11 +684,13 @@ 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.
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)))
if ((key2->type != Key::FOREIGN_KEY &&
key2->name != ignore_key &&
!foreign_key_prefix(key, key2)))
{
/* TO DO: issue warning message */
/* mark that the generated key should be ignored */
@@ -698,17 +700,9 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
key->name= ignore_key;
else
{
/*
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)--;
}
key2->name= ignore_key;
key_parts-= key2->columns.elements;
(*key_count)--;
}
break;
}