vitess.io/vitess@v0.16.2/proto/vtgate.proto (about)

     1  /*
     2  Copyright 2019 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // Data definitions for service vtgateservice.
    18  
    19  syntax = "proto3";
    20  option go_package = "vitess.io/vitess/go/vt/proto/vtgate";
    21  
    22  package vtgate;
    23  
    24  option java_package = "io.vitess.proto";
    25  
    26  import "binlogdata.proto";
    27  import "query.proto";
    28  import "topodata.proto";
    29  import "vtrpc.proto";
    30  
    31  // TransactionMode controls the execution of distributed transaction
    32  // across multiple shards.
    33  enum TransactionMode {
    34    // UNSPECIFIED uses the transaction mode set by the VTGate flag 'transaction_mode'.
    35    UNSPECIFIED = 0;
    36    // SINGLE disallows distributed transactions.
    37    SINGLE = 1;
    38    // MULTI allows distributed transactions with best effort commit.
    39    MULTI = 2;
    40    // TWOPC is for distributed transactions with atomic commits.
    41    TWOPC = 3;
    42  }
    43  
    44  
    45  // CommitOrder is used to designate which of the ShardSessions
    46  // get used for transactions.
    47  enum CommitOrder {
    48    // NORMAL is the default commit order.
    49    NORMAL = 0;
    50    // PRE is used to designate pre_sessions.
    51    PRE = 1;
    52    // POST is used to designate post_sessions.
    53    POST = 2;
    54    // AUTOCOMMIT is used to run the statement as autocommitted transaction.
    55    AUTOCOMMIT = 3;
    56  }
    57  
    58  // Session objects are exchanged like cookies through various
    59  // calls to VTGate. The behavior differs between V2 & V3 APIs.
    60  // V3 APIs are Execute, ExecuteBatch and StreamExecute. All
    61  // other APIs are V2. For the V3 APIs, the session
    62  // must be sent with every call to Execute or ExecuteBatch.
    63  // For the V2 APIs, Begin does not accept a session. It instead
    64  // returns a brand new one with in_transaction set to true.
    65  // After a call to Commit or Rollback, the session can be
    66  // discarded. If you're not in a transaction, Session is
    67  // an optional parameter for the V2 APIs.
    68  message Session {
    69    // in_transaction is set to true if the session is in a transaction.
    70    bool in_transaction = 1;
    71  
    72    message ShardSession {
    73      query.Target target = 1;
    74      int64 transaction_id = 2;
    75      topodata.TabletAlias tablet_alias = 3;
    76      // reserved connection if a dedicated connection is needed
    77      int64 reserved_id = 4;
    78      bool vindex_only = 5;
    79    }
    80    // shard_sessions keep track of per-shard transaction info.
    81    repeated ShardSession shard_sessions = 2;
    82  
    83    // single_db is deprecated. Use transaction_mode instead.
    84    reserved 3;
    85  
    86    // autocommit specifies if the session is in autocommit mode.
    87    // This is used only for V3.
    88    bool autocommit = 4;
    89  
    90    // target_string is the target expressed as a string. Valid
    91    // names are: keyspace:shard@target, keyspace@target or @target.
    92    // This is used only for V3.
    93    string target_string = 5;
    94  
    95    // options is used only for V3.
    96    query.ExecuteOptions options = 6;
    97  
    98    // transaction_mode specifies the current transaction mode.
    99    TransactionMode transaction_mode = 7;
   100  
   101    // warnings contains non-fatal warnings from the previous query
   102    repeated query.QueryWarning warnings = 8;
   103  
   104    // pre_sessions contains sessions that have to be committed first.
   105    repeated ShardSession pre_sessions = 9;
   106  
   107    // post_sessions contains sessions that have to be committed last.
   108    repeated ShardSession post_sessions = 10;
   109  
   110    // last_insert_id keeps track of the last seen insert_id for this session
   111    uint64 last_insert_id = 11;
   112  
   113    // found_rows keeps track of how many rows the last query returned
   114    uint64 found_rows = 12;
   115  
   116    // user_defined_variables contains all the @variables defined for this session
   117    map<string, query.BindVariable> user_defined_variables = 13;
   118  
   119    // system_variables keeps track of all session variables set for this connection
   120    // TODO: systay should we keep this so we can apply it ordered? 
   121    map<string, string> system_variables = 14;
   122  
   123    // row_count keeps track of the last seen rows affected for this session
   124    int64 row_count = 15;
   125  
   126    // Stores savepoint and release savepoint calls inside a transaction
   127    // and is reset once transaction is committed or rolled back.
   128    repeated string savepoints = 16;
   129  
   130    // in_reserved_conn is set to true if the session should be using reserved connections.
   131    bool in_reserved_conn = 17;
   132  
   133    // lock_session keep tracks of shard on which the lock query is sent.
   134    ShardSession lock_session = 18;
   135  
   136    // last_lock_heartbeat keep tracks of when last lock heartbeat was sent.
   137    int64 last_lock_heartbeat = 19;
   138  
   139    // read_after_write tracks the ReadAfterWrite settings for this session.
   140    ReadAfterWrite read_after_write = 20;
   141  
   142    // DDL strategy
   143    string DDLStrategy = 21;
   144  
   145    // Session UUID
   146    string SessionUUID = 22;
   147  
   148    // enable_system_settings defines if we can use reserved connections.
   149    bool enable_system_settings = 23;
   150  
   151    map<string, int64> advisory_lock = 24;
   152  
   153    // query_timeout is the maximum amount of time a query is permitted to run
   154    int64 query_timeout = 25;
   155  }
   156  
   157  // ReadAfterWrite contains information regarding gtid set and timeout
   158  // Also if the gtid information needs to be passed to client.
   159  message ReadAfterWrite {
   160    string read_after_write_gtid = 1;
   161    double read_after_write_timeout = 2;
   162    bool session_track_gtids = 3;
   163  }
   164  
   165  // ExecuteRequest is the payload to Execute.
   166  message ExecuteRequest {
   167    // caller_id identifies the caller. This is the effective caller ID,
   168    // set by the application to further identify the caller.
   169    vtrpc.CallerID caller_id = 1;
   170  
   171    // session carries the session state.
   172    Session session = 2;
   173  
   174    // query is the query and bind variables to execute.
   175    query.BoundQuery query = 3;
   176  
   177    // These values are deprecated. Use session instead.
   178    // topodata.TabletType tablet_type = 4;
   179    // string keyspace_shard = 6;
   180    // query.ExecuteOptions options = 7;
   181    // Deprecated: use session.in_transaction instead
   182    // bool not_in_transaction = 5;
   183    reserved 4, 5, 6, 7;
   184  }
   185  
   186  // ExecuteResponse is the returned value from Execute.
   187  message ExecuteResponse {
   188    // error contains an application level error if necessary. Note the
   189    // session may have changed, even when an error is returned (for
   190    // instance if a database integrity error happened).
   191    vtrpc.RPCError error = 1;
   192  
   193    // session is the updated session information.
   194    Session session = 2;
   195  
   196    // result contains the query result, only set if error is unset.
   197    query.QueryResult result = 3;
   198  }
   199  
   200  // ExecuteBatchRequest is the payload to ExecuteBatch.
   201  message ExecuteBatchRequest {
   202    // caller_id identifies the caller. This is the effective caller ID,
   203    // set by the application to further identify the caller.
   204    vtrpc.CallerID caller_id = 1;
   205  
   206    // session carries the session state.
   207    Session session = 2;
   208  
   209    // queries is a list of query and bind variables to execute.
   210    repeated query.BoundQuery queries = 3;
   211  
   212    // These values are deprecated. Use session instead.
   213    //  topodata.TabletType tablet_type = 4;
   214    //  bool as_transaction = 5;
   215    //  string keyspace_shard = 6;
   216    //  query.ExecuteOptions options = 7;
   217    reserved 4, 5, 6, 7;
   218  
   219  }
   220  
   221  
   222  // ExecuteBatchResponse is the returned value from ExecuteBatch.
   223  message ExecuteBatchResponse {
   224    // error contains an application level error if necessary. Note the
   225    // session may have changed, even when an error is returned (for
   226    // instance if a database integrity error happened).
   227    vtrpc.RPCError error = 1;
   228  
   229    // session is the updated session information.
   230    Session session = 2;
   231  
   232    // results contains the query results, only set if application level error is unset.
   233    repeated query.ResultWithError results = 3;
   234  }
   235  
   236  // StreamExecuteRequest is the payload to StreamExecute.
   237  message StreamExecuteRequest {
   238    // caller_id identifies the caller. This is the effective caller ID,
   239    // set by the application to further identify the caller.
   240    vtrpc.CallerID caller_id = 1;
   241  
   242    // query is the query and bind variables to execute.
   243    query.BoundQuery query = 2;
   244  
   245    // These values are deprecated. Use session instead.
   246    //  topodata.TabletType tablet_type = 3;
   247    //  string keyspace_shard = 4;
   248    //  query.ExecuteOptions options = 5;
   249    reserved 3,4,5;
   250  
   251    // session carries the session state.
   252    Session session = 6;
   253  }
   254  
   255  // StreamExecuteResponse is the returned value from StreamExecute.
   256  // The session is currently not returned because StreamExecute is
   257  // not expected to modify it.
   258  message StreamExecuteResponse {
   259    // result contains the result data.
   260    // The first value contains only Fields information.
   261    // The next values contain the actual rows, a few values per result.
   262    query.QueryResult result = 1;
   263  }
   264  
   265  // ResolveTransactionRequest is the payload to ResolveTransaction.
   266  message ResolveTransactionRequest {
   267    // caller_id identifies the caller. This is the effective caller ID,
   268    // set by the application to further identify the caller.
   269    vtrpc.CallerID caller_id = 1;
   270  
   271    // dtid is the dtid of the transaction to be resolved.
   272    string dtid = 2;
   273  }
   274  
   275  // ResolveTransactionResponse is the returned value from Rollback.
   276  message ResolveTransactionResponse {
   277  }
   278  
   279  message VStreamFlags {
   280    // align streams
   281    bool minimize_skew = 1;
   282    // how often heartbeats must be sent when idle (seconds)
   283    uint32 heartbeat_interval = 2;
   284    // stop streams on a reshard (journal event)
   285    bool stop_on_reshard = 3;
   286    // if specified, these cells (comma-separated) are used to pick source tablets from.
   287    // defaults to the cell of the vtgate serving the VStream API.
   288    string cells = 4;
   289  }
   290  
   291  // VStreamRequest is the payload for VStream.
   292  message VStreamRequest {
   293    vtrpc.CallerID caller_id = 1;
   294  
   295    topodata.TabletType tablet_type = 2;
   296  
   297    // position specifies the starting point of the bin log positions
   298    // as well as the keyspace-shards to pull events from.
   299    // position is of the form 'ks1:0@MySQL56/<mysql_pos>|ks2:-80@MySQL56/<mysql_pos>'.
   300    binlogdata.VGtid vgtid = 3;
   301    binlogdata.Filter filter = 4;
   302    VStreamFlags flags = 5;
   303  }
   304  
   305  // VStreamResponse is streamed by VStream.
   306  message VStreamResponse {
   307    repeated binlogdata.VEvent events = 1;
   308  }
   309  
   310  // PrepareRequest is the payload to Prepare.
   311  message PrepareRequest {
   312    // caller_id identifies the caller. This is the effective caller ID,
   313    // set by the application to further identify the caller.
   314    vtrpc.CallerID caller_id = 1;
   315  
   316    // session carries the session state.
   317    Session session = 2;
   318  
   319    // query is the query and bind variables to execute.
   320    query.BoundQuery query = 3;
   321  }
   322  
   323  // PrepareResponse is the returned value from Prepare.
   324  message PrepareResponse {
   325    // error contains an application level error if necessary. Note the
   326    // session may have changed, even when an error is returned (for
   327    // instance if a database integrity error happened).
   328    vtrpc.RPCError error = 1;
   329  
   330    // session is the updated session information.
   331    Session session = 2;
   332  
   333    // fields contains the fields, only set if error is unset.
   334    repeated query.Field fields = 3;
   335  }
   336  
   337  // CloseSessionRequest is the payload to CloseSession.
   338  message CloseSessionRequest {
   339    // caller_id identifies the caller. This is the effective caller ID,
   340    // set by the application to further identify the caller.
   341    vtrpc.CallerID caller_id = 1;
   342  
   343    // session carries the session state.
   344    Session session = 2;
   345  }
   346  
   347  // CloseSessionResponse is the returned value from CloseSession.
   348  message CloseSessionResponse {
   349    // error contains an application level error if necessary. Note the
   350    // session may have changed, even when an error is returned (for
   351    // instance if a database integrity error happened).
   352    vtrpc.RPCError error = 1;
   353  }