lib/dbd/pg/statement.rb in dbd-pg-0.3.3 vs lib/dbd/pg/statement.rb in dbd-pg-0.3.4

- old
+ new

@@ -69,12 +69,11 @@ def fetch_scroll(direction, offset) @result.fetch_scroll(direction, offset) end def finish - @stmt.clear if @stmt - @result.finish if @result + internal_finish @result = nil @db = nil end # @@ -121,17 +120,26 @@ def quote(str) str end end + # finish the statement at a lower level + def internal_finish + @result.finish if @result + statement_exists = @db._exec("select * from pg_prepared_statements where name='#{@stmt_name}'") + if statement_exists.num_tuples > 0 + @db._exec("DEALLOCATE \"#{@stmt_name}\"") + end + end + # prepare the statement at a lower level. def internal_prepare if @db["pg_native_binding"] unless @prepared @stmt = @db._prepare(@stmt_name, translate_param_markers(@sql)) end else - @stmt.clear if @stmt + internal_finish @stmt = @db._prepare(@stmt_name, DBI::SQL::PreparedStatement.new(DBI::DBD::Pg, @sql).bind(@bindvars)) end @prepared = true end