From bf5c050fd28f616d789a02b0fbd6fd8ff53c78d3 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 7 Jun 2021 17:40:30 +0300 Subject: MDEV-25866 Upgrade from pre-10.5.10 to 10.5.10 causes CHECK errors on encrypted Aria tables Hard to do a test case, but tested by hand and verified that mysql_upgrade will update the encrypted MariaDB tables. --- storage/maria/ha_maria.cc | 20 ++++++++++++++++++++ storage/maria/ha_maria.h | 1 + 2 files changed, 21 insertions(+) diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 79d32886659..5bf6754ff9d 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -4198,6 +4198,26 @@ int ha_maria::find_unique_row(uchar *record, uint constrain_no) return rc; } + +/** + Check if a table needs to be repaired +*/ + +int ha_maria::check_for_upgrade(HA_CHECK_OPT *check) +{ + if (table->s->mysql_version && table->s->mysql_version <= 100509 && + (file->s->base.extra_options & MA_EXTRA_OPTIONS_ENCRYPTED)) + { + /* + Encrypted tables before 10.5.9 had a bug where LSN was not + stored on the pages. These must be repaired! + */ + return HA_ADMIN_NEEDS_ALTER; + } + return HA_ADMIN_OK; +} + + struct st_mysql_storage_engine maria_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h index b2c664a072d..6b4302145dd 100644 --- a/storage/maria/ha_maria.h +++ b/storage/maria/ha_maria.h @@ -144,6 +144,7 @@ public: int check(THD * thd, HA_CHECK_OPT * check_opt) override; int analyze(THD * thd, HA_CHECK_OPT * check_opt) override; int repair(THD * thd, HA_CHECK_OPT * check_opt) override; + int check_for_upgrade(HA_CHECK_OPT *check_opt) override; bool check_and_repair(THD * thd) override final; bool is_crashed() const override final; bool is_changed() const; -- cgit v1.2.1