Skip to main content

Module query

Module query 

Source
Expand description

db query — execute arbitrary single-statement read-only SQL against the CLI’s local postgres pool. Returns the row set as typed JSON cells (Postgres → JSON via a per-cell decoder), with column metadata and the wire-protocol command tag.

Constraints:

  • Read-only: wrapped in SET LOCAL TRANSACTION READ ONLY server-side. Write attempts come back as Error::QueryReadOnlyViolation.
  • Timeout: the RequestBase envelope’s optional --timeout (humantime: 30s, 5m, 1h30m). When set, the CLI threads it to postgres as SET LOCAL statement_timeout / lock_timeout — enforcement is the server’s alone. When omitted, the query runs uncapped.

Multi-statement queries, COPY … TO STDOUT|STDIN, and transaction-control verbs (BEGIN / COMMIT / ROLLBACK) are rejected up front by a cheap leading-token scan on the CLI side before the query reaches the database.

Modules§

request_schema
response_schema

Structs§

Args
Column
One result column. r#type is the Postgres pg_type.typname (e.g. "int8", "text", "jsonb", "timestamptz"). Callers needing precision/scale/array-element-type can inspect the name; richer typeinfo is deferred.
Command
Request
Response
Unary response from db query.

Enums§

Path
Schema

Functions§

execute
execute_transform