pub struct Session<T = Timestamp> {
    conn_id: u32,
    prepared_statements: HashMap<String, PreparedStatement>,
    portals: HashMap<String, Portal>,
    transaction: TransactionStatus<T>,
    pcx: Option<PlanContext>,
    user: String,
    vars: Vars,
    drop_sinks: Vec<(ComputeInstanceId, GlobalId)>,
}
Expand description

A session holds per-connection state.

Fields

conn_id: u32prepared_statements: HashMap<String, PreparedStatement>portals: HashMap<String, Portal>transaction: TransactionStatus<T>pcx: Option<PlanContext>user: Stringvars: Varsdrop_sinks: Vec<(ComputeInstanceId, 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 connection ID associated with the session.

Returns the current transaction’s PlanContext. Panics if there is not a current transaction.

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 anomalies will occur if cleared.

Returns the transaction’s read timestamp, if set.

Returns None if there is no active transaction, or if the active transaction is not a read transaction.

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.

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.

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.

Creates and installs a new portal.

Resets the session to its initial state. Returns sinks that need to be dropped.

Returns the name of the user who owns this session.

Returns a reference to the variables in this session.

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more

Attaches the current Context to this type, returning a WithContext wrapper. Read more

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

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

Calls U::from(self).

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

Wrap the input message T in a tonic::Request

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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