async_postgres/pg_client/transaction_helpers

Pipelined single-statement transactions: execInTransaction and queryInTransaction issue BEGIN, the user SQL, and COMMIT with a single Sync round trip.

Internal module: not part of the public API. Import the pg_client hub instead; what it re-exports is the supported surface (see tests/api_surface.golden).

Procs

proc execInTransaction(conn: PgConnection; sql: string;
                       params: seq[PgParam] = @[]; opts: TransactionOptions;
                       timeout: Duration = ZeroDuration): Future[CommandResult] {.
    ...stackTrace: false, raises: [Exception, ValueError, CatchableError],
    tags: [RootEffect, TimeEffect], forbids: [].}
Execute a statement inside a pipelined transaction with options.
proc execInTransaction(conn: PgConnection; sql: string;
                       params: seq[PgParam] = @[];
                       timeout: Duration = ZeroDuration): Future[CommandResult] {.
    ...stackTrace: false, raises: [Exception, ValueError, CatchableError],
    tags: [RootEffect, TimeEffect], forbids: [].}
Execute a statement inside a pipelined BEGIN/COMMIT transaction (1 round trip). On error, ROLLBACK is issued automatically. On timeout, the connection is retired (csClosed) unless the wire had settled (asyncdispatch always retires: the timed-out op stays on the socket).
proc queryInTransaction(conn: PgConnection; sql: string;
                        params: seq[PgParam] = @[]; opts: TransactionOptions;
                        resultFormat: ResultFormat = rfAuto;
                        timeout: Duration = ZeroDuration): Future[QueryResult] {.
    ...stackTrace: false, raises: [Exception, ValueError, CatchableError],
    tags: [RootEffect, TimeEffect], forbids: [].}
Execute a query inside a pipelined transaction with options.
proc queryInTransaction(conn: PgConnection; sql: string;
                        params: seq[PgParam] = @[];
                        resultFormat: ResultFormat = rfAuto;
                        timeout: Duration = ZeroDuration): Future[QueryResult] {.
    ...stackTrace: false, raises: [Exception, ValueError, CatchableError],
    tags: [RootEffect, TimeEffect], forbids: [].}
Execute a query inside a pipelined BEGIN/COMMIT transaction (1 round trip). Returns rows. On error, ROLLBACK is issued automatically. On timeout, the connection is retired (csClosed) unless the wire had settled (asyncdispatch always retires: the timed-out op stays on the socket).