Module: PgHero::Methods::Basic

Included in:
Database
Defined in:
lib/pghero/methods/basic.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject



21
22
23
# File 'lib/pghero/methods/basic.rb', line 21

def current_user
  select_one("SELECT current_user")
end

#database_nameObject



17
18
19
# File 'lib/pghero/methods/basic.rb', line 17

def database_name
  select_one("SELECT current_database()")
end

#quote_ident(value) ⇒ Object



33
34
35
# File 'lib/pghero/methods/basic.rb', line 33

def quote_ident(value)
  with_connection { |c| c.quote_column_name(value) }
end

#server_versionObject



25
26
27
# File 'lib/pghero/methods/basic.rb', line 25

def server_version
  @server_version ||= select_one("SHOW server_version")
end

#server_version_numObject



29
30
31
# File 'lib/pghero/methods/basic.rb', line 29

def server_version_num
  @server_version_num ||= select_one("SHOW server_version_num").to_i
end

#ssl_used?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/pghero/methods/basic.rb', line 4

def ssl_used?
  ssl_used = nil
  with_transaction(rollback: true) do
    begin
      execute("CREATE EXTENSION IF NOT EXISTS sslinfo")
    rescue ActiveRecord::StatementInvalid
      # not superuser
    end
    ssl_used = select_one("SELECT ssl_is_used()")
  end
  ssl_used
end