vitess.io/vitess@v0.16.2/proto/query.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  // This file contains all the types necessary to make
    18  // RPC calls to Vttablet.
    19  
    20  syntax = "proto3";
    21  option go_package = "vitess.io/vitess/go/vt/proto/query";
    22  
    23  package query;
    24  
    25  option java_package = "io.vitess.proto";
    26  
    27  import "topodata.proto";
    28  import "vtrpc.proto";
    29  
    30  // Target describes what the client expects the tablet is.
    31  // If the tablet does not match, an error is returned.
    32  message Target {
    33    string keyspace = 1;
    34    string shard = 2;
    35    topodata.TabletType tablet_type = 3;
    36    // cell is used for routing queries between vtgate and vttablets. It
    37    // is not used when Target is part of the Session sent by the client.
    38    string cell = 4;
    39  }
    40  
    41  // VTGateCallerID is sent by VTGate to VTTablet to describe the
    42  // caller. If possible, this information is secure. For instance,
    43  // if using unique certificates that guarantee that VTGate->VTTablet
    44  // traffic cannot be spoofed, then VTTablet can trust this information,
    45  // and VTTablet will use it for tablet ACLs, for instance.
    46  // Because of this security guarantee, this is different than the CallerID
    47  // structure, which is not secure at all, because it is provided
    48  // by the Vitess client.
    49  message VTGateCallerID {
    50    string username = 1;
    51    repeated string groups = 2;
    52  }
    53  
    54  // EventToken is a structure that describes a point in time in a
    55  // replication stream on one shard. The most recent known replication
    56  // position can be retrieved from vttablet when executing a query. It
    57  // is also sent with the replication streams from the binlog service.
    58  message EventToken {
    59    // timestamp is the MySQL timestamp of the statements. Seconds since Epoch.
    60    int64 timestamp = 1;
    61  
    62    // The shard name that applied the statements. Note this is not set when
    63    // streaming from a vttablet. It is only used on the client -> vtgate link.
    64    string shard = 2;
    65  
    66    // The position on the replication stream after this statement was applied.
    67    // It is not the transaction ID / GTID, but the position / GTIDSet.
    68    string position = 3;
    69  }
    70  
    71  // Flags sent from the MySQL C API
    72  enum MySqlFlag {
    73    option allow_alias = true;
    74    
    75    EMPTY = 0;
    76    NOT_NULL_FLAG = 1;
    77    PRI_KEY_FLAG = 2;
    78    UNIQUE_KEY_FLAG = 4;
    79    MULTIPLE_KEY_FLAG = 8;
    80    BLOB_FLAG = 16;
    81    UNSIGNED_FLAG = 32;
    82    ZEROFILL_FLAG = 64;
    83    BINARY_FLAG = 128;
    84    ENUM_FLAG = 256;
    85    AUTO_INCREMENT_FLAG = 512;
    86    TIMESTAMP_FLAG = 1024;
    87    SET_FLAG = 2048;
    88    NO_DEFAULT_VALUE_FLAG = 4096;
    89    ON_UPDATE_NOW_FLAG = 8192;
    90    NUM_FLAG = 32768;
    91    PART_KEY_FLAG = 16384;
    92    GROUP_FLAG = 32768;
    93    UNIQUE_FLAG = 65536;
    94    BINCMP_FLAG = 131072;
    95  }
    96  
    97  // Flag allows us to qualify types by their common properties.
    98  enum Flag {
    99    NONE = 0;
   100    ISINTEGRAL = 256;
   101    ISUNSIGNED = 512;
   102    ISFLOAT = 1024;
   103    ISQUOTED = 2048;
   104    ISTEXT = 4096;
   105    ISBINARY = 8192;
   106  }
   107  
   108  // Type defines the various supported data types in bind vars
   109  // and query results.
   110  enum Type {
   111    // NULL_TYPE specifies a NULL type.
   112    NULL_TYPE = 0;
   113    // INT8 specifies a TINYINT type.
   114    // Properties: 1, IsNumber.
   115    INT8 = 257;
   116    // UINT8 specifies a TINYINT UNSIGNED type.
   117    // Properties: 2, IsNumber, IsUnsigned.
   118    UINT8 = 770;
   119    // INT16 specifies a SMALLINT type.
   120    // Properties: 3, IsNumber.
   121    INT16 = 259;
   122    // UINT16 specifies a SMALLINT UNSIGNED type.
   123    // Properties: 4, IsNumber, IsUnsigned.
   124    UINT16 = 772;
   125    // INT24 specifies a MEDIUMINT type.
   126    // Properties: 5, IsNumber.
   127    INT24 = 261;
   128    // UINT24 specifies a MEDIUMINT UNSIGNED type.
   129    // Properties: 6, IsNumber, IsUnsigned.
   130    UINT24 = 774;
   131    // INT32 specifies a INTEGER type.
   132    // Properties: 7, IsNumber.
   133    INT32 = 263;
   134    // UINT32 specifies a INTEGER UNSIGNED type.
   135    // Properties: 8, IsNumber, IsUnsigned.
   136    UINT32 = 776;
   137    // INT64 specifies a BIGINT type.
   138    // Properties: 9, IsNumber.
   139    INT64 = 265;
   140    // UINT64 specifies a BIGINT UNSIGNED type.
   141    // Properties: 10, IsNumber, IsUnsigned.
   142    UINT64 = 778;
   143    // FLOAT32 specifies a FLOAT type.
   144    // Properties: 11, IsFloat.
   145    FLOAT32 = 1035;
   146    // FLOAT64 specifies a DOUBLE or REAL type.
   147    // Properties: 12, IsFloat.
   148    FLOAT64 = 1036;
   149    // TIMESTAMP specifies a TIMESTAMP type.
   150    // Properties: 13, IsQuoted.
   151    TIMESTAMP = 2061;
   152    // DATE specifies a DATE type.
   153    // Properties: 14, IsQuoted.
   154    DATE = 2062;
   155    // TIME specifies a TIME type.
   156    // Properties: 15, IsQuoted.
   157    TIME = 2063;
   158    // DATETIME specifies a DATETIME type.
   159    // Properties: 16, IsQuoted.
   160    DATETIME = 2064;
   161    // YEAR specifies a YEAR type.
   162    // Properties: 17, IsNumber, IsUnsigned.
   163    YEAR = 785;
   164    // DECIMAL specifies a DECIMAL or NUMERIC type.
   165    // Properties: 18, None.
   166    DECIMAL = 18;
   167    // TEXT specifies a TEXT type.
   168    // Properties: 19, IsQuoted, IsText.
   169    TEXT = 6163;
   170    // BLOB specifies a BLOB type.
   171    // Properties: 20, IsQuoted, IsBinary.
   172    BLOB = 10260;
   173    // VARCHAR specifies a VARCHAR type.
   174    // Properties: 21, IsQuoted, IsText.
   175    VARCHAR = 6165;
   176    // VARBINARY specifies a VARBINARY type.
   177    // Properties: 22, IsQuoted, IsBinary.
   178    VARBINARY = 10262;
   179    // CHAR specifies a CHAR type.
   180    // Properties: 23, IsQuoted, IsText.
   181    CHAR = 6167;
   182    // BINARY specifies a BINARY type.
   183    // Properties: 24, IsQuoted, IsBinary.
   184    BINARY = 10264;
   185    // BIT specifies a BIT type.
   186    // Properties: 25, IsQuoted.
   187    BIT = 2073;
   188    // ENUM specifies an ENUM type.
   189    // Properties: 26, IsQuoted.
   190    ENUM = 2074;
   191    // SET specifies a SET type.
   192    // Properties: 27, IsQuoted.
   193    SET = 2075;
   194    // TUPLE specifies a tuple. This cannot
   195    // be returned in a QueryResult, but it can
   196    // be sent as a bind var.
   197    // Properties: 28, None.
   198    TUPLE = 28;
   199    // GEOMETRY specifies a GEOMETRY type.
   200    // Properties: 29, IsQuoted.
   201    GEOMETRY = 2077;
   202    // JSON specifies a JSON type.
   203    // Properties: 30, IsQuoted.
   204    JSON = 2078;
   205    // EXPRESSION specifies a SQL expression.
   206    // This type is for internal use only.
   207    // Properties: 31, None.
   208    EXPRESSION = 31;
   209    // HEXNUM specifies a HEXNUM type (unquoted varbinary).
   210    // Properties: 32, IsText.
   211    HEXNUM = 4128;
   212    // HEXVAL specifies a HEXVAL type (unquoted varbinary).
   213    // Properties: 33, IsText.
   214    HEXVAL = 4129;
   215    // BITNUM specifies a base 2 binary type (unquoted varbinary).
   216    // Properties: 34, IsText.
   217    BITNUM = 4130;
   218  }
   219  
   220  // Value represents a typed value.
   221  message Value {
   222    Type type = 1;
   223    bytes value = 2;
   224  }
   225  
   226  // BindVariable represents a single bind variable in a Query.
   227  message BindVariable {
   228    Type type = 1;
   229    bytes value = 2;
   230    // values are set if type is TUPLE.
   231    repeated Value values = 3;
   232  }
   233  
   234  // BoundQuery is a query with its bind variables
   235  message BoundQuery {
   236    // sql is the SQL query to execute
   237    string sql = 1;
   238  
   239    // bind_variables is a map of all bind variables to expand in the query.
   240    // nil values are not allowed. Use NULL_TYPE to express a NULL value.
   241    map<string, BindVariable> bind_variables = 2;
   242  }
   243  
   244  // ExecuteOptions is passed around for all Execute calls.
   245  message ExecuteOptions {
   246    // 1 used to be exclude_field_names, which was replaced by
   247    // IncludedFields enum below
   248    // 2 used to be include_event_token
   249    // 3 used to be compare_event_token
   250    reserved 1, 2, 3;
   251  
   252    enum IncludedFields {
   253      TYPE_AND_NAME = 0;
   254      TYPE_ONLY = 1;
   255      ALL = 2;
   256    }
   257  
   258    // Controls what fields are returned in Field message responses from mysql, i.e.
   259    // field name, table name, etc. This is an optimization for high-QPS queries where
   260    // the client knows what it's getting
   261    IncludedFields included_fields = 4;
   262  
   263    // client_rows_found specifies if rows_affected should return
   264    // rows found instead of rows affected. Behavior is defined
   265    // by MySQL's CLIENT_FOUND_ROWS flag.
   266    bool client_found_rows = 5;
   267  
   268    enum Workload {
   269      UNSPECIFIED = 0;
   270      OLTP = 1;
   271      OLAP = 2;
   272      DBA = 3;
   273    }
   274  
   275    // workload specifies the type of workload:
   276    // OLTP: DMLs allowed, results have row count limit, and
   277    // query timeouts are shorter.
   278    // OLAP: DMLS not allowed, no limit on row count, timeouts
   279    // can be as high as desired.
   280    // DBA: no limit on rowcount or timeout, all queries allowed 
   281    // but intended for long DMLs and DDLs.
   282    Workload workload = 6;
   283  
   284    // sql_select_limit sets an implicit limit on all select statements. Since
   285    // vitess also sets a rowcount limit on queries, the smallest value wins.
   286    int64 sql_select_limit = 8;
   287  
   288    enum TransactionIsolation {
   289      DEFAULT = 0;
   290      REPEATABLE_READ = 1;
   291      READ_COMMITTED = 2;
   292      READ_UNCOMMITTED = 3;
   293      SERIALIZABLE = 4;
   294  
   295      // This is not an "official" transaction level but it will do a
   296      // START TRANSACTION WITH CONSISTENT SNAPSHOT, READ ONLY
   297      CONSISTENT_SNAPSHOT_READ_ONLY = 5;
   298  
   299      // This not an "official" transaction level, it will send queries to mysql
   300      // without wrapping them in a transaction
   301      AUTOCOMMIT = 6;
   302    }
   303  
   304    TransactionIsolation transaction_isolation = 9;
   305  
   306    // skip_query_plan_cache specifies if the query plan should be cached by vitess.
   307    // By default all query plans are cached.
   308    bool skip_query_plan_cache = 10;
   309  
   310    enum PlannerVersion {
   311      DEFAULT_PLANNER = 0;
   312      V3 = 1;
   313      Gen4 = 2;
   314      Gen4Greedy = 3;
   315      Gen4Left2Right = 4;
   316      Gen4WithFallback = 5;
   317      Gen4CompareV3 = 6;
   318    }
   319    
   320    // PlannerVersion specifies which planner to use. 
   321    // If DEFAULT is chosen, whatever vtgate was started with will be used
   322    PlannerVersion planner_version = 11;
   323  
   324    // has_created_temp_tables signals whether plans created in this session should be cached or not
   325    // if the user has created temp tables, Vitess will not reuse plans created for this session in other sessions.
   326    // The current session can still use other sessions cached plans.
   327    bool has_created_temp_tables = 12;
   328  
   329    enum Consolidator {
   330      CONSOLIDATOR_UNSPECIFIED = 0;
   331      CONSOLIDATOR_DISABLED = 1;
   332      CONSOLIDATOR_ENABLED = 2;
   333      CONSOLIDATOR_ENABLED_REPLICAS = 3;
   334    }
   335  
   336    Consolidator consolidator = 13;
   337  
   338    enum TransactionAccessMode {
   339      CONSISTENT_SNAPSHOT = 0;
   340      READ_WRITE = 1;
   341      READ_ONLY = 2;
   342    }
   343  
   344    // TransactionAccessMode specifies the access modes to be used while starting the transaction i.e. READ WRITE/READ ONLY/WITH CONSISTENT SNAPSHOT
   345    // If not specified, the transaction will be started with the default access mode on the connection.
   346    repeated TransactionAccessMode transaction_access_mode = 14;
   347  }
   348  
   349  // Field describes a single column returned by a query
   350  message Field {
   351    // name of the field as returned by mysql C API
   352    string name = 1;
   353  
   354    // vitess-defined type. Conversion function is in sqltypes package.
   355    Type type = 2;
   356  
   357    // Remaining fields from mysql C API.
   358    // These fields are only populated when ExecuteOptions.included_fields
   359    // is set to IncludedFields.ALL.
   360    string table = 3;
   361    string org_table = 4;
   362    string database = 5;
   363    string org_name = 6;
   364  
   365    // column_length is really a uint32. All 32 bits can be used.
   366    uint32 column_length = 7;
   367  
   368    // charset is actually a uint16. Only the lower 16 bits are used.
   369    uint32 charset = 8;
   370  
   371    // decimals is actually a uint8. Only the lower 8 bits are used.
   372    uint32 decimals = 9;
   373  
   374    // flags is actually a uint16. Only the lower 16 bits are used.
   375    uint32 flags = 10;
   376  
   377    // column_type is optionally populated from information_schema.columns
   378    string column_type = 11;
   379  }
   380  
   381  // Row is a database row.
   382  message Row {
   383    // lengths contains the length of each value in values.
   384    // A length of -1 means that the field is NULL. While
   385    // reading values, you have to accummulate the length
   386    // to know the offset where the next value begins in values.
   387    repeated sint64 lengths = 1;
   388    // values contains a concatenation of all values in the row.
   389    bytes values = 2;
   390  }
   391  
   392  // QueryResult is returned by Execute and ExecuteStream.
   393  //
   394  // As returned by Execute, len(fields) is always equal to len(row)
   395  // (for each row in rows).
   396  //
   397  // As returned by StreamExecute, the first QueryResult has the fields
   398  // set, and subsequent QueryResult have rows set. And as Execute,
   399  // len(QueryResult[0].fields) is always equal to len(row) (for each
   400  // row in rows for each QueryResult in QueryResult[1:]).
   401  message QueryResult {
   402    // This used to be ResultExtras.
   403    reserved 5;
   404  
   405    repeated Field fields = 1;
   406    uint64 rows_affected = 2;
   407    uint64 insert_id = 3;
   408    repeated Row rows = 4;
   409    string info = 6;
   410    string session_state_changes = 7;
   411  }
   412  
   413  // QueryWarning is used to convey out of band query execution warnings
   414  // by storing in the vtgate.Session
   415  message QueryWarning {
   416    uint32 code = 1;
   417    string message = 2;
   418  }
   419  
   420  // StreamEvent describes a set of transformations that happened as a
   421  // single transactional unit on a server. It is streamed back by the
   422  // Update Stream calls.
   423  message StreamEvent {
   424    // One individual Statement in a transaction.
   425    message Statement {
   426      // The category of one statement.
   427      enum Category {
   428        Error = 0;
   429        DML = 1;
   430        DDL = 2;
   431      }
   432      Category category = 1;
   433  
   434      // table_name, primary_key_fields and primary_key_values are set for DML.
   435      string table_name = 2;
   436      repeated Field primary_key_fields = 3;
   437      repeated Row primary_key_values = 4;
   438  
   439      // sql is set for all queries.
   440      // FIXME(alainjobart) we may not need it for DMLs.
   441      bytes sql = 5;
   442    }
   443  
   444    // The statements in this transaction.
   445    repeated Statement statements = 1;
   446  
   447    // The Event Token for this event.
   448    EventToken event_token = 2;
   449  }
   450  
   451  // ExecuteRequest is the payload to Execute
   452  message ExecuteRequest {
   453    vtrpc.CallerID effective_caller_id = 1;
   454    VTGateCallerID immediate_caller_id = 2;
   455    Target target = 3;
   456    BoundQuery query = 4;
   457    int64 transaction_id = 5;
   458    ExecuteOptions options = 6;
   459    int64 reserved_id = 7;
   460  }
   461  
   462  // ExecuteResponse is the returned value from Execute
   463  message ExecuteResponse {
   464    QueryResult result = 1;
   465  }
   466  
   467  // ResultWithError represents a query response
   468  // in the form of result or error but not both.
   469  // TODO: To be used in ExecuteBatchResponse and BeginExecuteBatchResponse.
   470  message ResultWithError {
   471    // error contains an query level error, only set if result is unset.
   472    vtrpc.RPCError error = 1;
   473  
   474    // result contains the query result, only set if error is unset.
   475    query.QueryResult result = 2;
   476  }
   477  
   478  // StreamExecuteRequest is the payload to StreamExecute
   479  message StreamExecuteRequest {
   480    vtrpc.CallerID effective_caller_id = 1;
   481    VTGateCallerID immediate_caller_id = 2;
   482    Target target = 3;
   483    BoundQuery query = 4;
   484    ExecuteOptions options = 5;
   485    int64 transaction_id = 6;
   486    int64 reserved_id = 7;
   487  }
   488  
   489  // StreamExecuteResponse is the returned value from StreamExecute
   490  message StreamExecuteResponse {
   491    QueryResult result = 1;
   492  }
   493  
   494  // BeginRequest is the payload to Begin
   495  message BeginRequest {
   496    vtrpc.CallerID effective_caller_id = 1;
   497    VTGateCallerID immediate_caller_id = 2;
   498    Target target = 3;
   499    ExecuteOptions options = 4;
   500  }
   501  
   502  // BeginResponse is the returned value from Begin
   503  message BeginResponse {
   504    int64 transaction_id = 1;
   505    topodata.TabletAlias tablet_alias = 2;
   506    // The session_state_changes might be set if the transaction is a snapshot transaction
   507    // and the MySQL implementation supports getting a start gtid on snapshot
   508    string session_state_changes = 3;
   509  }
   510  
   511  // CommitRequest is the payload to Commit
   512  message CommitRequest {
   513    vtrpc.CallerID effective_caller_id = 1;
   514    VTGateCallerID immediate_caller_id = 2;
   515    Target target = 3;
   516    int64 transaction_id = 4;
   517  }
   518  
   519  // CommitResponse is the returned value from Commit
   520  message CommitResponse {
   521    int64 reserved_id = 1;
   522  }
   523  
   524  // RollbackRequest is the payload to Rollback
   525  message RollbackRequest {
   526    vtrpc.CallerID effective_caller_id = 1;
   527    VTGateCallerID immediate_caller_id = 2;
   528    Target target = 3;
   529    int64 transaction_id = 4;
   530  }
   531  
   532  // RollbackResponse is the returned value from Rollback
   533  message RollbackResponse {
   534    int64 reserved_id = 1;
   535  }
   536  
   537  // PrepareRequest is the payload to Prepare
   538  message PrepareRequest {
   539    vtrpc.CallerID effective_caller_id = 1;
   540    VTGateCallerID immediate_caller_id = 2;
   541    Target target = 3;
   542    int64 transaction_id = 4;
   543    string dtid = 5;
   544  }
   545  
   546  // PrepareResponse is the returned value from Prepare
   547  message PrepareResponse {}
   548  
   549  // CommitPreparedRequest is the payload to CommitPrepared
   550  message CommitPreparedRequest {
   551    vtrpc.CallerID effective_caller_id = 1;
   552    VTGateCallerID immediate_caller_id = 2;
   553    Target target = 3;
   554    string dtid = 4;
   555  }
   556  
   557  // CommitPreparedResponse is the returned value from CommitPrepared
   558  message CommitPreparedResponse {}
   559  
   560  // RollbackPreparedRequest is the payload to RollbackPrepared
   561  message RollbackPreparedRequest {
   562    vtrpc.CallerID effective_caller_id = 1;
   563    VTGateCallerID immediate_caller_id = 2;
   564    Target target = 3;
   565    int64 transaction_id = 4;
   566    string dtid = 5;
   567  }
   568  
   569  // RollbackPreparedResponse is the returned value from RollbackPrepared
   570  message RollbackPreparedResponse {}
   571  
   572  // CreateTransactionRequest is the payload to CreateTransaction
   573  message CreateTransactionRequest {
   574    vtrpc.CallerID effective_caller_id = 1;
   575    VTGateCallerID immediate_caller_id = 2;
   576    Target target = 3;
   577    string dtid = 4;
   578    repeated Target participants = 5;
   579  }
   580  
   581  // CreateTransactionResponse is the returned value from CreateTransaction
   582  message CreateTransactionResponse {}
   583  
   584  // StartCommitRequest is the payload to StartCommit
   585  message StartCommitRequest {
   586    vtrpc.CallerID effective_caller_id = 1;
   587    VTGateCallerID immediate_caller_id = 2;
   588    Target target = 3;
   589    int64 transaction_id = 4;
   590    string dtid = 5;
   591  }
   592  
   593  // StartCommitResponse is the returned value from StartCommit
   594  message StartCommitResponse {}
   595  
   596  // SetRollbackRequest is the payload to SetRollback
   597  message SetRollbackRequest {
   598    vtrpc.CallerID effective_caller_id = 1;
   599    VTGateCallerID immediate_caller_id = 2;
   600    Target target = 3;
   601    int64 transaction_id = 4;
   602    string dtid = 5;
   603  }
   604  
   605  // SetRollbackResponse is the returned value from SetRollback
   606  message SetRollbackResponse {}
   607  
   608  // ConcludeTransactionRequest is the payload to ConcludeTransaction
   609  message ConcludeTransactionRequest {
   610    vtrpc.CallerID effective_caller_id = 1;
   611    VTGateCallerID immediate_caller_id = 2;
   612    Target target = 3;
   613    string dtid = 4;
   614  }
   615  
   616  // ConcludeTransactionResponse is the returned value from ConcludeTransaction
   617  message ConcludeTransactionResponse {}
   618  
   619  // ReadTransactionRequest is the payload to ReadTransaction
   620  message ReadTransactionRequest {
   621    vtrpc.CallerID effective_caller_id = 1;
   622    VTGateCallerID immediate_caller_id = 2;
   623    Target target = 3;
   624    string dtid = 4;
   625  }
   626  
   627  // ReadTransactionResponse is the returned value from ReadTransaction
   628  message ReadTransactionResponse {
   629    TransactionMetadata metadata = 1;
   630  }
   631  
   632  // BeginExecuteRequest is the payload to BeginExecute
   633  message BeginExecuteRequest {
   634    vtrpc.CallerID effective_caller_id = 1;
   635    VTGateCallerID immediate_caller_id = 2;
   636    Target target = 3;
   637    BoundQuery query = 4;
   638    ExecuteOptions options = 5;
   639    int64 reserved_id = 6;
   640    repeated string pre_queries = 7;
   641  }
   642  
   643  // BeginExecuteResponse is the returned value from BeginExecute
   644  message BeginExecuteResponse {
   645    // error contains an application level error if necessary. Note the
   646    // transaction_id may be set, even when an error is returned, if the begin
   647    // worked but the execute failed.
   648    vtrpc.RPCError error = 1;
   649  
   650    QueryResult result = 2;
   651  
   652    // transaction_id might be non-zero even if an error is present.
   653    int64 transaction_id = 3;
   654    topodata.TabletAlias tablet_alias = 4;
   655    // The session_state_changes might be set if the transaction is a snapshot transaction
   656    // and the MySQL implementation supports getting a start gtid on snapshot
   657    string session_state_changes = 5;
   658  }
   659  
   660  // BeginStreamExecuteRequest is the payload to BeginStreamExecute
   661  message BeginStreamExecuteRequest {
   662    vtrpc.CallerID effective_caller_id = 1;
   663    VTGateCallerID immediate_caller_id = 2;
   664    Target target = 3;
   665    BoundQuery query = 4;
   666    ExecuteOptions options = 5;
   667    repeated string pre_queries = 6;
   668    int64 reserved_id = 7;
   669  }
   670  
   671  // BeginStreamExecuteResponse is the returned value from BeginStreamExecute
   672  message BeginStreamExecuteResponse {
   673    // error contains an application level error if necessary. Note the
   674    // transaction_id may be set, even when an error is returned, if the begin
   675    // worked but the stream execute failed.
   676    vtrpc.RPCError error = 1;
   677  
   678    QueryResult result = 2;
   679  
   680    // transaction_id might be non-zero even if an error is present.
   681    int64 transaction_id = 3;
   682    topodata.TabletAlias tablet_alias = 4;
   683    // The session_state_changes might be set if the transaction is a snapshot transaction
   684    // and the MySQL implementation supports getting a start gtid on snapshot
   685    string session_state_changes = 5;
   686  }
   687  
   688  // MessageStreamRequest is the request payload for MessageStream.
   689  message MessageStreamRequest {
   690    vtrpc.CallerID effective_caller_id = 1;
   691    VTGateCallerID immediate_caller_id = 2;
   692    Target target = 3;
   693    // name is the message table name.
   694    string name = 4;
   695  }
   696  
   697  // MessageStreamResponse is a response for MessageStream.
   698  message MessageStreamResponse {
   699    QueryResult result = 1;
   700  }
   701  
   702  // MessageAckRequest is the request payload for MessageAck.
   703  message MessageAckRequest {
   704    vtrpc.CallerID effective_caller_id = 1;
   705    VTGateCallerID immediate_caller_id = 2;
   706    Target target = 3;
   707    // name is the message table name.
   708    string name = 4;
   709    repeated Value ids = 5;
   710  }
   711  
   712  // MessageAckResponse is the response for MessageAck.
   713  message MessageAckResponse {
   714    // result contains the result of the ack operation.
   715    // Since this acts like a DML, only
   716    // RowsAffected is returned in the result.
   717    QueryResult result = 1;
   718  }
   719  
   720  // ReserveExecuteRequest is the payload to ReserveExecute
   721  message ReserveExecuteRequest {
   722    vtrpc.CallerID effective_caller_id = 1;
   723    VTGateCallerID immediate_caller_id = 2;
   724    Target target = 3;
   725    BoundQuery query = 4;
   726    int64 transaction_id = 5;
   727    ExecuteOptions options = 6;
   728    repeated string pre_queries = 7;
   729  }
   730  
   731  // ReserveExecuteResponse is the returned value from ReserveExecute
   732  message ReserveExecuteResponse {
   733    vtrpc.RPCError error = 1;
   734    QueryResult result = 2;
   735  
   736    // The following fields might be non-zero even if an error is present.
   737    int64 reserved_id = 3;
   738    topodata.TabletAlias tablet_alias = 4;
   739  }
   740  
   741  // ReserveStreamExecuteRequest is the payload to ReserveStreamExecute
   742  message ReserveStreamExecuteRequest {
   743    vtrpc.CallerID effective_caller_id = 1;
   744    VTGateCallerID immediate_caller_id = 2;
   745    Target target = 3;
   746    BoundQuery query = 4;
   747    ExecuteOptions options = 5;
   748    int64 transaction_id = 6;
   749    repeated string pre_queries = 7;
   750  }
   751  
   752  // ReserveStreamExecuteResponse is the returned value from ReserveStreamExecute
   753  message ReserveStreamExecuteResponse {
   754    vtrpc.RPCError error = 1;
   755    QueryResult result = 2;
   756  
   757    // The following fields might be non-zero even if an error is present.
   758    int64 reserved_id = 3;
   759    topodata.TabletAlias tablet_alias = 4;
   760  }
   761  
   762  
   763  // ReserveBeginExecuteRequest is the payload to ReserveBeginExecute
   764  message ReserveBeginExecuteRequest {
   765    vtrpc.CallerID effective_caller_id = 1;
   766    VTGateCallerID immediate_caller_id = 2;
   767    Target target = 3;
   768    BoundQuery query = 4;
   769    ExecuteOptions options = 5;
   770    repeated string pre_queries = 6;
   771    repeated string post_begin_queries = 7;
   772  }
   773  
   774  // ReserveBeginExecuteResponse is the returned value from ReserveBeginExecute
   775  message ReserveBeginExecuteResponse {
   776    // error contains an application level error if necessary. Note the
   777    // transaction_id may be set, even when an error is returned, if the begin
   778    // worked but the execute failed.
   779    vtrpc.RPCError error = 1;
   780    QueryResult result = 2;
   781    // The following fields might be non-zero even if an error is present.
   782    int64 transaction_id = 3;
   783    int64 reserved_id = 4;
   784    topodata.TabletAlias tablet_alias = 5;
   785    // The session_state_changes might be set if the transaction is a snapshot transaction
   786    // and the MySQL implementation supports getting a start gtid on snapshot
   787    string session_state_changes = 6;
   788  }
   789  
   790  // ReserveBeginStreamExecuteRequest is the payload to ReserveBeginStreamExecute
   791  message ReserveBeginStreamExecuteRequest {
   792    vtrpc.CallerID effective_caller_id = 1;
   793    VTGateCallerID immediate_caller_id = 2;
   794    Target target = 3;
   795    BoundQuery query = 4;
   796    ExecuteOptions options = 5;
   797    repeated string pre_queries = 6;
   798    repeated string post_begin_queries = 7;
   799  }
   800  
   801  // ReserveBeginStreamExecuteResponse is the returned value from ReserveBeginStreamExecute
   802  message ReserveBeginStreamExecuteResponse {
   803    // error contains an application level error if necessary. Note the
   804    // transaction_id may be set, even when an error is returned, if the begin
   805    // worked but the stream execute failed.
   806    vtrpc.RPCError error = 1;
   807  
   808    QueryResult result = 2;
   809  
   810    // The following fields might be non-zero even if an error is present.
   811    int64 transaction_id = 3;
   812    int64 reserved_id = 4;
   813    topodata.TabletAlias tablet_alias = 5;
   814    // The session_state_changes might be set if the transaction is a snapshot transaction
   815    // and the MySQL implementation supports getting a start gtid on snapshot
   816    string session_state_changes = 6;
   817  }
   818  
   819  // ReleaseRequest is the payload to Release
   820  message ReleaseRequest {
   821    vtrpc.CallerID effective_caller_id = 1;
   822    VTGateCallerID immediate_caller_id = 2;
   823    Target target = 3;
   824    int64 transaction_id = 4;
   825    int64 reserved_id = 5;
   826  }
   827  
   828  // ReleaseResponse is the returned value from Release
   829  message ReleaseResponse {
   830  }
   831  
   832  // StreamHealthRequest is the payload for StreamHealth
   833  message StreamHealthRequest {
   834  }
   835  
   836  // RealtimeStats contains information about the tablet status.
   837  // It is only valid for a single tablet.
   838  message RealtimeStats {
   839    // health_error is the last error we got from health check,
   840    // or empty is the server is healthy. This is used for subset selection,
   841    // we do not send queries to servers that are not healthy.
   842    string health_error = 1;
   843  
   844    // replication_lag_seconds is populated for replicas only. It indicates
   845    // how far behind on (MySQL) replication a replica currently is.  It is used
   846    // by clients for subset selection (so we don't try to send traffic
   847    // to tablets that are too far behind).
   848    // NOTE: This field must not be evaluated if "health_error" is not empty.
   849    // TODO(mberlin): Let's switch it to int64 instead?
   850    uint32 replication_lag_seconds = 2;
   851  
   852    // bin_log_players_count is the number of currently running binlog players.
   853    // if the value is 0, it means that filtered replication is currently not
   854    // running on the tablet. If >0, filtered replication is running.
   855    // NOTE: This field must not be evaluated if "health_error" is not empty.
   856    int32 binlog_players_count = 3;
   857  
   858    // filtered_replication_lag_seconds is populated for the receiving
   859    // primary of an ongoing filtered replication only.
   860    // It specifies how far the receiving primary lags behind the sending primary.
   861    // NOTE: This field must not be evaluated if "health_error" is not empty.
   862    // NOTE: This field must not be evaluated if "bin_log_players_count" is 0.
   863    int64 filtered_replication_lag_seconds = 4;
   864  
   865    // cpu_usage is used for load-based balancing
   866    double cpu_usage = 5;
   867  
   868    // qps is the average QPS (queries per second) rate in the last XX seconds
   869    // where XX is usually 60 (See query_service_stats.go).
   870    double qps = 6;
   871  
   872    // table_schema_changed is to provide list of tables that have schema changes detected by the tablet.
   873    repeated string table_schema_changed = 7;
   874  
   875    // view_schema_changed is to provide list of views that have schema changes detected by the tablet.
   876    repeated string view_schema_changed = 8;
   877  }
   878  
   879  // AggregateStats contains information about the health of a group of
   880  // tablets for a Target.  It is used to propagate stats from a vtgate
   881  // to another, or from the Gateway layer of a vtgate to the routing
   882  // layer.
   883  message AggregateStats {
   884    // healthy_tablet_count is the number of healthy tablets in the group.
   885    int32 healthy_tablet_count = 1;
   886  
   887    // unhealthy_tablet_count is the number of unhealthy tablets in the group.
   888    int32 unhealthy_tablet_count = 2;
   889  
   890    // replication_lag_seconds_min is the minimum of the
   891    // replication_lag_seconds values of the healthy tablets. It is unset
   892    // if the tablet type is primary.
   893    uint32 replication_lag_seconds_min = 3;
   894  
   895    // replication_lag_seconds_max is the maximum of the
   896    // replication_lag_seconds values of the healthy tablets. It is unset
   897    // if the tablet type is primary.
   898    uint32 replication_lag_seconds_max = 4;
   899  }
   900  
   901  // StreamHealthResponse is streamed by StreamHealth on a regular basis.
   902  // It is expected to be used between a vtgate and vttablet:
   903  // - target describes the tablet.
   904  // - realtime_stats is set.
   905  // - aggregate_stats is not set (deprecated)
   906  message StreamHealthResponse {
   907    // target is the current server type. Only queries with that exact Target
   908    // record will be accepted (the cell may not match, however).
   909    Target target = 1;
   910  
   911    // serving is true iff the tablet is serving. A tablet may not be serving
   912    // if filtered replication is enabled on a primary for instance,
   913    // or if a replica should not be used because the keyspace is being resharded.
   914    bool serving = 2;
   915  
   916    // tablet_externally_reparented_timestamp can be interpreted as the
   917    // last time we knew that this tablet was the PRIMARY of this shard
   918    // (if StreamHealthResponse describes a group of tablets, between
   919    // two vtgates, only one primary will be present in the group, and
   920    // this is this primary's value).
   921    //
   922    // It is used by vtgate when determining the current PRIMARY of a shard.
   923    // If vtgate sees more than one PRIMARY tablet, this timestamp is used
   924    // as tiebreaker where the PRIMARY with the highest timestamp wins.
   925    // Another usage of this timestamp is in go/vt/vtgate/buffer to detect the end
   926    // of a reparent (failover) and stop buffering.
   927    //
   928    // In practice, this field is set to:
   929    // a) the last time the RPC tabletmanager.TabletExternallyReparented was
   930    //    called on this tablet (usually done by an external failover tool e.g.
   931    //    Orchestrator). The failover tool can call this as long as we are the
   932    //    primary i.e. even ages after the last reparent occurred.
   933    // OR
   934    // b) the last time an active reparent was executed through a vtctl command
   935    //    (InitShardPrimary, PlannedReparentShard, EmergencyReparentShard)
   936    // OR
   937    // c) the last time vttablet was started and it initialized its tablet type
   938    //    as PRIMARY because it was recorded as the shard's current primary in the
   939    //    topology (see go/vt/vttablet/tabletmanager/init_tablet.go)
   940    // OR
   941    // d) 0 if the vttablet was never a PRIMARY.
   942    int64 tablet_externally_reparented_timestamp = 3;
   943  
   944    // realtime_stats contains information about the tablet status.
   945    // It is only filled in if the information is about a tablet.
   946    RealtimeStats realtime_stats = 4;
   947  
   948    reserved 6;
   949    // Deprecated
   950    // AggregateStats constrains information about the group of tablet status.
   951    // It is only filled in if the information is about a group of tablets.
   952    // AggregateStats aggregate_stats = 6;
   953  
   954    // tablet_alias is the alias of the sending tablet. The discovery/healthcheck.go
   955    // code uses it to verify that it's talking to the correct tablet and that it
   956    // hasn't changed in the meantime e.g. due to tablet restarts where ports or
   957    // ips have been reused but assigned differently.
   958    topodata.TabletAlias tablet_alias = 5;
   959  }
   960  
   961  // TransactionState represents the state of a distributed transaction.
   962  enum TransactionState {
   963    UNKNOWN = 0;
   964    PREPARE = 1;
   965    COMMIT = 2;
   966    ROLLBACK = 3;
   967  }
   968  
   969  // TransactionMetadata contains the metadata for a distributed transaction.
   970  message TransactionMetadata {
   971    string dtid = 1;
   972    TransactionState state = 2;
   973    int64 time_created = 3;
   974    repeated Target participants = 4;
   975  }
   976  
   977  
   978  // SchemaTableType represents the type of table requested.
   979  enum SchemaTableType {
   980    VIEWS = 0;
   981    TABLES = 1;
   982    ALL = 2;
   983  }
   984  
   985  // GetSchemaRequest is the payload to GetSchema
   986  message GetSchemaRequest {
   987    Target target = 1;
   988    SchemaTableType table_type = 2;
   989    repeated string table_names = 3;
   990  }
   991  
   992  // GetSchemaResponse is the returned value from GetSchema
   993  message GetSchemaResponse {
   994    // this is for the schema definition for the requested tables.
   995    map<string, string> table_definition = 2;
   996  }