@@ -52,8 +52,8 @@ def adapter_name
52
52
def redshift?
53
53
# SELECT version() :
54
54
# PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.647
55
- if ( redshift = config [ :redshift ] ) . nil?
56
- redshift = !! ( @connection . database_product || '' ) . index ( 'Redshift' )
55
+ if ( redshift = @ config[ :redshift ] ) . nil?
56
+ redshift = !! ( valid_raw_connection . database_product || '' ) . index ( 'Redshift' )
57
57
end
58
58
redshift
59
59
end
@@ -73,8 +73,8 @@ def configure_connection
73
73
# see http://jdbc.postgresql.org/documentation/91/connect.html
74
74
# self.set_client_encoding(encoding)
75
75
#end
76
- self . client_min_messages = config [ :min_messages ] || 'warning'
77
- self . schema_search_path = config [ :schema_search_path ] || config [ :schema_order ]
76
+ self . client_min_messages = @ config[ :min_messages ] || 'warning'
77
+ self . schema_search_path = @ config[ :schema_search_path ] || @ config[ :schema_order ]
78
78
79
79
# Use standard-conforming strings if available so we don't have to do the E'...' dance.
80
80
set_standard_conforming_strings
@@ -93,14 +93,17 @@ def configure_connection
93
93
94
94
# SET statements from :variables config hash
95
95
# http://www.postgresql.org/docs/8.3/static/sql-set.html
96
- ( config [ :variables ] || { } ) . map do |k , v |
96
+ ( @ config[ :variables ] || { } ) . map do |k , v |
97
97
if v == ':default' || v == :default
98
98
# Sets the value to the global or compile default
99
99
execute ( "SET SESSION #{ k } TO DEFAULT" , 'SCHEMA' )
100
100
elsif ! v . nil?
101
101
execute ( "SET SESSION #{ k } TO #{ quote ( v ) } " , 'SCHEMA' )
102
102
end
103
103
end
104
+
105
+ @type_map = Type ::HashLookupTypeMap . new
106
+ initialize_type_map
104
107
end
105
108
106
109
# @private
@@ -370,7 +373,7 @@ def use_insert_returning?
370
373
371
374
def get_database_version # :nodoc:
372
375
begin
373
- version = @connection . database_product
376
+ version = valid_raw_connection . database_product
374
377
if match = version . match ( /([\d \. ]*\d ).*?/ )
375
378
version = match [ 1 ] . split ( '.' ) . map ( &:to_i )
376
379
# PostgreSQL version representation does not have more than 4 digits
@@ -761,16 +764,17 @@ class PostgreSQLAdapter < AbstractAdapter
761
764
# AR expects OID to be available on the adapter
762
765
OID = ActiveRecord ::ConnectionAdapters ::PostgreSQL ::OID
763
766
764
- def initialize ( connection , logger = nil , connection_parameters = nil , config = { } )
767
+ def initialize ( ...)
768
+ super
769
+
770
+ conn_params = @config . compact
771
+
772
+ @connection_parameters = conn_params
773
+
765
774
# @local_tz is initialized as nil to avoid warnings when connect tries to use it
766
775
@local_tz = nil
767
776
@max_identifier_length = nil
768
777
769
- super ( connection , logger , config ) # configure_connection happens in super
770
-
771
- @type_map = Type ::HashLookupTypeMap . new
772
- initialize_type_map
773
-
774
778
@use_insert_returning = @config . key? ( :insert_returning ) ?
775
779
self . class . type_cast_config_to_boolean ( @config [ :insert_returning ] ) : true
776
780
end
@@ -793,7 +797,7 @@ def self.database_exists?(config)
793
797
public :sql_for_insert
794
798
alias :postgresql_version :database_version
795
799
796
- def jdbc_connection_class ( spec )
800
+ def jdbc_connection_class
797
801
::ArJdbc ::PostgreSQL . jdbc_connection_class
798
802
end
799
803
@@ -829,8 +833,10 @@ def exec_no_cache(sql, name, binds, async: false)
829
833
830
834
type_casted_binds = type_casted_binds ( binds )
831
835
log ( sql , name , binds , type_casted_binds , async : async ) do
832
- ActiveSupport ::Dependencies . interlock . permit_concurrent_loads do
833
- @connection . exec_params ( sql , type_casted_binds )
836
+ with_raw_connection do |conn |
837
+ result = conn . exec_params ( sql , type_casted_binds )
838
+ verified!
839
+ result
834
840
end
835
841
end
836
842
end
0 commit comments