module ActiveRecord::ConnectionAdapters::SQLServer::Showplan
Constants
- OPTIONS
- OPTION_ALL
- OPTION_TEXT
- OPTION_XML
Public Instance Methods
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
Source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 32 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
Source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 45 def showplan_all? showplan_option == OPTION_ALL end
Source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 39 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
Source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 57 def showplan_printer case showplan_option when OPTION_XML then PrinterXml when OPTION_ALL, OPTION_TEXT then PrinterTable else PrinterTable end end
Source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 49 def showplan_text? showplan_option == OPTION_TEXT end
Source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 53 def showplan_xml? showplan_option == OPTION_XML end
Source
# File lib/active_record/connection_adapters/sqlserver/showplan.rb, line 25 def with_showplan_on set_showplan_option(true) yield ensure set_showplan_option(false) end