aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-04 15:41:59 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-04 15:41:59 -0700
commit19fc88646ba4eede7f9d4d75bd114871a7a4926b (patch)
treeb3ed2999d38f6c567b534e2d046a83530c8edb5b /activerecord
parenta0420d4733809876483132d2c0a75d8b24c6db22 (diff)
downloadrails-19fc88646ba4eede7f9d4d75bd114871a7a4926b.tar.gz
rails-19fc88646ba4eede7f9d4d75bd114871a7a4926b.tar.bz2
rails-19fc88646ba4eede7f9d4d75bd114871a7a4926b.zip
prepare the statement inside the begin / rescue block
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 9a13d10ecc..158a0573dd 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -772,12 +772,10 @@ module ActiveRecord
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 @@ module ActiveRecord
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]