Commit 383baa81 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: invert return code

parent 010f535b
...@@ -213,11 +213,11 @@ Foreign_key::Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root) ...@@ -213,11 +213,11 @@ Foreign_key::Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root)
We only compare field names We only compare field names
RETURN RETURN
0 Generated key is a prefix of other key true Generated key is a prefix of other key
1 Not equal false Not a prefix
*/ */
bool foreign_key_prefix(Key *a, Key *b) bool is_foreign_key_prefix(Key *a, Key *b)
{ {
/* Ensure that 'a' is the generated key */ /* Ensure that 'a' is the generated key */
if (a->generated) if (a->generated)
...@@ -228,13 +228,13 @@ bool foreign_key_prefix(Key *a, Key *b) ...@@ -228,13 +228,13 @@ bool foreign_key_prefix(Key *a, Key *b)
else else
{ {
if (!b->generated) if (!b->generated)
return TRUE; // No foreign key return false; // No foreign key
swap_variables(Key*, a, b); // Put generated key in 'a' swap_variables(Key*, a, b); // Put generated key in 'a'
} }
/* Test if 'a' is a prefix of 'b' */ /* Test if 'a' is a prefix of 'b' */
if (a->columns.elements > b->columns.elements) if (a->columns.elements > b->columns.elements)
return TRUE; // Can't be prefix return false; // Can't be prefix
List_iterator<Key_part_spec> col_it1(a->columns); List_iterator<Key_part_spec> col_it1(a->columns);
List_iterator<Key_part_spec> col_it2(b->columns); List_iterator<Key_part_spec> col_it2(b->columns);
...@@ -254,17 +254,17 @@ bool foreign_key_prefix(Key *a, Key *b) ...@@ -254,17 +254,17 @@ bool foreign_key_prefix(Key *a, Key *b)
} }
} }
if (!found) if (!found)
return TRUE; // Error return false; // Error
} }
return FALSE; // Is prefix return true; // Is prefix
#else #else
while ((col1= col_it1++)) while ((col1= col_it1++))
{ {
col2= col_it2++; col2= col_it2++;
if (!(*col1 == *col2)) if (!(*col1 == *col2))
return TRUE; return false;
} }
return FALSE; // Is prefix return true; // Is prefix
#endif #endif
} }
......
...@@ -446,7 +446,7 @@ class Key :public Sql_alloc, public DDL_options { ...@@ -446,7 +446,7 @@ class Key :public Sql_alloc, public DDL_options {
Key(const Key &rhs, MEM_ROOT *mem_root); Key(const Key &rhs, MEM_ROOT *mem_root);
virtual ~Key() = default; virtual ~Key() = default;
/* Equality comparison of keys (ignoring name) */ /* Equality comparison of keys (ignoring name) */
friend bool foreign_key_prefix(Key *a, Key *b); friend bool is_foreign_key_prefix(Key *a, Key *b);
/** /**
Used to make a clone of this object for ALTER/CREATE TABLE Used to make a clone of this object for ALTER/CREATE TABLE
@sa comment for Key_part_spec::clone @sa comment for Key_part_spec::clone
......
...@@ -3835,13 +3835,12 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, ...@@ -3835,13 +3835,12 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
while ((key2 = key_iterator2++) != key) while ((key2 = key_iterator2++) != key)
{ {
/* /*
foreign_key_prefix(key, key2) returns 0 if key or key2, or both, is is_foreign_key_prefix(key, key2) returns true if key or key2, or
'generated', and a generated key is a prefix of the other key. both, is 'generated', and a generated key is a prefix of the other
Then we do not need the generated shorter key. key. Then we do not need the generated shorter key.
*/ */
if ((key2->type != Key::FOREIGN_KEY && if (key2->type != Key::FOREIGN_KEY && key2->name.str != ignore_key &&
key2->name.str != ignore_key && is_foreign_key_prefix(key, key2))
!foreign_key_prefix(key, key2)))
{ {
/* mark that the generated key should be ignored */ /* mark that the generated key should be ignored */
if (!key2->generated || if (!key2->generated ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment