From 2d483e6b755de67b6db9bfd1711b9900b6a363a0 Mon Sep 17 00:00:00 2001 From: "Jean-Marie RENOUARDjmrenouard@gmail.com" Date: Mon, 4 Apr 2016 12:32:35 -0400 Subject: [PATCH] Check tables are all innodb table and check all table gets pk #150 --- mysqltuner.pl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 6ccc3cc..4d69c14 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -3041,7 +3041,25 @@ sub mariadb_galera { foreach my $gstatus ( keys %mystat ) { next unless $gstatus =~ /^wsrep.*/; infoprint "\t".trim($gstatus). " = ".$mystat{$gstatus}; - } + } + my @primaryKeysNbTables=select_array("select CONCAT(table_schema,CONCAT('.', table_name)) from information_schema.columns where table_schema not in ('mysql', 'information_schema', 'performance_schema') group by table_schema,table_name having sum(if(column_key in ('PRI','UNI'), 1,0)) = 0"); + if (scalar (@primaryKeysNbTables) > 0 ) { + badprint "Following table(s) don't have primary key:"; + foreach my $badtable( @primaryKeysNbTables ) { + badprint "\t$badtable"; + } + } else { + goodprint "All tables get a primary key"; + } + my @nonInnoDbTables=select_array("select CONCAT(table_schema,CONCAT('.', table_name)) from information_schema.tables where ENGINE <> 'InnoDb' and table_schema not in ('mysql', 'performance_schema', 'information_schema')"); + if (scalar (@nonInnoDbTables) > 0 ) { + badprint "Following table(s) are not InnoDB table:"; + foreach my $badtable( @nonInnoDbTables ) { + badprint "\t$badtable"; + } + } else { + goodprint "All tables are InnoDB tables"; + } }