Class: Rack::Bug::SQLPanel::ProfileResult

Inherits:
QueryResult
  • Object
show all
Defined in:
lib/rack/bug/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::Bug::SQLPanel::QueryResult

Instance Method Details

#executeObject



84
85
86
87
88
89
90
91
92
93
# File 'lib/rack/bug/panels/sql_panel/query.rb', line 84

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



73
74
75
76
77
78
79
80
81
82
# File 'lib/rack/bug/panels/sql_panel/query.rb', line 73

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