summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2023-01-31 09:31:42 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2023-01-31 09:31:42 +0100
commitc3a5cf2b5bb0c0e1623a0ddc8e3d49557f35e800 (patch)
tree0e47046f09c1ad4a4223e45d7ac2c41406272b92 /sql/handler.cc
parent81196469bbc6b8424c97a378e5fc5b16d40b43b5 (diff)
parentf8a85af8ca1c937b8d4f847477bd282f80251cde (diff)
downloadmariadb-git-c3a5cf2b5bb0c0e1623a0ddc8e3d49557f35e800.tar.gz
Merge branch '10.5' into 10.6
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 d88e5f06425..7e42f814cb7 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4698,6 +4698,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;
@@ -4735,6 +4764,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);
}