The update/delete method prepares a statement which it never frees. Below is an updated method which corrects this behaviour.
This problem is observed with v2.5.10
/lib/active_record/connection_adapters/ibm_db_adapter.rb
module ActiveRecord
module ConnectionAdapters
class IBMAdapter
def update(arel, name = nil, binds = [])
sql = to_sql(arel)
# Make sure the WHERE clause handles NULL's correctly
sqlarray = sql.split(/\s*WHERE\s*/)
size = sqlarray.size
if size > 1
sql = sqlarray[0] + " WHERE "
if size > 2
1.upto size-2 do |index|
sqlarray[index].gsub!( /(=\s*NULL|IN\s*\(NULL\))/i, " IS NULL" ) unless
sqlarray[index].nil?
sql = sql + sqlarray[index] + " WHERE "
end
end
sqlarray[size-1].gsub!( /(=\s*NULL|IN\s*\(NULL\))/i, " IS NULL" ) unless sqlarray[size-1].nil?
sql = sql + sqlarray[size-1]
end
clear_query_cache if defined? clear_query_cache
if binds.nil? || binds.empty?
update_direct(sql, name)
else
if stmt = exec_query(sql,name,binds)
num = IBM_DB.num_rows(stmt)
IBM_DB.free_stmt(stmt) # This is the important line added
num
end
end
end
end
end
end
|