Method: Sequel::Postgres::DatabaseMethods#server_version

Defined in:
lib/sequel/adapters/shared/postgres.rb

#server_version(server = nil) ⇒ Object

The version of the PostgreSQL server, used for determining capability.



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/sequel/adapters/shared/postgres.rb', line 454

def server_version(server=nil)
  return @server_version if @server_version
  @server_version = synchronize(server) do |conn|
    (conn.server_version rescue nil) if conn.respond_to?(:server_version)
  end
  unless @server_version
    @server_version = if m = /PostgreSQL (\d+)\.(\d+)(?:(?:rc\d+)|\.(\d+))?/.match(fetch('SELECT version()').single_value)
      (m[1].to_i * 10000) + (m[2].to_i * 100) + m[3].to_i
    else
      0
    end
  end
  warn 'Sequel no longer supports PostgreSQL <8.2, some things may not work' if @server_version < 80200
  @server_version
end