aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-21 11:19:45 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-26 13:44:10 -0700
commit1741bbe2d5cb58af76fb2ca31a25c05eadfadb71 (patch)
treef6bc9d5a4ce3694593cfda9778d7cf27973743af /activerecord/lib/active_record
parent28a18b59885913682ffb1bceb87694eccd217df2 (diff)
downloadrails-1741bbe2d5cb58af76fb2ca31a25c05eadfadb71.tar.gz
rails-1741bbe2d5cb58af76fb2ca31a25c05eadfadb71.tar.bz2
rails-1741bbe2d5cb58af76fb2ca31a25c05eadfadb71.zip
avoiding statement cache if there are no bind values
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 5e46f6994c..64a07cccca 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -521,6 +521,8 @@ module ActiveRecord
end
def exec(sql, name = 'SQL', binds = [])
+ return exec_no_cache(sql, name) if binds.empty?
+
log(sql, name) do
unless @statements.key? sql
nextkey = "a#{@statements.length + 1}"
@@ -962,6 +964,15 @@ module ActiveRecord
end
private
+ def exec_no_cache(sql, name)
+ log(sql, name) do
+ result = @connection.async_exec(sql)
+ ret = ActiveRecord::Result.new(result.fields, result_as_array(result))
+ result.clear
+ ret
+ end
+ end
+
# The internal PostgreSQL identifier of the money data type.
MONEY_COLUMN_TYPE_OID = 790 #:nodoc:
# The internal PostgreSQL identifier of the BYTEA data type.