summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorunknown <marko@hundin.mysql.fi>2004-04-21 13:15:43 +0300
committerunknown <marko@hundin.mysql.fi>2004-04-21 13:15:43 +0300
commitc9e1538298ccfc2172d4db06df54f0f321b7db09 (patch)
treeae59a3c9912d8e259bde8cadb1f3c324bda1e419 /sql/sql_class.cc
parentfd6ae5aa21906a221caf8fd34aabbaee1ef6a447 (diff)
downloadmariadb-git-c9e1538298ccfc2172d4db06df54f0f321b7db09.tar.gz
Introduce keys in child tables corresponding to FOREIGN KEYs
Remove redundant keys in CREATE TABLE and ALTER TABLE mysql-test/r/constraints.result: Remove redundant keys mysql-test/r/create.result: Remove redundant keys mysql-test/r/innodb.result: Remove redundant keys mysql-test/r/range.result: Remove redundant keys mysql-test/t/range.test: Remove redundant keys sql/sql_class.cc: Equality comparison of keys (ignoring name) sql/sql_class.h: Equality comparison of keys (ignoring name) sql/sql_table.cc: Remove redundant keys sql/sql_yacc.yy: Introduce keys in child tables corresponding to FOREIGN KEYs
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 1b4c8bec416..f297ddf2917 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -79,6 +79,34 @@ extern "C" void free_user_var(user_var_entry *entry)
}
+bool key_part_spec::operator==(const key_part_spec& other) const
+{
+ return length == other.length && !strcmp(field_name, other.field_name);
+}
+
+/* Equality comparison of keys (ignoring name) */
+bool Key::operator==(Key& other)
+{
+ if (type == other.type &&
+ algorithm == other.algorithm &&
+ columns.elements == other.columns.elements)
+ {
+ List_iterator<key_part_spec> col_it1(columns);
+ List_iterator<key_part_spec> col_it2(other.columns);
+ const key_part_spec *col1, *col2;
+ while ((col1 = col_it1++))
+ {
+ col2 = col_it2++;
+ DBUG_ASSERT(col2 != NULL);
+ if (!(*col1 == *col2))
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+
/****************************************************************************
** Thread specific functions
****************************************************************************/