vitess_grpc/generated/
vtgate.rs

1/// Session objects are exchanged like cookies through various
2/// calls to VTGate. The behavior differs between V2 & V3 APIs.
3/// V3 APIs are Execute, ExecuteBatch and StreamExecute. All
4/// other APIs are V2. For the V3 APIs, the session
5/// must be sent with every call to Execute or ExecuteBatch.
6/// For the V2 APIs, Begin does not accept a session. It instead
7/// returns a brand new one with in_transaction set to true.
8/// After a call to Commit or Rollback, the session can be
9/// discarded. If you're not in a transaction, Session is
10/// an optional parameter for the V2 APIs.
11#[allow(clippy::derive_partial_eq_without_eq)]
12#[derive(Clone, PartialEq, ::prost::Message)]
13pub struct Session {
14    /// in_transaction is set to true if the session is in a transaction.
15    #[prost(bool, tag = "1")]
16    pub in_transaction: bool,
17    /// shard_sessions keep track of per-shard transaction info.
18    #[prost(message, repeated, tag = "2")]
19    pub shard_sessions: ::prost::alloc::vec::Vec<session::ShardSession>,
20    /// autocommit specifies if the session is in autocommit mode.
21    /// This is used only for V3.
22    #[prost(bool, tag = "4")]
23    pub autocommit: bool,
24    /// target_string is the target expressed as a string. Valid
25    /// names are: keyspace:shard@target, keyspace@target or @target.
26    /// This is used only for V3.
27    #[prost(string, tag = "5")]
28    pub target_string: ::prost::alloc::string::String,
29    /// options is used only for V3.
30    #[prost(message, optional, tag = "6")]
31    pub options: ::core::option::Option<super::query::ExecuteOptions>,
32    /// transaction_mode specifies the current transaction mode.
33    #[prost(enumeration = "TransactionMode", tag = "7")]
34    pub transaction_mode: i32,
35    /// warnings contains non-fatal warnings from the previous query
36    #[prost(message, repeated, tag = "8")]
37    pub warnings: ::prost::alloc::vec::Vec<super::query::QueryWarning>,
38    /// pre_sessions contains sessions that have to be committed first.
39    #[prost(message, repeated, tag = "9")]
40    pub pre_sessions: ::prost::alloc::vec::Vec<session::ShardSession>,
41    /// post_sessions contains sessions that have to be committed last.
42    #[prost(message, repeated, tag = "10")]
43    pub post_sessions: ::prost::alloc::vec::Vec<session::ShardSession>,
44    /// last_insert_id keeps track of the last seen insert_id for this session
45    #[prost(uint64, tag = "11")]
46    pub last_insert_id: u64,
47    /// found_rows keeps track of how many rows the last query returned
48    #[prost(uint64, tag = "12")]
49    pub found_rows: u64,
50    /// user_defined_variables contains all the @variables defined for this session
51    #[prost(map = "string, message", tag = "13")]
52    pub user_defined_variables: ::std::collections::HashMap<
53        ::prost::alloc::string::String,
54        super::query::BindVariable,
55    >,
56    /// system_variables keeps track of all session variables set for this connection
57    /// TODO: systay should we keep this so we can apply it ordered?
58    #[prost(map = "string, string", tag = "14")]
59    pub system_variables: ::std::collections::HashMap<
60        ::prost::alloc::string::String,
61        ::prost::alloc::string::String,
62    >,
63    /// row_count keeps track of the last seen rows affected for this session
64    #[prost(int64, tag = "15")]
65    pub row_count: i64,
66    /// Stores savepoint and release savepoint calls inside a transaction
67    /// and is reset once transaction is committed or rolled back.
68    #[prost(string, repeated, tag = "16")]
69    pub savepoints: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
70    /// in_reserved_conn is set to true if the session should be using reserved connections.
71    #[prost(bool, tag = "17")]
72    pub in_reserved_conn: bool,
73    /// lock_session keep tracks of shard on which the lock query is sent.
74    #[prost(message, optional, tag = "18")]
75    pub lock_session: ::core::option::Option<session::ShardSession>,
76    /// last_lock_heartbeat keep tracks of when last lock heartbeat was sent.
77    #[prost(int64, tag = "19")]
78    pub last_lock_heartbeat: i64,
79    /// read_after_write tracks the ReadAfterWrite settings for this session.
80    #[prost(message, optional, tag = "20")]
81    pub read_after_write: ::core::option::Option<ReadAfterWrite>,
82    /// DDL strategy
83    #[prost(string, tag = "21")]
84    pub ddl_strategy: ::prost::alloc::string::String,
85    /// Session UUID
86    #[prost(string, tag = "22")]
87    pub session_uuid: ::prost::alloc::string::String,
88    /// enable_system_settings defines if we can use reserved connections.
89    #[prost(bool, tag = "23")]
90    pub enable_system_settings: bool,
91    #[prost(map = "string, int64", tag = "24")]
92    pub advisory_lock: ::std::collections::HashMap<::prost::alloc::string::String, i64>,
93    /// query_timeout is the maximum amount of time a query is permitted to run
94    #[prost(int64, tag = "25")]
95    pub query_timeout: i64,
96    #[prost(map = "string, message", tag = "26")]
97    pub prepare_statement: ::std::collections::HashMap<
98        ::prost::alloc::string::String,
99        PrepareData,
100    >,
101    /// MigrationContext
102    #[prost(string, tag = "27")]
103    pub migration_context: ::prost::alloc::string::String,
104}
105/// Nested message and enum types in `Session`.
106pub mod session {
107    #[allow(clippy::derive_partial_eq_without_eq)]
108    #[derive(Clone, PartialEq, ::prost::Message)]
109    pub struct ShardSession {
110        #[prost(message, optional, tag = "1")]
111        pub target: ::core::option::Option<super::super::query::Target>,
112        #[prost(int64, tag = "2")]
113        pub transaction_id: i64,
114        #[prost(message, optional, tag = "3")]
115        pub tablet_alias: ::core::option::Option<super::super::topodata::TabletAlias>,
116        /// reserved connection if a dedicated connection is needed
117        #[prost(int64, tag = "4")]
118        pub reserved_id: i64,
119        #[prost(bool, tag = "5")]
120        pub vindex_only: bool,
121    }
122}
123/// PrepareData keeps the prepared statement and other information related for execution of it.
124#[allow(clippy::derive_partial_eq_without_eq)]
125#[derive(Clone, PartialEq, ::prost::Message)]
126pub struct PrepareData {
127    #[prost(string, tag = "1")]
128    pub prepare_statement: ::prost::alloc::string::String,
129    #[prost(int32, tag = "2")]
130    pub params_count: i32,
131}
132/// ReadAfterWrite contains information regarding gtid set and timeout
133/// Also if the gtid information needs to be passed to client.
134#[allow(clippy::derive_partial_eq_without_eq)]
135#[derive(Clone, PartialEq, ::prost::Message)]
136pub struct ReadAfterWrite {
137    #[prost(string, tag = "1")]
138    pub read_after_write_gtid: ::prost::alloc::string::String,
139    #[prost(double, tag = "2")]
140    pub read_after_write_timeout: f64,
141    #[prost(bool, tag = "3")]
142    pub session_track_gtids: bool,
143}
144/// ExecuteRequest is the payload to Execute.
145#[allow(clippy::derive_partial_eq_without_eq)]
146#[derive(Clone, PartialEq, ::prost::Message)]
147pub struct ExecuteRequest {
148    /// caller_id identifies the caller. This is the effective caller ID,
149    /// set by the application to further identify the caller.
150    #[prost(message, optional, tag = "1")]
151    pub caller_id: ::core::option::Option<super::vtrpc::CallerId>,
152    /// session carries the session state.
153    #[prost(message, optional, tag = "2")]
154    pub session: ::core::option::Option<Session>,
155    /// query is the query and bind variables to execute.
156    #[prost(message, optional, tag = "3")]
157    pub query: ::core::option::Option<super::query::BoundQuery>,
158}
159/// ExecuteResponse is the returned value from Execute.
160#[allow(clippy::derive_partial_eq_without_eq)]
161#[derive(Clone, PartialEq, ::prost::Message)]
162pub struct ExecuteResponse {
163    /// error contains an application level error if necessary. Note the
164    /// session may have changed, even when an error is returned (for
165    /// instance if a database integrity error happened).
166    #[prost(message, optional, tag = "1")]
167    pub error: ::core::option::Option<super::vtrpc::RpcError>,
168    /// session is the updated session information.
169    #[prost(message, optional, tag = "2")]
170    pub session: ::core::option::Option<Session>,
171    /// result contains the query result, only set if error is unset.
172    #[prost(message, optional, tag = "3")]
173    pub result: ::core::option::Option<super::query::QueryResult>,
174}
175/// ExecuteBatchRequest is the payload to ExecuteBatch.
176#[allow(clippy::derive_partial_eq_without_eq)]
177#[derive(Clone, PartialEq, ::prost::Message)]
178pub struct ExecuteBatchRequest {
179    /// caller_id identifies the caller. This is the effective caller ID,
180    /// set by the application to further identify the caller.
181    #[prost(message, optional, tag = "1")]
182    pub caller_id: ::core::option::Option<super::vtrpc::CallerId>,
183    /// session carries the session state.
184    #[prost(message, optional, tag = "2")]
185    pub session: ::core::option::Option<Session>,
186    /// queries is a list of query and bind variables to execute.
187    #[prost(message, repeated, tag = "3")]
188    pub queries: ::prost::alloc::vec::Vec<super::query::BoundQuery>,
189}
190/// ExecuteBatchResponse is the returned value from ExecuteBatch.
191#[allow(clippy::derive_partial_eq_without_eq)]
192#[derive(Clone, PartialEq, ::prost::Message)]
193pub struct ExecuteBatchResponse {
194    /// error contains an application level error if necessary. Note the
195    /// session may have changed, even when an error is returned (for
196    /// instance if a database integrity error happened).
197    #[prost(message, optional, tag = "1")]
198    pub error: ::core::option::Option<super::vtrpc::RpcError>,
199    /// session is the updated session information.
200    #[prost(message, optional, tag = "2")]
201    pub session: ::core::option::Option<Session>,
202    /// results contains the query results, only set if application level error is unset.
203    #[prost(message, repeated, tag = "3")]
204    pub results: ::prost::alloc::vec::Vec<super::query::ResultWithError>,
205}
206/// StreamExecuteRequest is the payload to StreamExecute.
207#[allow(clippy::derive_partial_eq_without_eq)]
208#[derive(Clone, PartialEq, ::prost::Message)]
209pub struct StreamExecuteRequest {
210    /// caller_id identifies the caller. This is the effective caller ID,
211    /// set by the application to further identify the caller.
212    #[prost(message, optional, tag = "1")]
213    pub caller_id: ::core::option::Option<super::vtrpc::CallerId>,
214    /// query is the query and bind variables to execute.
215    #[prost(message, optional, tag = "2")]
216    pub query: ::core::option::Option<super::query::BoundQuery>,
217    /// session carries the session state.
218    #[prost(message, optional, tag = "6")]
219    pub session: ::core::option::Option<Session>,
220}
221/// StreamExecuteResponse is the returned value from StreamExecute.
222/// The session is currently not returned because StreamExecute is
223/// not expected to modify it.
224#[allow(clippy::derive_partial_eq_without_eq)]
225#[derive(Clone, PartialEq, ::prost::Message)]
226pub struct StreamExecuteResponse {
227    /// result contains the result data.
228    /// The first value contains only Fields information.
229    /// The next values contain the actual rows, a few values per result.
230    #[prost(message, optional, tag = "1")]
231    pub result: ::core::option::Option<super::query::QueryResult>,
232    /// session is the updated session information.
233    #[prost(message, optional, tag = "2")]
234    pub session: ::core::option::Option<Session>,
235}
236/// ResolveTransactionRequest is the payload to ResolveTransaction.
237#[allow(clippy::derive_partial_eq_without_eq)]
238#[derive(Clone, PartialEq, ::prost::Message)]
239pub struct ResolveTransactionRequest {
240    /// caller_id identifies the caller. This is the effective caller ID,
241    /// set by the application to further identify the caller.
242    #[prost(message, optional, tag = "1")]
243    pub caller_id: ::core::option::Option<super::vtrpc::CallerId>,
244    /// dtid is the dtid of the transaction to be resolved.
245    #[prost(string, tag = "2")]
246    pub dtid: ::prost::alloc::string::String,
247}
248/// ResolveTransactionResponse is the returned value from Rollback.
249#[allow(clippy::derive_partial_eq_without_eq)]
250#[derive(Clone, PartialEq, ::prost::Message)]
251pub struct ResolveTransactionResponse {}
252#[allow(clippy::derive_partial_eq_without_eq)]
253#[derive(Clone, PartialEq, ::prost::Message)]
254pub struct VStreamFlags {
255    /// align streams
256    #[prost(bool, tag = "1")]
257    pub minimize_skew: bool,
258    /// how often heartbeats must be sent when idle (seconds)
259    #[prost(uint32, tag = "2")]
260    pub heartbeat_interval: u32,
261    /// stop streams on a reshard (journal event)
262    #[prost(bool, tag = "3")]
263    pub stop_on_reshard: bool,
264    /// if specified, these cells (comma-separated) are used to pick source tablets from.
265    /// defaults to the cell of the vtgate serving the VStream API.
266    #[prost(string, tag = "4")]
267    pub cells: ::prost::alloc::string::String,
268    #[prost(string, tag = "5")]
269    pub cell_preference: ::prost::alloc::string::String,
270    #[prost(string, tag = "6")]
271    pub tablet_order: ::prost::alloc::string::String,
272}
273/// VStreamRequest is the payload for VStream.
274#[allow(clippy::derive_partial_eq_without_eq)]
275#[derive(Clone, PartialEq, ::prost::Message)]
276pub struct VStreamRequest {
277    #[prost(message, optional, tag = "1")]
278    pub caller_id: ::core::option::Option<super::vtrpc::CallerId>,
279    #[prost(enumeration = "super::topodata::TabletType", tag = "2")]
280    pub tablet_type: i32,
281    /// position specifies the starting point of the bin log positions
282    /// as well as the keyspace-shards to pull events from.
283    /// position is of the form 'ks1:0@MySQL56/<mysql_pos>|ks2:-80@MySQL56/<mysql_pos>'.
284    #[prost(message, optional, tag = "3")]
285    pub vgtid: ::core::option::Option<super::binlogdata::VGtid>,
286    #[prost(message, optional, tag = "4")]
287    pub filter: ::core::option::Option<super::binlogdata::Filter>,
288    #[prost(message, optional, tag = "5")]
289    pub flags: ::core::option::Option<VStreamFlags>,
290}
291/// VStreamResponse is streamed by VStream.
292#[allow(clippy::derive_partial_eq_without_eq)]
293#[derive(Clone, PartialEq, ::prost::Message)]
294pub struct VStreamResponse {
295    #[prost(message, repeated, tag = "1")]
296    pub events: ::prost::alloc::vec::Vec<super::binlogdata::VEvent>,
297}
298/// PrepareRequest is the payload to Prepare.
299#[allow(clippy::derive_partial_eq_without_eq)]
300#[derive(Clone, PartialEq, ::prost::Message)]
301pub struct PrepareRequest {
302    /// caller_id identifies the caller. This is the effective caller ID,
303    /// set by the application to further identify the caller.
304    #[prost(message, optional, tag = "1")]
305    pub caller_id: ::core::option::Option<super::vtrpc::CallerId>,
306    /// session carries the session state.
307    #[prost(message, optional, tag = "2")]
308    pub session: ::core::option::Option<Session>,
309    /// query is the query and bind variables to execute.
310    #[prost(message, optional, tag = "3")]
311    pub query: ::core::option::Option<super::query::BoundQuery>,
312}
313/// PrepareResponse is the returned value from Prepare.
314#[allow(clippy::derive_partial_eq_without_eq)]
315#[derive(Clone, PartialEq, ::prost::Message)]
316pub struct PrepareResponse {
317    /// error contains an application level error if necessary. Note the
318    /// session may have changed, even when an error is returned (for
319    /// instance if a database integrity error happened).
320    #[prost(message, optional, tag = "1")]
321    pub error: ::core::option::Option<super::vtrpc::RpcError>,
322    /// session is the updated session information.
323    #[prost(message, optional, tag = "2")]
324    pub session: ::core::option::Option<Session>,
325    /// fields contains the fields, only set if error is unset.
326    #[prost(message, repeated, tag = "3")]
327    pub fields: ::prost::alloc::vec::Vec<super::query::Field>,
328}
329/// CloseSessionRequest is the payload to CloseSession.
330#[allow(clippy::derive_partial_eq_without_eq)]
331#[derive(Clone, PartialEq, ::prost::Message)]
332pub struct CloseSessionRequest {
333    /// caller_id identifies the caller. This is the effective caller ID,
334    /// set by the application to further identify the caller.
335    #[prost(message, optional, tag = "1")]
336    pub caller_id: ::core::option::Option<super::vtrpc::CallerId>,
337    /// session carries the session state.
338    #[prost(message, optional, tag = "2")]
339    pub session: ::core::option::Option<Session>,
340}
341/// CloseSessionResponse is the returned value from CloseSession.
342#[allow(clippy::derive_partial_eq_without_eq)]
343#[derive(Clone, PartialEq, ::prost::Message)]
344pub struct CloseSessionResponse {
345    /// error contains an application level error if necessary. Note the
346    /// session may have changed, even when an error is returned (for
347    /// instance if a database integrity error happened).
348    #[prost(message, optional, tag = "1")]
349    pub error: ::core::option::Option<super::vtrpc::RpcError>,
350}
351/// TransactionMode controls the execution of distributed transaction
352/// across multiple shards.
353#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
354#[repr(i32)]
355pub enum TransactionMode {
356    /// UNSPECIFIED uses the transaction mode set by the VTGate flag 'transaction_mode'.
357    Unspecified = 0,
358    /// SINGLE disallows distributed transactions.
359    Single = 1,
360    /// MULTI allows distributed transactions with best effort commit.
361    Multi = 2,
362    /// TWOPC is for distributed transactions with atomic commits.
363    Twopc = 3,
364}
365impl TransactionMode {
366    /// String value of the enum field names used in the ProtoBuf definition.
367    ///
368    /// The values are not transformed in any way and thus are considered stable
369    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
370    pub fn as_str_name(&self) -> &'static str {
371        match self {
372            TransactionMode::Unspecified => "UNSPECIFIED",
373            TransactionMode::Single => "SINGLE",
374            TransactionMode::Multi => "MULTI",
375            TransactionMode::Twopc => "TWOPC",
376        }
377    }
378    /// Creates an enum from field names used in the ProtoBuf definition.
379    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
380        match value {
381            "UNSPECIFIED" => Some(Self::Unspecified),
382            "SINGLE" => Some(Self::Single),
383            "MULTI" => Some(Self::Multi),
384            "TWOPC" => Some(Self::Twopc),
385            _ => None,
386        }
387    }
388}
389/// CommitOrder is used to designate which of the ShardSessions
390/// get used for transactions.
391#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
392#[repr(i32)]
393pub enum CommitOrder {
394    /// NORMAL is the default commit order.
395    Normal = 0,
396    /// PRE is used to designate pre_sessions.
397    Pre = 1,
398    /// POST is used to designate post_sessions.
399    Post = 2,
400    /// AUTOCOMMIT is used to run the statement as autocommitted transaction.
401    Autocommit = 3,
402}
403impl CommitOrder {
404    /// String value of the enum field names used in the ProtoBuf definition.
405    ///
406    /// The values are not transformed in any way and thus are considered stable
407    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
408    pub fn as_str_name(&self) -> &'static str {
409        match self {
410            CommitOrder::Normal => "NORMAL",
411            CommitOrder::Pre => "PRE",
412            CommitOrder::Post => "POST",
413            CommitOrder::Autocommit => "AUTOCOMMIT",
414        }
415    }
416    /// Creates an enum from field names used in the ProtoBuf definition.
417    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
418        match value {
419            "NORMAL" => Some(Self::Normal),
420            "PRE" => Some(Self::Pre),
421            "POST" => Some(Self::Post),
422            "AUTOCOMMIT" => Some(Self::Autocommit),
423            _ => None,
424        }
425    }
426}