Skip to content

Commit

Permalink
Only try and query innodb status with MySQL databases
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Jan 21, 2012
1 parent a2b55f7 commit 317b544
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/deadlock_retry.rb
Expand Up @@ -71,17 +71,21 @@ def show_innodb_status
def check_innodb_status_available
return unless DeadlockRetry.innodb_status_cmd == nil

begin
mysql_version = self.connection.select_rows('show variables like \'version\'')[0][1]
cmd = if mysql_version < '5.5'
'show innodb status'
else
'show engine innodb status'
if self.connection.adapter_name == "MySQL"
begin
mysql_version = self.connection.select_rows('show variables like \'version\'')[0][1]
cmd = if mysql_version < '5.5'
'show innodb status'
else
'show engine innodb status'
end
self.connection.select_value(cmd)
DeadlockRetry.innodb_status_cmd = cmd
rescue
logger.info "Cannot log innodb status: #{$!.message}"
DeadlockRetry.innodb_status_cmd = false
end
self.connection.select_value(cmd)
DeadlockRetry.innodb_status_cmd = cmd
rescue
logger.info "Cannot log innodb status: #{$!.message}"
else
DeadlockRetry.innodb_status_cmd = false
end
end
Expand Down
4 changes: 4 additions & 0 deletions test/deadlock_retry_test.rb
Expand Up @@ -45,6 +45,10 @@ def self.select_value(sql)
true
end

def self.adapter_name
"MySQL"
end

include DeadlockRetry
end

Expand Down

0 comments on commit 317b544

Please sign in to comment.