Fix command output capturing in optimize_tables.rb for Ruby 1.9

This commit is contained in:
Jerome Charaoui 2014-03-11 17:57:03 -04:00
parent f34882cadd
commit 8fbc1b33ee

View file

@ -2,7 +2,8 @@
# set home as we runit as weekly cron, where HOME is /
ENV['HOME'] = '/root'
tables = %x{mysql -Bse "SELECT TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') AND Data_free > 0 AND ENGINE IN ('MyISAM','InnoDB','ARCHIVE')"}
tables = %x(mysql -Bse "SELECT TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') AND Data_free > 0 AND ENGINE IN ('MyISAM','InnoDB','ARCHIVE')")
tables = tables.split(/\n/)
tables.each { |table|
tableitems = table.chomp.split(/\t/)
system "mysql #{tableitems[0]} -Bse \"OPTIMIZE TABLE \\`#{tableitems[0]}\\`.\\`#{tableitems[1]}\\`\" | grep -q OK"