New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump the minimum version of PostgreSQL to 9.3 #34520

Merged
merged 1 commit into from Nov 26, 2018

Conversation

Projects
None yet
4 participants
@yahonda
Contributor

yahonda commented Nov 25, 2018

Summary

This pull request bumps the minimum version of PostgreSQL to 9.3, dropping PostgreSQL 9.1 and 9.2 support.

https://www.postgresql.org/support/versioning/

  • 9.1 EOLed on September 2016.
  • 9.2 EOLed on September 2017.

9.3 is also not supported since Nov 8, 2018. https://www.postgresql.org/about/news/1905/
I think it may be a little bit early to drop PostgreSQL 9.3 yet.

Here are other changes included in this pull request:

  • Deprecated supports_ranges? since no other databases support range data type

  • Add supports_materialized_views? to abstract adapter
    Materialized views itself is supported by other databases, other connection adapters may support them

  • Drop CI against PostgreSQL 9.2

@yahonda yahonda force-pushed the yahonda:bump_pg93 branch from b5d7a82 to ea85d44 Nov 25, 2018

JOIN pg_attribute a
ON a.attrelid = i.indrelid
AND a.attnum = i.indkey[i.idx]
ORDER BY i.idx

This comment has been minimized.

@kamipo

kamipo Nov 25, 2018

Member

Is this query deterministic order even if the ORDER BY is removed?

This comment has been minimized.

@yahonda

yahonda Nov 25, 2018

Contributor

Thanks for the comment.

In my environment, it returns the primary key order as expected without order by but It does not look like deterministic since it does not Sort at the end of the query.

Was thinking about adding order by a.attnum but it just shows the column order of the table, not the index key order.

  create_table :countries_treaties, force: true, primary_key: [:country_id, :treaty_id] do |t|
    t.string :country_id, null: false
    t.string :treaty_id, null: false
  end
  • Without ORDER BY i.idx
activerecord_unittest=#               SELECT a.attname
              FROM (
                     SELECT indrelid, indkey, generate_subscripts(indkey, 1) idx
                       FROM pg_index
                      WHERE indrelid = 'countries_treaties'::regclass
                        AND indisprimary
                   ) i
              JOIN pg_attribute a
                ON a.attrelid = i.indrelid
               AND a.attnum = i.indkey[i.idx];
  attname
------------
 country_id
 treaty_id
(2 rows)


activerecord_unittest=# explain SELECT a.attname
activerecord_unittest-#               FROM (
activerecord_unittest(#                      SELECT indrelid, indkey, generate_subscripts(indkey, 1) idx
activerecord_unittest(#                        FROM pg_index
activerecord_unittest(#                       WHERE indrelid = 'countries_treaties'::regclass
activerecord_unittest(#                         AND indisprimary
activerecord_unittest(#                    ) i
activerecord_unittest-#               JOIN pg_attribute a
activerecord_unittest-#                 ON a.attrelid = i.indrelid
activerecord_unittest-#                AND a.attnum = i.indkey[i.idx];
                                                         QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------
 Hash Join  (cost=329.65..357.92 rows=43 width=64)
   Hash Cond: ((pg_index.indrelid = a.attrelid) AND (pg_index.indkey[(generate_subscripts(pg_index.indkey, 1))] = a.attnum))
   ->  ProjectSet  (cost=0.27..13.30 rows=1000 width=34)
         ->  Index Scan using pg_index_indrelid_index on pg_index  (cost=0.27..8.29 rows=1 width=30)
               Index Cond: (indrelid = '207561'::oid)
               Filter: indisprimary
   ->  Hash  (cost=218.75..218.75 rows=7375 width=70)
         ->  Seq Scan on pg_attribute a  (cost=0.00..218.75 rows=7375 width=70)
(8 rows)

activerecord_unittest=#
  • WITH ORDER BY i.idx
activerecord_unittest=# explain SELECT a.attname
              FROM (
                     SELECT indrelid, indkey, generate_subscripts(indkey, 1) idx
                       FROM pg_index
                      WHERE indrelid = 'countries_treaties'::regclass
                        AND indisprimary
                   ) i
              JOIN pg_attribute a
                ON a.attrelid = i.indrelid
               AND a.attnum = i.indkey[i.idx] ORDER BY i.idx;
                                                            QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=359.09..359.20 rows=43 width=68)
   Sort Key: (generate_subscripts(pg_index.indkey, 1))
   ->  Hash Join  (cost=329.65..357.92 rows=43 width=68)
         Hash Cond: ((pg_index.indrelid = a.attrelid) AND (pg_index.indkey[(generate_subscripts(pg_index.indkey, 1))] = a.attnum))
         ->  ProjectSet  (cost=0.27..13.30 rows=1000 width=34)
               ->  Index Scan using pg_index_indrelid_index on pg_index  (cost=0.27..8.29 rows=1 width=30)
                     Index Cond: (indrelid = '207561'::oid)
                     Filter: indisprimary
         ->  Hash  (cost=218.75..218.75 rows=7375 width=70)
               ->  Seq Scan on pg_attribute a  (cost=0.00..218.75 rows=7375 width=70)
(10 rows)

activerecord_unittest=#

This comment has been minimized.

@yahonda

yahonda Nov 25, 2018

Contributor

Well, in the meantime I'm restoring this change to the current master one since it looks difficult (for me) to guarantee the order of index key, not table column order.

@y-yagi

This comment has been minimized.

Member

y-yagi commented Nov 25, 2018

Can also remove branch condition in test_reconnection_after_actual_disconnection_with_verify?

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

Bump the minimum version of PostgreSQL to 9.3
https://www.postgresql.org/support/versioning/

- 9.1 EOLed on September 2016.
- 9.2 EOLed on September 2017.

9.3 is also not supported since Nov 8, 2018.  https://www.postgresql.org/about/news/1905/
I think it may be a little bit early to drop PostgreSQL 9.3 yet.

* Deprecated `supports_ranges?` since no other databases support range data type

* Add `supports_materialized_views?` to abstract adapter
Materialized views itself is supported by other databases, other connection adapters may support them

* Remove `with_manual_interventions`
It was only necessary for PostgreSQL 9.1 or earlier

* Drop CI against PostgreSQL 9.2

@yahonda yahonda force-pushed the yahonda:bump_pg93 branch from ea85d44 to 6fb128d Nov 25, 2018

@yahonda

This comment has been minimized.

Contributor

yahonda commented Nov 25, 2018

Removed PostgreSQL version condition and with_manual_interventions from test_reconnection_after_actual_disconnection_with_verify.

@rafaelfranca rafaelfranca merged commit 713e75d into rails:master Nov 26, 2018

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@yahonda yahonda deleted the yahonda:bump_pg93 branch Dec 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment