module ActiveRecord::ConnectionAdapters::SQLServer::Showplan
Constants
- OPTIONS
- OPTION_ALL
- OPTION_TEXT
- OPTION_XML
Public Instance Methods
explain(arel, binds = [], options = [])
click to toggle source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 15 def explain(arel, binds = [], options = []) sql = to_sql(arel) result = with_showplan_on { internal_exec_query(sql, "EXPLAIN", binds) } printer = showplan_printer.new(result) printer.pp end
Protected Instance Methods
set_showplan_option(enable = true)
click to toggle source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 31 def set_showplan_option(enable = true) sql = "SET #{showplan_option} #{enable ? 'ON' : 'OFF'}" raw_execute(sql, "SCHEMA") rescue Exception raise ActiveRecordError, "#{showplan_option} could not be turned #{enable ? 'ON' : 'OFF'}, perhaps you do not have SHOWPLAN permissions?" end
showplan_all?()
click to toggle source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 44 def showplan_all? showplan_option == OPTION_ALL end
showplan_option()
click to toggle source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 38 def showplan_option (SQLServerAdapter.showplan_option || OPTION_ALL).tap do |opt| raise(ArgumentError, "Unknown SHOWPLAN option #{opt.inspect} found.") if OPTIONS.exclude?(opt) end end
showplan_printer()
click to toggle source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 56 def showplan_printer case showplan_option when OPTION_XML then PrinterXml when OPTION_ALL, OPTION_TEXT then PrinterTable else PrinterTable end end
showplan_text?()
click to toggle source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 48 def showplan_text? showplan_option == OPTION_TEXT end
showplan_xml?()
click to toggle source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 52 def showplan_xml? showplan_option == OPTION_XML end
with_showplan_on() { || ... }
click to toggle source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 24 def with_showplan_on set_showplan_option(true) yield ensure set_showplan_option(false) end