Class: Rack::Insight::SQLPanel::ProfileResult

Inherits:
QueryResult
  • Object
show all
Defined in:
lib/rack/insight/panels/sql_panel/query.rb

Instance Attribute Summary

Attributes inherited from QueryResult

#sql, #time

Instance Method Summary collapse

Methods inherited from QueryResult

#column_names, execute, #human_time, #initialize, #inspectable?, #result, #rows, #valid_hash?

Methods included from FilteredBacktrace

#backtrace, backtrace_regexp, #filtered_backtrace, #has_backtrace?, root_for_backtrace_filtering

Constructor Details

This class inherits a constructor from Rack::Insight::SQLPanel::QueryResult

Instance Method Details

#executeObject



82
83
84
85
86
87
88
89
90
91
# File 'lib/rack/insight/panels/sql_panel/query.rb', line 82

def execute
  with_profiling do
    super
    self.class.execute <<-SQL
        SELECT *
          FROM information_schema.profiling
         WHERE query_id = (SELECT query_id FROM information_schema.profiling ORDER BY query_id DESC LIMIT 1)
    SQL
  end
end

#with_profilingObject



71
72
73
74
75
76
77
78
79
80
# File 'lib/rack/insight/panels/sql_panel/query.rb', line 71

def with_profiling
  result = nil
  begin
    self.class.execute("SET PROFILING=1")
    result = yield
  ensure
    self.class.execute("SET PROFILING=0")
  end
  return result
end