QueryExecutor

class QueryExecutor(stream: PgStream, typeRegistry: TypeRegistry, maxParameterWriterCapacity: Int?, initialParameterWriterCapacity: Int?, logParameterValues: Boolean)

Handles the low-level execution of PostgreSQL queries over the wire protocol.

This executor manages communication with the database using both the Simple Query Protocol (for utility statements) and the Extended Query Protocol (for parameterized DML and DQL). It is responsible for parsing responses, managing the transaction state flag, and mapping results back into usable domain objects.

Constructors

Link copied to clipboard
internal constructor(stream: PgStream, typeRegistry: TypeRegistry, maxParameterWriterCapacity: Int?, initialParameterWriterCapacity: Int?, logParameterValues: Boolean)

Functions

Link copied to clipboard
fun execute(sql: String, ignoreRows: Boolean = false)

Uses Simple Query Protocol (Q). Intended for calls that do not return results or where results are ignored (e.g., SET TIME ZONE, BEGIN).

Link copied to clipboard
fun query(sql: String, params: Array<out Any?> = emptyArray(), parameterSerializer: ParameterSerializer? = null, mapper: ResultMapper, maxRows: Int = 0): List<Row>

Uses Extended Query Protocol. Intended for DQL (SELECT). Returns a parsed list of rows (Row) immediately.

fun <R> query(sql: String, params: Array<out Any?> = emptyArray(), parameterSerializer: ParameterSerializer?, mapper: ResultMapper, maxRows: Int = 0, transform: (Row) -> R): List<R>

Uses Extended Query Protocol. Intended for DQL (SELECT). Returns a parsed list of elements using the provided transform function immediately.

Link copied to clipboard
fun <R> queryForEach(sql: String, params: Array<out Any?> = emptyArray(), parameterSerializer: ParameterSerializer, mapper: ResultMapper, fetchSize: Int, transform: (Row) -> R, block: (R) -> Unit)

Uses Extended Query Protocol. Intended for DQL (SELECT). Iterates over rows in batches of fetchSize and applies the given transform and block. A fetchSize of 0 is Execute's own "no limit": one batch carrying the whole result.

Link copied to clipboard
fun update(sql: String, params: Array<out Any?> = emptyArray(), parameterSerializer: ParameterSerializer? = null): Long

Uses Extended Query Protocol (Parse, Bind, Execute, Sync). Intended for DML (INSERT, UPDATE, DELETE). Expects no rows returned. Returns the number of updated rows.