Skip to main content

Module executor

Module executor 

Source
Expand description

The Executor trait โ€“ the runtime contract between generated code and the pool.

Code generated by bsql::query! calls methods on this trait. Pool, PoolConnection, and Transaction all implement it.

The associated type Rows controls the return wrapper:

  • Pool returns Arc<[Row]> (singleflight needs shared ownership).
  • PoolConnection and Transaction return Vec<Row> (no sharing, avoids ~20-40ns atomic ops + Arc control-block allocation per query).

Generated code only uses Deref<Target = [Row]> operations (.len(), .iter(), &rows[i]), so it works identically with both types.

v0.7: query_raw_readonly routes SELECT queries to replicas when read/write splitting is configured. Falls through to primary otherwise.

Traitsยง

Executor
Execute a prepared query and return raw rows.