pub struct PgPool { /* private fields */ }Implementations§
Source§impl PgPool
impl PgPool
Sourcepub async fn connect(
cfg: PgConfig,
ssh_client: Option<Arc<RwLock<SshClient>>>,
) -> Result<Arc<Self>, PgError>
pub async fn connect( cfg: PgConfig, ssh_client: Option<Arc<RwLock<SshClient>>>, ) -> Result<Arc<Self>, PgError>
Open a pool with min_size = 1 (one connection eagerly
established) and max_size = DEFAULT_MAX_POOL_SIZE. Eager
initial connect surfaces auth/network errors immediately
rather than deferring them to the first query.
Sourcepub async fn list_databases(&self) -> Result<Vec<DbSummary>, PgError>
pub async fn list_databases(&self) -> Result<Vec<DbSummary>, PgError>
Schema introspection runs on the connection bound to the well-known browser session. Re-using the same session means the browser doesn’t churn through pool slots on every tree refresh.
pub async fn list_schemas(&self) -> Result<Vec<SchemaSummary>, PgError>
Sourcepub async fn list_schemas_in(
&self,
database: Option<&str>,
) -> Result<Vec<SchemaSummary>, PgError>
pub async fn list_schemas_in( &self, database: Option<&str>, ) -> Result<Vec<SchemaSummary>, PgError>
List schemas in database, opening (and caching) a side
connection when it differs from the connection’s default DB.
Postgres binds a connection to one database at startup, so
browsing other DBs in the tree requires this routing —
otherwise every database expansion would show the connected
DB’s schemas.
pub async fn list_relations( &self, schema: &str, ) -> Result<Vec<Relation>, PgError>
pub async fn list_relations_in( &self, schema: &str, database: Option<&str>, ) -> Result<Vec<Relation>, PgError>
Sourcepub async fn list_schema_contents_in(
&self,
schema: &str,
database: Option<&str>,
) -> Result<SchemaContents, PgError>
pub async fn list_schema_contents_in( &self, schema: &str, database: Option<&str>, ) -> Result<SchemaContents, PgError>
Unified schema-contents fetch — tables, views, mat-views, sequences, routines, and object types in one call. Replaces the per-category round-trips the older tree did, and is what the DataGrip-style 6-category tree expects.
Sourcepub async fn describe_columns(
&self,
schema: &str,
table: &str,
) -> Result<Vec<ColumnDetail>, PgError>
pub async fn describe_columns( &self, schema: &str, table: &str, ) -> Result<Vec<ColumnDetail>, PgError>
Describe a relation’s columns for the INSERT form. Runs on the browser session to avoid churning a query tab’s lease.
Sourcepub async fn execute(
&self,
session_id: &str,
sql: &str,
page_size: usize,
) -> Result<ExecutionOutcome, PgError>
pub async fn execute( &self, session_id: &str, sql: &str, page_size: usize, ) -> Result<ExecutionOutcome, PgError>
Run a SQL statement on the connection assigned to session_id,
leasing one if the session is new. Closes any previously-active
cursor on that connection (per-session behavior — other sessions
are unaffected).
pub async fn fetch_page( &self, session_id: &str, cursor_id: &str, count: usize, ) -> Result<PageResult, PgError>
Sourcepub async fn update_cell(
&self,
session_id: &str,
schema: &str,
table: &str,
column: &str,
column_type: &str,
new_value: Option<&str>,
ctid: &str,
) -> Result<UpdateOutcome, PgError>
pub async fn update_cell( &self, session_id: &str, schema: &str, table: &str, column: &str, column_type: &str, new_value: Option<&str>, ctid: &str, ) -> Result<UpdateOutcome, PgError>
Update a single cell on (schema, table) identified by ctid.
Runs on the session’s connection so users editing in one tab
don’t block on another tab’s pagination cursor. Returns
UpdateOutcome { rows_affected } — the UI treats 0 as
“row no longer there, please refresh”.
Sourcepub async fn insert_row(
&self,
session_id: &str,
schema: &str,
table: &str,
inputs: &[InsertColumnInput],
return_columns: &[String],
) -> Result<InsertedRow, PgError>
pub async fn insert_row( &self, session_id: &str, schema: &str, table: &str, inputs: &[InsertColumnInput], return_columns: &[String], ) -> Result<InsertedRow, PgError>
Insert one row, returning the requested columns. Runs on the
session’s connection so any session-local state (SET,
transactions) applies. See edit::insert_row for the SQL
shape and parameter rules.
Sourcepub async fn delete_rows(
&self,
session_id: &str,
schema: &str,
table: &str,
ctids: &[String],
) -> Result<UpdateOutcome, PgError>
pub async fn delete_rows( &self, session_id: &str, schema: &str, table: &str, ctids: &[String], ) -> Result<UpdateOutcome, PgError>
Delete one or more rows by ctid on the session’s connection. Returns the actual rows-deleted count — callers compare against the requested count to spot “some rows were already gone” (concurrent edit / delete from another session).
pub async fn close_query( &self, session_id: &str, cursor_id: &str, ) -> Result<(), PgError>
Sourcepub async fn cancel(&self, session_id: &str) -> Result<(), PgError>
pub async fn cancel(&self, session_id: &str) -> Result<(), PgError>
Server-side cancel for whatever query is in flight on the session’s connection. Uses the same TLS posture as the data wire — TLS-only Postgres deployments (RDS, Supabase, Neon) reject plaintext cancels, which would silently leave the in-flight query running until it timed out. No-op if the session has no lease.
Sourcepub async fn release_session(&self, session_id: &str)
pub async fn release_session(&self, session_id: &str)
Release a session’s lease. Closes any active cursor first so the underlying connection returns to idle in a clean state.