class Debloater::Connection
Public Class Methods
new(options)
click to toggle source
# File lib/debloater/connection.rb, line 10 def initialize(options) @pg = PG::Connection.open(options) exec %{ SET statement_timeout = 0; } end
Public Instance Methods
statindex_method()
click to toggle source
# File lib/debloater/connection.rb, line 20 def statindex_method @_guessed_index_method ||= if _check_pgstatindex method = :pgstatindex elsif _check_get_pgstatindex method = :get_pgstatindex end end
Private Instance Methods
_check_get_pgstatindex()
click to toggle source
# File lib/debloater/connection.rb, line 47 def _check_get_pgstatindex exec %{ select * from get_pgstatindex(0); } rescue PG::UndefinedFunction => e _fatal e, msg: 'The `get_pgstatindex` function is not found. Consult the README.' rescue PG::InternalError # expected, as there is no index with OID zero true rescue PG::Error => e _fatal e end
_check_pgstatindex()
click to toggle source
# File lib/debloater/connection.rb, line 31 def _check_pgstatindex exec %{ select * from pgstatindex(0); } rescue PG::UndefinedFunction => e _fatal e, msg: 'The `pgstattuple` extension is missing. Consult the README.' rescue PG::InternalError # expected, as there is no index with OID zero true rescue PG::InsufficientPrivilege _log "`pgstatindex` not permitted, falling back to get_pgstatindex" false rescue PG::Error => e _fatal e end