Struct Session

Source
pub struct Session {
Show 26 fields pub in_transaction: bool, pub shard_sessions: Vec<ShardSession>, pub autocommit: bool, pub target_string: String, pub options: Option<ExecuteOptions>, pub transaction_mode: i32, pub warnings: Vec<QueryWarning>, pub pre_sessions: Vec<ShardSession>, pub post_sessions: Vec<ShardSession>, pub last_insert_id: u64, pub found_rows: u64, pub user_defined_variables: HashMap<String, BindVariable>, pub system_variables: HashMap<String, String>, pub row_count: i64, pub savepoints: Vec<String>, pub in_reserved_conn: bool, pub lock_session: Option<ShardSession>, pub last_lock_heartbeat: i64, pub read_after_write: Option<ReadAfterWrite>, pub ddl_strategy: String, pub session_uuid: String, pub enable_system_settings: bool, pub advisory_lock: HashMap<String, i64>, pub query_timeout: i64, pub prepare_statement: HashMap<String, PrepareData>, pub migration_context: String,
}
Expand description

Session objects are exchanged like cookies through various calls to VTGate. The behavior differs between V2 & V3 APIs. V3 APIs are Execute, ExecuteBatch and StreamExecute. All other APIs are V2. For the V3 APIs, the session must be sent with every call to Execute or ExecuteBatch. For the V2 APIs, Begin does not accept a session. It instead returns a brand new one with in_transaction set to true. After a call to Commit or Rollback, the session can be discarded. If you’re not in a transaction, Session is an optional parameter for the V2 APIs.

Fields§

§in_transaction: bool

in_transaction is set to true if the session is in a transaction.

§shard_sessions: Vec<ShardSession>

shard_sessions keep track of per-shard transaction info.

§autocommit: bool

autocommit specifies if the session is in autocommit mode. This is used only for V3.

§target_string: String

target_string is the target expressed as a string. Valid names are: keyspace:shard@target, keyspace@target or @target. This is used only for V3.

§options: Option<ExecuteOptions>

options is used only for V3.

§transaction_mode: i32

transaction_mode specifies the current transaction mode.

§warnings: Vec<QueryWarning>

warnings contains non-fatal warnings from the previous query

§pre_sessions: Vec<ShardSession>

pre_sessions contains sessions that have to be committed first.

§post_sessions: Vec<ShardSession>

post_sessions contains sessions that have to be committed last.

§last_insert_id: u64

last_insert_id keeps track of the last seen insert_id for this session

§found_rows: u64

found_rows keeps track of how many rows the last query returned

§user_defined_variables: HashMap<String, BindVariable>

user_defined_variables contains all the @variables defined for this session

§system_variables: HashMap<String, String>

system_variables keeps track of all session variables set for this connection TODO: systay should we keep this so we can apply it ordered?

§row_count: i64

row_count keeps track of the last seen rows affected for this session

§savepoints: Vec<String>

Stores savepoint and release savepoint calls inside a transaction and is reset once transaction is committed or rolled back.

§in_reserved_conn: bool

in_reserved_conn is set to true if the session should be using reserved connections.

§lock_session: Option<ShardSession>

lock_session keep tracks of shard on which the lock query is sent.

§last_lock_heartbeat: i64

last_lock_heartbeat keep tracks of when last lock heartbeat was sent.

§read_after_write: Option<ReadAfterWrite>

read_after_write tracks the ReadAfterWrite settings for this session.

§ddl_strategy: String

DDL strategy

§session_uuid: String

Session UUID

§enable_system_settings: bool

enable_system_settings defines if we can use reserved connections.

§advisory_lock: HashMap<String, i64>§query_timeout: i64

query_timeout is the maximum amount of time a query is permitted to run

§prepare_statement: HashMap<String, PrepareData>§migration_context: String

MigrationContext

Implementations§

Source§

impl Session

Source

pub fn transaction_mode(&self) -> TransactionMode

Returns the enum value of transaction_mode, or the default if the field is set to an invalid enum value.

Source

pub fn set_transaction_mode(&mut self, value: TransactionMode)

Sets transaction_mode to the provided enum value.

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Session

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Session

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Message for Session

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for Session

Source§

fn eq(&self, other: &Session) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Session

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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