Class: Mysqlknife::Mysql::SQL
- Inherits:
-
Object
- Object
- Mysqlknife::Mysql::SQL
- Defined in:
- lib/mysqlknife/mysql/sql.rb
Instance Method Summary collapse
- #current_user ⇒ Object
- #current_user_grants ⇒ Object
- #mysql_kill(pid) ⇒ Object
- #mysql_skip_repl_error ⇒ Object
- #rds_kill(pid) ⇒ Object
- #rds_skip_repl_error ⇒ Object
- #replica_lag ⇒ Object
- #show_procedure(name) ⇒ Object
- #show_processlist(where = nil) ⇒ Object
- #slave_status ⇒ Object
Instance Method Details
#current_user ⇒ Object
6 7 8 |
# File 'lib/mysqlknife/mysql/sql.rb', line 6 def current_user 'SELECT CURRENT_USER;' end |
#current_user_grants ⇒ Object
10 11 12 |
# File 'lib/mysqlknife/mysql/sql.rb', line 10 def current_user_grants 'SHOW GRANTS FOR CURRENT_USER;' end |
#mysql_kill(pid) ⇒ Object
41 42 43 |
# File 'lib/mysqlknife/mysql/sql.rb', line 41 def mysql_kill(pid) "KILL #{pid};" end |
#mysql_skip_repl_error ⇒ Object
35 36 37 38 39 |
# File 'lib/mysqlknife/mysql/sql.rb', line 35 def mysql_skip_repl_error %w(STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; START SLAVE;).join(' ') end |
#rds_kill(pid) ⇒ Object
49 50 51 |
# File 'lib/mysqlknife/mysql/sql.rb', line 49 def rds_kill(pid) "CALL mysql.rds_kill(#{pid});" end |
#rds_skip_repl_error ⇒ Object
53 54 55 |
# File 'lib/mysqlknife/mysql/sql.rb', line 53 def rds_skip_repl_error 'CALL mysql.rds_skip_repl_error;' end |
#replica_lag ⇒ Object
14 15 16 |
# File 'lib/mysqlknife/mysql/sql.rb', line 14 def replica_lag 'SHOW SLAVE STATUS\G' end |
#show_procedure(name) ⇒ Object
31 32 33 |
# File 'lib/mysqlknife/mysql/sql.rb', line 31 def show_procedure(name) "SHOW PROCEDURE STATUS LIKE '#{name}';" end |
#show_processlist(where = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mysqlknife/mysql/sql.rb', line 18 def show_processlist(where = nil) sql = %w(SELECT id, user, host, db, command, time, state, info FROM INFORMATION_SCHEMA.PROCESSLIST WHERE state NOT REGEXP '(slave|relay|event)' AND user NOT IN ('rdsadmin', 'rdsrepladmin', 'system user', 'event_scheduler') AND id != CONNECTION_ID() AND command != 'Binlog Dump').join(' ') sql << " AND #{where};" unless where.nil? end |
#slave_status ⇒ Object
45 46 47 |
# File 'lib/mysqlknife/mysql/sql.rb', line 45 def slave_status 'SHOW SLAVE STATUS;' end |