Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ matrix:
before_install:
- "sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/10/main/postgresql.conf"
- "sudo service postgresql restart 10"
- rvm: 2.5.1
env:
- "GEM=ar:postgresql POSTGRES=9.2"
addons:
postgresql: "9.2"
- rvm: jruby-head
jdk: oraclejdk8
env:
Expand Down
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Bump minimum PostgreSQL version to 9.3.

*Yasuo Honda*

* Values of enum are frozen, raising an error when attempting to modify them.

*Emmanuel Byrd*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ def supports_views?
false
end

# Does this adapter support materialized views?
def supports_materialized_views?
false
end

# Does this adapter support datetime with precision?
def supports_datetime_with_precision?
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def supports_datetime_with_precision?
end

def supports_json?
postgresql_version >= 90200
true
end

def supports_comments?
Expand Down Expand Up @@ -332,16 +332,16 @@ def supports_extensions?
end

def supports_ranges?
# Range datatypes weren't introduced until PostgreSQL 9.2
postgresql_version >= 90200
true
end
deprecate :supports_ranges?

def supports_materialized_views?
postgresql_version >= 90300
true
end

def supports_foreign_tables?
postgresql_version >= 90300
true
end

def supports_pgcrypto_uuid?
Expand Down Expand Up @@ -425,8 +425,8 @@ def default_index_type?(index) # :nodoc:

private
def check_version
if postgresql_version < 90100
raise "Your version of PostgreSQL (#{postgresql_version}) is too old. Active Record supports PostgreSQL >= 9.1."
if postgresql_version < 90300
raise "Your version of PostgreSQL (#{postgresql_version}) is too old. Active Record supports PostgreSQL >= 9.3."
end
end

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

if supports_ranges?
query = <<~SQL
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
FROM pg_type as t
LEFT JOIN pg_range as r ON oid = rngtypid
SQL
else
query = <<~SQL
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, t.typtype, t.typbasetype
FROM pg_type as t
SQL
end
query = <<~SQL
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
FROM pg_type as t
LEFT JOIN pg_range as r ON oid = rngtypid
SQL

if oids
query += "WHERE t.oid::integer IN (%s)" % oids.join(", ")
Expand Down
29 changes: 7 additions & 22 deletions activerecord/test/cases/adapters/postgresql/connection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,34 +146,15 @@ def test_statement_key_is_logged
end
end

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

# Sanity check.
assert_predicate @connection, :active?

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

@connection.verify!

Expand Down Expand Up @@ -261,6 +242,10 @@ def test_release_non_existent_advisory_lock
end
end

def test_supports_ranges_is_deprecated
assert_deprecated { @connection.supports_ranges? }
end

private

def with_warning_suppression
Expand Down
Loading