Struct coord::session::Session [−][src]
pub struct Session {
conn_id: u32,
prepared_statements: HashMap<String, PreparedStatement>,
portals: HashMap<String, Portal>,
transaction: TransactionStatus,
pcx: Option<PlanContext>,
user: String,
vars: Vars,
drop_sinks: Vec<GlobalId>,
}
Expand description
A session holds per-connection state.
Fields
conn_id: u32
prepared_statements: HashMap<String, PreparedStatement>
portals: HashMap<String, Portal>
transaction: TransactionStatus
pcx: Option<PlanContext>
user: String
vars: Vars
drop_sinks: Vec<GlobalId>
Implementations
Creates a new session for the specified connection ID.
Creates a new dummy session.
Dummy sessions are intended for use when executing queries on behalf of the system itself, rather than on behalf of a user.
Returns the current transaction’s PlanContext. Panics if there is not a current transaction.
pub fn start_transaction(
self,
wall_time: DateTime<Utc>,
access: Option<TransactionAccessMode>
) -> Self
pub fn start_transaction(
self,
wall_time: DateTime<Utc>,
access: Option<TransactionAccessMode>
) -> Self
Starts an explicit transaction, or changes an implicit to an explicit transaction.
Starts either a single statement or implicit transaction based on the number of statements, but only if no transaction has been started already.
Clears a transaction, setting its state to Default and destroying all portals. Returned are:
- sinks that were started in this transaction and need to be dropped
- the cleared transaction so its operations can be handled
The Postgres protocol docs specify:
a named portal object lasts till the end of the current transaction and An unnamed portal is destroyed at the end of the transaction
Marks the current transaction as failed.
Returns the current transaction status.
Adds operations to the current transaction. An error is produced if they cannot be merged (i.e., a read cannot be merged to an insert).
Adds a sink that will need to be dropped when the current transaction is cleared.
Sets the transaction ops to TransactionOps::None
. Must only be used after
verifying that no transaction anomolies will occur if cleared.
pub fn get_transaction_timestamp<F: FnMut() -> Result<Timestamp, CoordError>>(
&mut self,
get_ts: F
) -> Result<Timestamp, CoordError>
pub fn get_transaction_timestamp<F: FnMut() -> Result<Timestamp, CoordError>>(
&mut self,
get_ts: F
) -> Result<Timestamp, CoordError>
Assumes an active transaction. Returns its read timestamp. Errors if not a read transaction. Calls get_ts to get a timestamp if the transaction doesn’t have an operation yet, converting the transaction to a read.
Registers the prepared statement under name
.
Removes the prepared statement associated with name
.
Returns whether a statement previously existed.
Removes all prepared statements.
Retrieves the prepared statement associated with name
.
This is unverified and could be incorrect if the underlying catalog has changed.
pub fn get_prepared_statement_mut_unverified(
&mut self,
name: &str
) -> Option<&mut PreparedStatement>
pub fn get_prepared_statement_mut_unverified(
&mut self,
name: &str
) -> Option<&mut PreparedStatement>
Retrieves the prepared statement associated with name
.
This is unverified and could be incorrect if the underlying catalog has changed.
Returns the prepared statements for the session.
pub fn set_portal(
&mut self,
portal_name: String,
desc: StatementDesc,
stmt: Option<Statement<Raw>>,
params: Vec<(Datum<'_>, ScalarType)>,
result_formats: Vec<Format>
) -> Result<(), CoordError>
pub fn set_portal(
&mut self,
portal_name: String,
desc: StatementDesc,
stmt: Option<Statement<Raw>>,
params: Vec<(Datum<'_>, ScalarType)>,
result_formats: Vec<Format>
) -> Result<(), CoordError>
Binds the specified portal to the specified prepared statement.
If the prepared statement contains parameters, the values and types of
those parameters must be provided in params
. It is the caller’s
responsibility to ensure that the correct number of parameters is
provided.
and is stored on the portal.
Removes the specified portal.
If there is no such portal, this method does nothing. Returns whether that portal existed.
Retrieves a reference to the specified portal.
If there is no such portal, returns None
.
Retrieves a mutable reference to the specified portal.
If there is no such portal, returns None
.
pub fn create_new_portal(
&mut self,
stmt: Option<Statement<Raw>>,
desc: StatementDesc,
parameters: Params,
result_formats: Vec<Format>
) -> Result<String, CoordError>
pub fn create_new_portal(
&mut self,
stmt: Option<Statement<Raw>>,
desc: StatementDesc,
parameters: Params,
result_formats: Vec<Format>
) -> Result<String, CoordError>
Creates and installs a new portal.
Resets the session to its initial state. Returns sinks that need to be dropped.
Returns a mutable reference to the variables in this session.
Grants the coordinator’s write lock guard to this session’s inner transaction.
Panics
If the inner transaction is idle. See
TransactionStatus::grant_write_lock
.
Returns whether or not this session currently holds the write lock.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Session
impl !UnwindSafe for Session
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more