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 def check_innodb_status_available
return unless DeadlockRetry.innodb_status_cmd == nil return unless DeadlockRetry.innodb_status_cmd == nil


begin if self.connection.adapter_name == "MySQL"
mysql_version = self.connection.select_rows('show variables like \'version\'')[0][1] begin
cmd = if mysql_version < '5.5' mysql_version = self.connection.select_rows('show variables like \'version\'')[0][1]
'show innodb status' cmd = if mysql_version < '5.5'
else 'show innodb status'
'show engine 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 end
self.connection.select_value(cmd) else
DeadlockRetry.innodb_status_cmd = cmd
rescue
logger.info "Cannot log innodb status: #{$!.message}"
DeadlockRetry.innodb_status_cmd = false DeadlockRetry.innodb_status_cmd = false
end end
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 true
end end


def self.adapter_name
"MySQL"
end

include DeadlockRetry include DeadlockRetry
end end


Expand Down

0 comments on commit 317b544

Please sign in to comment.