method

perform_query

Importance_0
v8.0.0 - Show latest stable - 0 notes - Class: DatabaseStatements
  • 1.0.0
  • 1.1.6
  • 1.2.6
  • 2.0.3
  • 2.1.0
  • 2.2.1
  • 2.3.8
  • 3.0.0
  • 3.0.9
  • 3.1.0
  • 3.2.1
  • 3.2.8
  • 3.2.13
  • 4.0.2
  • 4.1.8
  • 4.2.1
  • 4.2.7
  • 4.2.9
  • 5.0.0.1
  • 5.1.7
  • 5.2.3
  • 6.0.0
  • 6.1.3.1
  • 6.1.7.7
  • 7.0.0
  • 7.1.3.2
  • 7.1.3.4
  • 7.2.3
  • 8.0.0 (0)
  • 8.1.1 (0)
  • What's this?
perform_query(raw_connection, sql, binds, type_casted_binds, prepare:, notification_payload:, batch: false) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/connection_adapters/mysql2/database_statements.rb, line 41
          def perform_query(raw_connection, sql, binds, type_casted_binds, prepare,, notification_payload,, batch: false)
            reset_multi_statement = if batch && !multi_statements_enabled?
              raw_connection.set_server_option(::Mysql2::Client::OPTION_MULTI_STATEMENTS_ON)
              true
            end

            # Make sure we carry over any changes to ActiveRecord.default_timezone that have been
            # made since we established the connection
            raw_connection.query_options[:database_timezone] = default_timezone

            result = if prepare
              stmt = @statements[sql] ||= raw_connection.prepare(sql)

              begin
                ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
                  stmt.execute(*type_casted_binds)
                end
              rescue ::Mysql2::Error
                @statements.delete(sql)
                stmt.close
                raise
              end
              verified!
            else
              raw_connection.query(sql)
            end

            notification_payload[:row_count] = result&.size || 0

            @affected_rows_before_warnings = raw_connection.affected_rows
            raw_connection.abandon_results!

            verified!
            handle_warnings(sql)
            result
          ensure
            if reset_multi_statement && active?
              raw_connection.set_server_option(::Mysql2::Client::OPTION_MULTI_STATEMENTS_OFF)
            end
          end
Register or log in to add new notes.