Sha256: 524fc2c59134b61054d2a9ce0231a9cd7b544dc3f331f5be26e899d0b6e22bda
Contents?: true
Size: 1.94 KB
Versions: 9
Compression:
Stored size: 1.94 KB
Contents
module PgHero module Methods module Basic def settings names = if server_version_num >= 90500 %w( max_connections shared_buffers effective_cache_size work_mem maintenance_work_mem min_wal_size max_wal_size checkpoint_completion_target wal_buffers default_statistics_target ) else %w( max_connections shared_buffers effective_cache_size work_mem maintenance_work_mem checkpoint_segments checkpoint_completion_target wal_buffers default_statistics_target ) end Hash[names.map { |name| [name, select_all("SHOW #{name}").first[name]] }] end def ssl_used? ssl_used = nil connection_model.transaction do execute("CREATE EXTENSION IF NOT EXISTS sslinfo") ssl_used = PgHero.truthy?(select_all("SELECT ssl_is_used()").first["ssl_is_used"]) raise ActiveRecord::Rollback end ssl_used end def database_name select_all("SELECT current_database()").first["current_database"] end def server_version select_all("SHOW server_version").first["server_version"] end private def select_all(sql) # squish for logs connection.select_all(squish(sql)).to_a end def execute(sql) connection.execute(sql) end def connection connection_model.connection end # from ActiveSupport def squish(str) str.to_s.gsub(/\A[[:space:]]+/, "").gsub(/[[:space:]]+\z/, "").gsub(/[[:space:]]+/, " ") end def quote(value) connection.quote(value) end def quote_table_name(value) connection.quote_table_name(value) end def unquote(part) if part && part.start_with?('"') part[1..-2] else part end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems