summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2023-02-15 16:30:53 +0100
committerSergei Golubchik <serg@mariadb.org>2023-02-15 16:30:53 +0100
commitb45ed284a69cdbffac61bdcf74bf86fa7b7391a4 (patch)
treede26ce8e0a5aa40889e889d758e3a3a98b9f71a8 /sql/handler.cc
parentcc182aca9352fb7efde0deb0a83844e1d5f0c64c (diff)
parentcafba8761af55ae16cc69c9b53a341340a845b36 (diff)
downloadmariadb-git-bb-11.0-all-builders.tar.gz
Merge branch '10.11' into 11.0bb-11.0-all-builders
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 5884339c809..1a4cc630a37 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4848,6 +4848,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;
@@ -4885,6 +4914,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);
}