instance method exec_cache

Ruby on Rails 7.2.3

Since v3.1.12 Last seen in v7.2.3 Private

Available in: v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3

Signature

exec_cache(sql, name, binds, async:, allow_retry:, materialize_transactions:)

No documentation comment.

Parameters

sql req
name req
binds req
async keyreq
allow_retry keyreq
materialize_transactions keyreq
Source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 907
        def exec_cache(sql, name, binds, async:, allow_retry:, materialize_transactions:)
          mark_transaction_written_if_write(sql)

          update_typemap_for_default_timezone

          with_raw_connection(allow_retry: allow_retry, materialize_transactions: materialize_transactions) do |conn|
            stmt_key = prepare_statement(sql, binds, conn)
            type_casted_binds = type_casted_binds(binds)

            log(sql, name, binds, type_casted_binds, stmt_key, async: async) do |notification_payload|
              result = conn.exec_prepared(stmt_key, type_casted_binds)
              verified!
              notification_payload[:row_count] = result.count
              result
            end
          end
        rescue ActiveRecord::StatementInvalid => e
          raise unless is_cached_plan_failure?(e)

          # Nothing we can do if we are in a transaction because all commands
          # will raise InFailedSQLTransaction
          if in_transaction?
            raise ActiveRecord::PreparedStatementCacheExpired.new(e.cause.message, connection_pool: @pool)
          else
            @lock.synchronize do
              # outside of transactions we can simply flush this query and retry
              @statements.delete sql_key(sql)
            end
            retry
          end
        end

Defined in activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb line 907 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

Type at least 2 characters to search.

↑↓ navigate · open · esc close