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)
We only compare field names
RETURN
0 Generated key is a prefix of other key
1 Not equal
true Generated key is a prefix of other key
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 */
if (a->generated)
......@@ -228,13 +228,13 @@ bool foreign_key_prefix(Key *a, Key *b)
else
{
if (!b->generated)
return TRUE; // No foreign key
return false; // No foreign key
swap_variables(Key*, a, b); // Put generated key in 'a'
}
/* Test if 'a' is a prefix of 'b' */
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_it2(b->columns);
......@@ -254,17 +254,17 @@ bool foreign_key_prefix(Key *a, Key *b)
}
}
if (!found)
return TRUE; // Error
return false; // Error
}
return FALSE; // Is prefix
return true; // Is prefix
#else
while ((col1= col_it1++))
{
col2= col_it2++;
if (!(*col1 == *col2))
return TRUE;
return false;
}
return FALSE; // Is prefix
return true; // Is prefix
#endif
}
......
......@@ -446,7 +446,7 @@ class Key :public Sql_alloc, public DDL_options {
Key(const Key &rhs, MEM_ROOT *mem_root);
virtual ~Key() = default;
/* 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
@sa comment for Key_part_spec::clone
......
......@@ -3835,13 +3835,12 @@ mysql_prepare_create_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.
is_foreign_key_prefix(key, key2) returns true 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 &&
key2->name.str != ignore_key &&
!foreign_key_prefix(key, key2)))
if (key2->type != Key::FOREIGN_KEY && key2->name.str != ignore_key &&
is_foreign_key_prefix(key, key2))
{
/* mark that the generated key should be ignored */
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