Permalink
Browse files

Bug Fix -- clean up connection after stored procedure [#3151 state:re…

…solved] for 2-3-stable
  • Loading branch information...
1 parent 43e2bbe commit 7e79889d1cd7d9f1b924c3a8d67d2fd70db3fb64 @Jeff-Lawson Jeff-Lawson committed with tenderlove Aug 18, 2010
@@ -315,6 +315,7 @@ def select_rows(sql, name = nil)
rows = []
result.each { |row| rows << row }
result.free
+ @connection.more_results && @connection.next_result # invoking stored procedures with CLIENT_MULTI_RESULTS requires this to tidy up else connection will be dropped
rows
end
@@ -638,6 +639,7 @@ def select(sql, name = nil)
result = execute(sql, name)
rows = result.all_hashes
result.free
+ @connection.more_results && @connection.next_result # invoking stored procedures with CLIENT_MULTI_RESULTS requires this to tidy up else connection will be dropped
rows
end
@@ -48,6 +48,7 @@ def test_successful_reconnection_after_timeout_with_verify
def test_multi_results
rows = ActiveRecord::Base.connection.select_rows('CALL ten();')
assert_equal 10, rows[0][0].to_i, "ten() did not return 10 as expected: #{rows.inspect}"
+ assert @connection.active?, "Bad connection use by 'MysqlAdapter.select_rows'"
end
end
@@ -19,6 +19,13 @@
BEGIN
select 10;
END
+SQL
+
+ ActiveRecord::Base.connection.execute <<-SQL
+CREATE PROCEDURE topics() SQL SECURITY INVOKER
+BEGIN
+ select * from topics limit 1;
+END
SQL
end

0 comments on commit 7e79889

Please sign in to comment.