Skip to content
Browse files

Only try and query innodb status with MySQL databases

  • Loading branch information...
1 parent a2b55f7 commit 317b54472bbaf8c19a93b134ad6efd23fd2cff33 @tomhughes tomhughes committed Jan 21, 2012
Showing with 18 additions and 10 deletions.
  1. +14 −10 lib/deadlock_retry.rb
  2. +4 −0 test/deadlock_retry_test.rb
View
24 lib/deadlock_retry.rb
@@ -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
View
4 test/deadlock_retry_test.rb
@@ -45,6 +45,10 @@ def self.select_value(sql)
true
end
+ def self.adapter_name
+ "MySQL"
+ end
+
include DeadlockRetry
end

0 comments on commit 317b544

Please sign in to comment.
Something went wrong with that request. Please try again.