summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 2e475404da2..e074b46f52f 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4699,6 +4699,35 @@ int handler::check_collation_compatibility()
}
+int handler::check_long_hash_compatibility() const
+{
+ if (!table->s->old_long_hash_function())
+ return 0;
+ KEY *key= table->key_info;
+ KEY *key_end= key + table->s->keys;
+ for ( ; key < key_end; key++)
+ {
+ if (key->algorithm == HA_KEY_ALG_LONG_HASH)
+ {
+ /*
+ The old (pre-MDEV-27653) hash function was wrong.
+ So the long hash unique constraint can have some
+ duplicate records. REPAIR TABLE can't fix this,
+ it will fail on a duplicate key error.
+ Only "ALTER IGNORE TABLE .. FORCE" can fix this.
+ So we need to return HA_ADMIN_NEEDS_ALTER here,
+ (not HA_ADMIN_NEEDS_UPGRADE which is used elsewhere),
+ to properly send the error message text corresponding
+ to ER_TABLE_NEEDS_REBUILD (rather than to ER_TABLE_NEEDS_UPGRADE)
+ to the user.
+ */
+ return HA_ADMIN_NEEDS_ALTER;
+ }
+ }
+ return 0;
+}
+
+
int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt)
{
int error;
@@ -4736,6 +4765,9 @@ int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt)
if (unlikely((error= check_collation_compatibility())))
return error;
+
+ if (unlikely((error= check_long_hash_compatibility())))
+ return error;
return check_for_upgrade(check_opt);
}