Skip to main content

PgPool

Struct PgPool 

Source
pub struct PgPool { /* private fields */ }

Implementations§

Source§

impl PgPool

Source

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.

Source

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.

Source

pub async fn list_schemas(&self) -> Result<Vec<SchemaSummary>, PgError>

Source

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.

Source

pub async fn list_relations( &self, schema: &str, ) -> Result<Vec<Relation>, PgError>

Source

pub async fn list_relations_in( &self, schema: &str, database: Option<&str>, ) -> Result<Vec<Relation>, PgError>

Source

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.

Source

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.

Source

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).

Source

pub async fn fetch_page( &self, session_id: &str, cursor_id: &str, count: usize, ) -> Result<PageResult, PgError>

Source

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”.

Source

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.

Source

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).

Source

pub async fn close_query( &self, session_id: &str, cursor_id: &str, ) -> Result<(), PgError>

Source

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.

Source

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.

Source

pub async fn shutdown(&self)

Tear down all connections. Used on disconnect.

Trait Implementations§

Source§

impl Drop for PgPool

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for PgPool

§

impl !RefUnwindSafe for PgPool

§

impl Send for PgPool

§

impl Sync for PgPool

§

impl Unpin for PgPool

§

impl UnsafeUnpin for PgPool

§

impl !UnwindSafe for PgPool

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more