Skip to content

Commit 713e75d

Browse files
authored
Merge pull request rails#34520 from yahonda/bump_pg93
Bump the minimum version of PostgreSQL to 9.3
2 parents 0fe258d + 6fb128d commit 713e75d

File tree

12 files changed

+385
-410
lines changed

12 files changed

+385
-410
lines changed

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,6 @@ matrix:
184184
before_install:
185185
- "sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/10/main/postgresql.conf"
186186
- "sudo service postgresql restart 10"
187-
- rvm: 2.5.1
188-
env:
189-
- "GEM=ar:postgresql POSTGRES=9.2"
190-
addons:
191-
postgresql: "9.2"
192187
- rvm: jruby-head
193188
jdk: oraclejdk8
194189
env:

activerecord/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Bump minimum PostgreSQL version to 9.3.
2+
3+
*Yasuo Honda*
4+
15
* Values of enum are frozen, raising an error when attempting to modify them.
26

37
*Emmanuel Byrd*

activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@ def supports_views?
314314
false
315315
end
316316

317+
# Does this adapter support materialized views?
318+
def supports_materialized_views?
319+
false
320+
end
321+
317322
# Does this adapter support datetime with precision?
318323
def supports_datetime_with_precision?
319324
false

activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def supports_datetime_with_precision?
185185
end
186186

187187
def supports_json?
188-
postgresql_version >= 90200
188+
true
189189
end
190190

191191
def supports_comments?
@@ -332,16 +332,16 @@ def supports_extensions?
332332
end
333333

334334
def supports_ranges?
335-
# Range datatypes weren't introduced until PostgreSQL 9.2
336-
postgresql_version >= 90200
335+
true
337336
end
337+
deprecate :supports_ranges?
338338

339339
def supports_materialized_views?
340-
postgresql_version >= 90300
340+
true
341341
end
342342

343343
def supports_foreign_tables?
344-
postgresql_version >= 90300
344+
true
345345
end
346346

347347
def supports_pgcrypto_uuid?
@@ -425,8 +425,8 @@ def default_index_type?(index) # :nodoc:
425425

426426
private
427427
def check_version
428-
if postgresql_version < 90100
429-
raise "Your version of PostgreSQL (#{postgresql_version}) is too old. Active Record supports PostgreSQL >= 9.1."
428+
if postgresql_version < 90300
429+
raise "Your version of PostgreSQL (#{postgresql_version}) is too old. Active Record supports PostgreSQL >= 9.3."
430430
end
431431
end
432432

@@ -589,18 +589,11 @@ def has_default_function?(default_value, default)
589589
def load_additional_types(oids = nil)
590590
initializer = OID::TypeMapInitializer.new(type_map)
591591

592-
if supports_ranges?
593-
query = <<~SQL
594-
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
595-
FROM pg_type as t
596-
LEFT JOIN pg_range as r ON oid = rngtypid
597-
SQL
598-
else
599-
query = <<~SQL
600-
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, t.typtype, t.typbasetype
601-
FROM pg_type as t
602-
SQL
603-
end
592+
query = <<~SQL
593+
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
594+
FROM pg_type as t
595+
LEFT JOIN pg_range as r ON oid = rngtypid
596+
SQL
604597

605598
if oids
606599
query += "WHERE t.oid::integer IN (%s)" % oids.join(", ")

activerecord/test/cases/adapters/postgresql/connection_test.rb

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -146,34 +146,15 @@ def test_statement_key_is_logged
146146
end
147147
end
148148

149-
# Must have PostgreSQL >= 9.2, or with_manual_interventions set to
150-
# true for this test to run.
151-
#
152-
# When prompted, restart the PostgreSQL server with the
153-
# "-m fast" option or kill the individual connection assuming
154-
# you know the incantation to do that.
155-
# To restart PostgreSQL 9.1 on macOS, installed via MacPorts, ...
156-
# sudo su postgres -c "pg_ctl restart -D /opt/local/var/db/postgresql91/defaultdb/ -m fast"
157149
def test_reconnection_after_actual_disconnection_with_verify
158150
original_connection_pid = @connection.query("select pg_backend_pid()")
159151

160152
# Sanity check.
161153
assert_predicate @connection, :active?
162154

163-
if @connection.send(:postgresql_version) >= 90200
164-
secondary_connection = ActiveRecord::Base.connection_pool.checkout
165-
secondary_connection.query("select pg_terminate_backend(#{original_connection_pid.first.first})")
166-
ActiveRecord::Base.connection_pool.checkin(secondary_connection)
167-
elsif ARTest.config["with_manual_interventions"]
168-
puts "Kill the connection now (e.g. by restarting the PostgreSQL " \
169-
'server with the "-m fast" option) and then press enter.'
170-
$stdin.gets
171-
else
172-
# We're not capable of terminating the backend ourselves, and
173-
# we're not allowed to seek assistance; bail out without
174-
# actually testing anything.
175-
return
176-
end
155+
secondary_connection = ActiveRecord::Base.connection_pool.checkout
156+
secondary_connection.query("select pg_terminate_backend(#{original_connection_pid.first.first})")
157+
ActiveRecord::Base.connection_pool.checkin(secondary_connection)
177158

178159
@connection.verify!
179160

@@ -261,6 +242,10 @@ def test_release_non_existent_advisory_lock
261242
end
262243
end
263244

245+
def test_supports_ranges_is_deprecated
246+
assert_deprecated { @connection.supports_ranges? }
247+
end
248+
264249
private
265250

266251
def with_warning_suppression

0 commit comments

Comments
 (0)