Expand description
PostgreSQL pool for the database explorer.
Sprint 6 model: each PgPool represents one configured Postgres
profile and manages up to max_size underlying connections. Callers
identify their work by session_id (typically a UUID per query
tab). The pool maps session_id → connection so a tab’s cursor
always lives on the same wire across execute → fetch_page → close_query. Idle connections are reused for fresh sessions.
§Why per-session leasing
tokio_postgres::Client is Sync, but a Postgres session is
single-threaded by protocol: one transaction at a time, one cursor
at a time. To let two query tabs run independent paginated SELECTs
in parallel, each must hold its own connection for the cursor’s
lifetime. Without that, opening cursor A then cursor B on the same
wire kills A — what Sprint 5’s single-cursor invariant produced.
§Tunnel sharing
When the profile uses an SSH tunnel, the listener is opened once
at pool construction and shared by every pooled connection — they
each open their own SSH direct-tcpip channel via the same local
port. Single tunnel per profile keeps SSH session usage minimal.
§Thread safety
PgPool is Send + Sync. All public methods take &self and
acquire internal locks for short windows (the pool’s own metadata
Mutex during lease/release, and a per-connection Mutex during
cursor bookkeeping). FFI callers wrap one Arc<PgPool> per
managed connection id.
Re-exports§
pub use config::PgAuthMethod;pub use config::PgConfig;pub use config::PgTlsMode;pub use config::SshTunnelRef;pub use edit::InsertColumnInput;pub use edit::InsertedRow;pub use edit::UpdateOutcome;pub use exec::ActiveCursor;pub use exec::ColumnMeta;pub use exec::ExecutionOutcome;pub use exec::PageResult;pub use introspect::ColumnDetail;pub use introspect::DbSummary;pub use introspect::ObjectType;pub use introspect::ObjectTypeKind;pub use introspect::Relation;pub use introspect::RelationKind;pub use introspect::Routine;pub use introspect::RoutineKind;pub use introspect::SchemaContents;pub use introspect::SchemaSummary;pub use introspect::Sequence;pub use tunnel::SshTunnel;
Modules§
- config
- PostgreSQL connection configuration.
- edit
- Cell-level row editing for the explorer.
- exec
- Query execution for the Postgres explorer.
- introspect
- Schema introspection queries against
pg_catalog. - tunnel
- SSH local-port forwarding for the Postgres explorer.
Structs§
Enums§
- PgError
- Errors surfaced from the Postgres explorer layer.
Constants§
- BROWSER_
SESSION_ ID - Stable session id used for the schema browser’s introspection
calls (
list_databases,list_schemas,list_relations). Uses a name that can’t collide with a UUID-generated tab session id.