Class: Mysqlknife::Mysql::SQL

Inherits:
Object
  • Object
show all
Defined in:
lib/mysqlknife/mysql/sql.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject



6
7
8
# File 'lib/mysqlknife/mysql/sql.rb', line 6

def current_user
  'SELECT CURRENT_USER;'
end

#current_user_grantsObject



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_errorObject



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_errorObject



53
54
55
# File 'lib/mysqlknife/mysql/sql.rb', line 53

def rds_skip_repl_error
  'CALL mysql.rds_skip_repl_error;'
end

#replica_lagObject



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_statusObject



45
46
47
# File 'lib/mysqlknife/mysql/sql.rb', line 45

def slave_status
  'SHOW SLAVE STATUS;'
end