summaryrefslogtreecommitdiff
path: root/scripts/mysql_system_tables_fix.sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-08-05 14:39:00 +0200
committerSergei Golubchik <sergii@pisem.net>2014-08-05 14:39:00 +0200
commit053d5edbdc29dfa211324bc6f43079bfebc4023e (patch)
tree906066f77cd3cbe0445a468750a181725150f062 /scripts/mysql_system_tables_fix.sql
parentaafe43b7e049b1537e63eef6509c8a8075533b0e (diff)
downloadmariadb-git-053d5edbdc29dfa211324bc6f43079bfebc4023e.tar.gz
MDEV-5151 mysql_upgrade does not fix "last_update" in "mysql.innodb_table_stats"
fix_privilege_tables: use ALTER TABLE to fix last_update column in innodb stat tables
Diffstat (limited to 'scripts/mysql_system_tables_fix.sql')
-rw-r--r--scripts/mysql_system_tables_fix.sql10
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql
index 383a534416d..49a9062e13e 100644
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -648,6 +648,16 @@ DROP TABLE tmp_proxies_priv;
# Convering the host name to lower case for existing users
UPDATE user SET host=LOWER( host ) WHERE LOWER( host ) <> host;
+# update timestamp fields in the innodb stat tables
+set @str="alter table mysql.innodb_index_stats modify last_update timestamp not null default current_timestamp on update current_timestamp";
+set @str=if(@have_innodb <> 0, @str, "set @dummy = 0");
+prepare stmt from @str;
+execute stmt;
+
+set @str=replace(@str, "innodb_index_stats", "innodb_table_stats");
+prepare stmt from @str;
+execute stmt;
+
SET @innodb_index_stats_fk= (select count(*) from information_schema.referential_constraints where constraint_schema='mysql' and table_name = 'innodb_index_stats' and referenced_table_name = 'innodb_table_stats' and constraint_name = 'innodb_index_stats_ibfk_1');
SET @str=IF(@innodb_index_stats_fk > 0 and @have_innodb > 0, "ALTER TABLE mysql.innodb_index_stats DROP FOREIGN KEY `innodb_index_stats_ibfk_1`", "SET @dummy = 0");
PREPARE stmt FROM @str;