Permalink
Browse files

prepare the statement inside the begin / rescue block

  • Loading branch information...
1 parent a0420d4 commit 19fc88646ba4eede7f9d4d75bd114871a7a4926b @tenderlove tenderlove committed Oct 4, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
View
8 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -772,12 +772,10 @@ def exec_no_cache(sql, name, binds)
end
def exec_cache(sql, name, binds)
- stmt_key = prepare_statement(sql)
-
log(sql, name, binds) do
begin
- # Clear the queue
- @connection.get_last_result
+ stmt_key = prepare_statement(sql)
+
@connection.send_query_prepared(stmt_key, binds.map { |col, val|
type_cast(val, col)
})
@@ -816,6 +814,8 @@ def prepare_statement(sql)
unless @statements.key? sql_key
nextkey = @statements.next_key
@connection.prepare nextkey, sql
+ # Clear the queue
+ @connection.get_last_result
@statements[sql_key] = nextkey
end
@statements[sql_key]

0 comments on commit 19fc886

Please sign in to comment.