1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #12779 from dougbarth/dont_swallow_exceptions_during_transactional_statements_in_mysql

Don't swallow exceptions in transctional statements
This commit is contained in:
Aaron Patterson 2013-11-15 11:29:12 -08:00
commit 314e2cc05b
4 changed files with 10 additions and 10 deletions

View file

@ -320,27 +320,19 @@ module ActiveRecord
def begin_db_transaction def begin_db_transaction
execute "BEGIN" execute "BEGIN"
rescue
# Transactions aren't supported
end end
def begin_isolated_db_transaction(isolation) def begin_isolated_db_transaction(isolation)
execute "SET TRANSACTION ISOLATION LEVEL #{transaction_isolation_levels.fetch(isolation)}" execute "SET TRANSACTION ISOLATION LEVEL #{transaction_isolation_levels.fetch(isolation)}"
begin_db_transaction begin_db_transaction
rescue
# Transactions aren't supported
end end
def commit_db_transaction #:nodoc: def commit_db_transaction #:nodoc:
execute "COMMIT" execute "COMMIT"
rescue
# Transactions aren't supported
end end
def rollback_db_transaction #:nodoc: def rollback_db_transaction #:nodoc:
execute "ROLLBACK" execute "ROLLBACK"
rescue
# Transactions aren't supported
end end
# In the simple case, MySQL allows us to place JOINs directly into the UPDATE # In the simple case, MySQL allows us to place JOINs directly into the UPDATE

View file

@ -462,8 +462,6 @@ module ActiveRecord
def begin_db_transaction #:nodoc: def begin_db_transaction #:nodoc:
exec_query "BEGIN" exec_query "BEGIN"
rescue Mysql::Error
# Transactions aren't supported
end end
private private

View file

@ -40,6 +40,11 @@ class MysqlConnectionTest < ActiveRecord::TestCase
@connection.update('set @@wait_timeout=1') @connection.update('set @@wait_timeout=1')
sleep 2 sleep 2
assert !@connection.active? assert !@connection.active?
# Repair all fixture connections so other tests won't break.
@fixture_connections.each do |c|
c.verify!
end
end end
def test_successful_reconnection_after_timeout_with_manual_reconnect def test_successful_reconnection_after_timeout_with_manual_reconnect

View file

@ -18,6 +18,11 @@ class MysqlConnectionTest < ActiveRecord::TestCase
@connection.update('set @@wait_timeout=1') @connection.update('set @@wait_timeout=1')
sleep 2 sleep 2
assert !@connection.active? assert !@connection.active?
# Repair all fixture connections so other tests won't break.
@fixture_connections.each do |c|
c.verify!
end
end end
def test_successful_reconnection_after_timeout_with_manual_reconnect def test_successful_reconnection_after_timeout_with_manual_reconnect