clj-r2dbc.impl.execute

Core execution layer for clj-r2dbc.

Provides:
  execute-core!   - context-map execute-fn; populates :clj-r2dbc/rows and :clj-r2dbc/update-count.
  execute!*       - main entry point; returns vector (rows, update-count map, or []).
  execute-one!*   - first item or nil.
  execute-each!*  - per-binding result vectors for multi-param-set execution.
  execute-batch!* - vector of update counts for batch SQL execution.

Precondition: supplying both :middleware and :interceptors throws immediately.

This namespace is an implementation detail; do not use from application code.

execute!*

(execute!* db sql params opts)
Execute sql against db with the given params and opts.

Args:
  db     - ConnectionFactory, Connection, or ConnectableWithOpts.
  sql    - SQL string.
  params - sequential bind parameters.
  opts   - options map:
             :middleware   - seq of middleware fns (not with :interceptors).
             :interceptors - seq of interceptor maps (not with :middleware).
             :qualifier    - column keyword mode.
             :fetch-size   - calls Statement.fetchSize.
             :returning    - calls Statement.returnGeneratedValues.

Returns a Missionary task resolving to a labeled map.

Throws (synchronously):
  ex-info :clj-r2dbc/unsupported when both :middleware and :interceptors are present.

execute-batch!*

(execute-batch!* db sql-stmts _opts)
Execute a batch of sql-stmts via Connection.createBatch().

Args:
  db        - ConnectionFactory, Connection, or ConnectableWithOpts.
  sql-stmts - sequential collection of SQL strings.
  opts      - options map.

Returns a Missionary task resolving to {:clj-r2dbc/update-counts [...]}.
Row segments from batch results are silently discarded.

execute-core!

(execute-core! ctx)
Execute-fn for the interceptor pipeline.

Args:
  ctx - context map containing:
          :r2dbc/connection  - active R2DBC Connection.
          :clj-r2dbc/sql     - SQL string.
          :clj-r2dbc/params  - sequential bind parameters.
          :clj-r2dbc/opts    - options map.

Returns a task that resolves to the updated context map with:
  :clj-r2dbc/rows         - vector of row maps (may be empty).
  :clj-r2dbc/update-count - integer sum of UpdateCount segments (absent when none).

On R2dbcException, throws ex-info enriched with :clj-r2dbc/error-category,
:sql-state, :error-code, :sql, and :params.
missionary.Cancelled is never swallowed.

execute-each!*

(execute-each!* db sql param-sets opts)
Execute sql once per param-set in param-sets via Statement.add() batching.

Args:
  db         - ConnectionFactory, Connection, or ConnectableWithOpts.
  sql        - SQL string.
  param-sets - sequential collection of binding-set vectors.
  opts       - options map (:qualifier, :fetch-size; not :middleware or
               :interceptors).

Returns a Missionary task resolving to {:clj-r2dbc/results [...]}.

Throws (synchronously):
  ex-info :clj-r2dbc/limit-exceeded when (count param-sets) exceeds
  :max-batch-size (default 10000).

execute-one!*

(execute-one!* db sql params opts)
Execute sql against db and return the first row or nil.

Args:
  db     - ConnectionFactory, Connection, or ConnectableWithOpts.
  sql    - SQL string.
  params - sequential bind parameters.
  opts   - options map (see execute!* for supported keys).

Returns a Missionary task resolving to the first row map or nil.