summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-05-15 11:57:40 +0300
committerunknown <monty@mysql.com>2004-05-15 11:57:40 +0300
commitc9667f114695bbf9dda1548b2c48a44b89c580b0 (patch)
treebc0f1775f58953cbf0e41e15b7cb5874821c8578 /sql
parentdd4be0244d57da44351d6788dc9e29d2bcb60ea3 (diff)
downloadmariadb-git-c9667f114695bbf9dda1548b2c48a44b89c580b0.tar.gz
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()
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_table.cc24
2 files changed, 10 insertions, 16 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 03d67c4f300..f7992c3db9e 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -86,7 +86,7 @@ bool key_part_spec::operator==(const key_part_spec& other) const
/*
- Test if a foreign key is a prefix of the given key
+ Test if a foreign key (= generated key) is a prefix of the given key
(ignoring key name, key type and order of columns)
NOTES:
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 47574eab666..284b228567a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -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;
}