Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-07-24 14:23:54 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2018-07-24 14:25:01 +0300
commit2ade035eb253a5a69f05acab26b3e5ad6d3eb233 (patch)
tree5cf37782cef62c07d326a76e97e4a6a9dd806c6e /lib/gitlab/database.rb
parent1c24eafb4106dc7890ef74093a59009e94baa705 (diff)
Backport various EE changes to Gitlab::Database
These changes are useful for CE as well. For example, the MR https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20720 can make use of some of the backported methods.
Diffstat (limited to 'lib/gitlab/database.rb')
-rw-r--r--lib/gitlab/database.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index 872e70f9a5d..8eacad078c8 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -61,6 +61,10 @@ module Gitlab
@version ||= database_version.match(/\A(?:PostgreSQL |)([^\s]+).*\z/)[1]
end
+ def self.postgresql_9_or_less?
+ postgresql? && version.to_f < 10
+ end
+
def self.join_lateral_supported?
postgresql? && version.to_f >= 9.3
end
@@ -69,6 +73,28 @@ module Gitlab
postgresql? && version.to_f >= 9.4
end
+ def self.pg_stat_wal_receiver_supported?
+ postgresql? && version.to_f >= 9.6
+ end
+
+ # map some of the function names that changed between PostgreSQL 9 and 10
+ # https://wiki.postgresql.org/wiki/New_in_postgres_10
+ def self.pg_wal_lsn_diff
+ Gitlab::Database.postgresql_9_or_less? ? 'pg_xlog_location_diff' : 'pg_wal_lsn_diff'
+ end
+
+ def self.pg_current_wal_insert_lsn
+ Gitlab::Database.postgresql_9_or_less? ? 'pg_current_xlog_insert_location' : 'pg_current_wal_insert_lsn'
+ end
+
+ def self.pg_last_wal_receive_lsn
+ Gitlab::Database.postgresql_9_or_less? ? 'pg_last_xlog_receive_location' : 'pg_last_wal_receive_lsn'
+ end
+
+ def self.pg_last_wal_replay_lsn
+ Gitlab::Database.postgresql_9_or_less? ? 'pg_last_xlog_replay_location' : 'pg_last_wal_replay_lsn'
+ end
+
def self.nulls_last_order(field, direction = 'ASC')
order = "#{field} #{direction}"