New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread cursor fix #53

Closed
wants to merge 7 commits into
base: master
from
Copy path View file
@@ -68,14 +68,12 @@ def exec(sql, *bindvars)
class Cursor #:nodoc:
include Connection::CursorCommon

# stack of open cursors
@@open_cursors = []
attr_reader :raw_cursor

def initialize(conn, raw_cursor)
@connection = conn
@raw_cursor = raw_cursor
@@open_cursors.push self
open_cursors.push self
end

def self.new_from_parse(conn, sql)
@@ -125,12 +123,20 @@ def close_raw_cursor

def close
# close all cursors that were created after this one
while (open_cursor = @@open_cursors.pop) && !open_cursor.equal?(self)
while (open_cursor = open_cursors.pop) && !open_cursor.equal?(self)
open_cursor.close_raw_cursor
end

close_raw_cursor

Thread.current[:__ruby_plsql_open_cursors] = nil if open_cursors.empty?
end

# Returns the (modifiable) list of open cursors in the current thread.
def open_cursors
Thread.current[:__ruby_plsql_open_cursors] ||= []
Thread.current[:__ruby_plsql_open_cursors]
end
end

def parse(sql)
@@ -336,4 +342,4 @@ def ora_date_to_ruby_date(val)

end

end
end
ProTip! Use n and p to navigate between commits in a pull request.