2008-10-02 00:56:10 +00:00
|
|
|
require File.dirname(__FILE__) + '/test_helper'
|
|
|
|
|
|
|
|
m = Mysql.real_connect('localhost','root')
|
|
|
|
m.reconnect = true
|
2009-04-18 22:42:12 +00:00
|
|
|
$count = 0
|
2008-10-02 00:56:10 +00:00
|
|
|
class << m
|
|
|
|
def safe_query( query )
|
|
|
|
begin
|
|
|
|
send_query( query )
|
|
|
|
rescue => e
|
2009-04-18 22:42:12 +00:00
|
|
|
$count += 1
|
2008-10-02 00:56:10 +00:00
|
|
|
puts e.message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
m.safe_query( 'select sleep(1)' )
|
|
|
|
m.safe_query( 'select sleep(1)' )#raises
|
|
|
|
m.simulate_disconnect #fires mysql_library_end
|
|
|
|
m.safe_query( 'select sleep(1)' )
|
|
|
|
m.safe_query( 'select sleep(1)' )#raises
|
|
|
|
m.close
|
|
|
|
m.connect('localhost','root')
|
|
|
|
m.safe_query( 'select sleep(1)' )
|
2008-10-19 22:17:42 +00:00
|
|
|
m.safe_query( 'select sleep(1)' )#raises
|
|
|
|
m.simulate_disconnect
|
2009-04-18 22:42:12 +00:00
|
|
|
raise unless $count == 3
|
2008-10-19 22:17:42 +00:00
|
|
|
m.safe_query( 'BEGIN' )
|
2009-04-18 22:42:12 +00:00
|
|
|
m.safe_query( 'select sleep(1)' ) # raises
|
2008-10-19 22:17:42 +00:00
|
|
|
m.get_result()
|
2009-04-18 22:42:12 +00:00
|
|
|
m.safe_query( 'COMMIT' )
|
|
|
|
m.get_result
|
|
|
|
raise unless $count == 4
|