pub struct PoolGuard { /* private fields */ }Expand description
A borrowed connection from the pool. Returns to the pool on drop.
If the connection is in a failed transaction state, broken, or marked for discard, it is dropped (decrements open_count) instead of returned.
Implementations§
Source§impl PoolGuard
impl PoolGuard
Sourcepub fn mark_discard(&mut self)
pub fn mark_discard(&mut self)
Mark this connection for discard — it will NOT be returned to the pool on drop. The open_count is decremented and the TCP connection is closed.
Sourcepub fn cancel(&self) -> Result<(), DriverError>
pub fn cancel(&self) -> Result<(), DriverError>
Cancel the currently running query on the underlying connection.
Opens a new TCP connection and sends a CancelRequest to PG. The cancel connection is closed immediately after.
Sourcepub fn is_in_transaction(&self) -> bool
pub fn is_in_transaction(&self) -> bool
Whether the connection is inside a transaction.
Sourcepub fn query(
&mut self,
sql: &str,
sql_hash: u64,
params: &[&(dyn Encode + Sync)],
) -> Result<QueryResult, DriverError>
pub fn query( &mut self, sql: &str, sql_hash: u64, params: &[&(dyn Encode + Sync)], ) -> Result<QueryResult, DriverError>
Execute a prepared query and return rows.
Sourcepub fn execute(
&mut self,
sql: &str,
sql_hash: u64,
params: &[&(dyn Encode + Sync)],
) -> Result<u64, DriverError>
pub fn execute( &mut self, sql: &str, sql_hash: u64, params: &[&(dyn Encode + Sync)], ) -> Result<u64, DriverError>
Execute a query without result rows (INSERT/UPDATE/DELETE).
Sourcepub fn execute_pipeline(
&mut self,
sql: &str,
sql_hash: u64,
param_sets: &[&[&(dyn Encode + Sync)]],
) -> Result<Vec<u64>, DriverError>
pub fn execute_pipeline( &mut self, sql: &str, sql_hash: u64, param_sets: &[&[&(dyn Encode + Sync)]], ) -> Result<Vec<u64>, DriverError>
Execute the same statement N times with different params in one pipeline.
Sends all N Bind+Execute messages + one Sync. One round-trip for N operations. Returns the affected row count for each parameter set.
Sourcepub fn simple_query(&mut self, sql: &str) -> Result<(), DriverError>
pub fn simple_query(&mut self, sql: &str) -> Result<(), DriverError>
Execute a simple (unprepared) query.
Sourcepub fn simple_query_rows(
&mut self,
sql: &str,
) -> Result<Vec<SimpleRow>, DriverError>
pub fn simple_query_rows( &mut self, sql: &str, ) -> Result<Vec<SimpleRow>, DriverError>
Execute a simple query and return rows as text.
Uses PostgreSQL’s simple query protocol — all values are strings.
Sourcepub fn for_each<F>(
&mut self,
sql: &str,
sql_hash: u64,
params: &[&(dyn Encode + Sync)],
f: F,
) -> Result<(), DriverError>
pub fn for_each<F>( &mut self, sql: &str, sql_hash: u64, params: &[&(dyn Encode + Sync)], f: F, ) -> Result<(), DriverError>
Process each row via a closure with zero-copy PgDataRow.
Sourcepub fn for_each_raw<F>(
&mut self,
sql: &str,
sql_hash: u64,
params: &[&(dyn Encode + Sync)],
f: F,
) -> Result<(), DriverError>
pub fn for_each_raw<F>( &mut self, sql: &str, sql_hash: u64, params: &[&(dyn Encode + Sync)], f: F, ) -> Result<(), DriverError>
Process each DataRow as raw bytes — fastest path.
Sourcepub fn query_streaming_start(
&mut self,
sql: &str,
sql_hash: u64,
params: &[&(dyn Encode + Sync)],
chunk_size: i32,
) -> Result<(Arc<[ColumnDesc]>, bool), DriverError>
pub fn query_streaming_start( &mut self, sql: &str, sql_hash: u64, params: &[&(dyn Encode + Sync)], chunk_size: i32, ) -> Result<(Arc<[ColumnDesc]>, bool), DriverError>
Start a streaming query.
Sourcepub fn streaming_send_execute(
&mut self,
chunk_size: i32,
) -> Result<(), DriverError>
pub fn streaming_send_execute( &mut self, chunk_size: i32, ) -> Result<(), DriverError>
Send Execute+Flush for a streaming query (2nd+ chunks).
Sourcepub fn streaming_next_chunk(
&mut self,
arena: &mut Arena,
all_col_offsets: &mut Vec<(usize, i32)>,
) -> Result<bool, DriverError>
pub fn streaming_next_chunk( &mut self, arena: &mut Arena, all_col_offsets: &mut Vec<(usize, i32)>, ) -> Result<bool, DriverError>
Read the next chunk of rows from an in-progress streaming query.
Sourcepub fn copy_in<'a, I>(
&mut self,
table: &str,
columns: &[&str],
rows: I,
) -> Result<u64, DriverError>where
I: IntoIterator<Item = &'a str>,
pub fn copy_in<'a, I>(
&mut self,
table: &str,
columns: &[&str],
rows: I,
) -> Result<u64, DriverError>where
I: IntoIterator<Item = &'a str>,
Bulk copy data INTO a table from an iterator of text rows.
Each row is a tab-separated string (TSV format). Returns the row count.