xref: /aosp_15_r20/external/googleapis/google/spanner/v1/spanner.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.spanner.v1;
18
19import public "google/spanner/v1/commit_response.proto";
20
21import "google/api/annotations.proto";
22import "google/api/client.proto";
23import "google/api/field_behavior.proto";
24import "google/api/resource.proto";
25import "google/protobuf/duration.proto";
26import "google/protobuf/empty.proto";
27import "google/protobuf/struct.proto";
28import "google/protobuf/timestamp.proto";
29import "google/rpc/status.proto";
30import "google/spanner/v1/keys.proto";
31import "google/spanner/v1/mutation.proto";
32import "google/spanner/v1/result_set.proto";
33import "google/spanner/v1/transaction.proto";
34import "google/spanner/v1/type.proto";
35
36option csharp_namespace = "Google.Cloud.Spanner.V1";
37option go_package = "cloud.google.com/go/spanner/apiv1/spannerpb;spannerpb";
38option java_multiple_files = true;
39option java_outer_classname = "SpannerProto";
40option java_package = "com.google.spanner.v1";
41option php_namespace = "Google\\Cloud\\Spanner\\V1";
42option ruby_package = "Google::Cloud::Spanner::V1";
43option (google.api.resource_definition) = {
44  type: "spanner.googleapis.com/Database"
45  pattern: "projects/{project}/instances/{instance}/databases/{database}"
46};
47
48// Cloud Spanner API
49//
50// The Cloud Spanner API can be used to manage sessions and execute
51// transactions on data stored in Cloud Spanner databases.
52service Spanner {
53  option (google.api.default_host) = "spanner.googleapis.com";
54  option (google.api.oauth_scopes) =
55      "https://www.googleapis.com/auth/cloud-platform,"
56      "https://www.googleapis.com/auth/spanner.data";
57
58  // Creates a new session. A session can be used to perform
59  // transactions that read and/or modify data in a Cloud Spanner database.
60  // Sessions are meant to be reused for many consecutive
61  // transactions.
62  //
63  // Sessions can only execute one transaction at a time. To execute
64  // multiple concurrent read-write/write-only transactions, create
65  // multiple sessions. Note that standalone reads and queries use a
66  // transaction internally, and count toward the one transaction
67  // limit.
68  //
69  // Active sessions use additional server resources, so it is a good idea to
70  // delete idle and unneeded sessions.
71  // Aside from explicit deletes, Cloud Spanner may delete sessions for which no
72  // operations are sent for more than an hour. If a session is deleted,
73  // requests to it return `NOT_FOUND`.
74  //
75  // Idle sessions can be kept alive by sending a trivial SQL query
76  // periodically, e.g., `"SELECT 1"`.
77  rpc CreateSession(CreateSessionRequest) returns (Session) {
78    option (google.api.http) = {
79      post: "/v1/{database=projects/*/instances/*/databases/*}/sessions"
80      body: "*"
81    };
82    option (google.api.method_signature) = "database";
83  }
84
85  // Creates multiple new sessions.
86  //
87  // This API can be used to initialize a session cache on the clients.
88  // See https://goo.gl/TgSFN2 for best practices on session cache management.
89  rpc BatchCreateSessions(BatchCreateSessionsRequest)
90      returns (BatchCreateSessionsResponse) {
91    option (google.api.http) = {
92      post: "/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate"
93      body: "*"
94    };
95    option (google.api.method_signature) = "database,session_count";
96  }
97
98  // Gets a session. Returns `NOT_FOUND` if the session does not exist.
99  // This is mainly useful for determining whether a session is still
100  // alive.
101  rpc GetSession(GetSessionRequest) returns (Session) {
102    option (google.api.http) = {
103      get: "/v1/{name=projects/*/instances/*/databases/*/sessions/*}"
104    };
105    option (google.api.method_signature) = "name";
106  }
107
108  // Lists all sessions in a given database.
109  rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) {
110    option (google.api.http) = {
111      get: "/v1/{database=projects/*/instances/*/databases/*}/sessions"
112    };
113    option (google.api.method_signature) = "database";
114  }
115
116  // Ends a session, releasing server resources associated with it. This will
117  // asynchronously trigger cancellation of any operations that are running with
118  // this session.
119  rpc DeleteSession(DeleteSessionRequest) returns (google.protobuf.Empty) {
120    option (google.api.http) = {
121      delete: "/v1/{name=projects/*/instances/*/databases/*/sessions/*}"
122    };
123    option (google.api.method_signature) = "name";
124  }
125
126  // Executes an SQL statement, returning all results in a single reply. This
127  // method cannot be used to return a result set larger than 10 MiB;
128  // if the query yields more data than that, the query fails with
129  // a `FAILED_PRECONDITION` error.
130  //
131  // Operations inside read-write transactions might return `ABORTED`. If
132  // this occurs, the application should restart the transaction from
133  // the beginning. See [Transaction][google.spanner.v1.Transaction] for more
134  // details.
135  //
136  // Larger result sets can be fetched in streaming fashion by calling
137  // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql]
138  // instead.
139  rpc ExecuteSql(ExecuteSqlRequest) returns (ResultSet) {
140    option (google.api.http) = {
141      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql"
142      body: "*"
143    };
144  }
145
146  // Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the
147  // result set as a stream. Unlike
148  // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there is no limit on
149  // the size of the returned result set. However, no individual row in the
150  // result set can exceed 100 MiB, and no column value can exceed 10 MiB.
151  rpc ExecuteStreamingSql(ExecuteSqlRequest) returns (stream PartialResultSet) {
152    option (google.api.http) = {
153      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql"
154      body: "*"
155    };
156  }
157
158  // Executes a batch of SQL DML statements. This method allows many statements
159  // to be run with lower latency than submitting them sequentially with
160  // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
161  //
162  // Statements are executed in sequential order. A request can succeed even if
163  // a statement fails. The
164  // [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status]
165  // field in the response provides information about the statement that failed.
166  // Clients must inspect this field to determine whether an error occurred.
167  //
168  // Execution stops after the first failed statement; the remaining statements
169  // are not executed.
170  rpc ExecuteBatchDml(ExecuteBatchDmlRequest)
171      returns (ExecuteBatchDmlResponse) {
172    option (google.api.http) = {
173      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml"
174      body: "*"
175    };
176  }
177
178  // Reads rows from the database using key lookups and scans, as a
179  // simple key/value style alternative to
180  // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].  This method cannot be
181  // used to return a result set larger than 10 MiB; if the read matches more
182  // data than that, the read fails with a `FAILED_PRECONDITION`
183  // error.
184  //
185  // Reads inside read-write transactions might return `ABORTED`. If
186  // this occurs, the application should restart the transaction from
187  // the beginning. See [Transaction][google.spanner.v1.Transaction] for more
188  // details.
189  //
190  // Larger result sets can be yielded in streaming fashion by calling
191  // [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead.
192  rpc Read(ReadRequest) returns (ResultSet) {
193    option (google.api.http) = {
194      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read"
195      body: "*"
196    };
197  }
198
199  // Like [Read][google.spanner.v1.Spanner.Read], except returns the result set
200  // as a stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no
201  // limit on the size of the returned result set. However, no individual row in
202  // the result set can exceed 100 MiB, and no column value can exceed
203  // 10 MiB.
204  rpc StreamingRead(ReadRequest) returns (stream PartialResultSet) {
205    option (google.api.http) = {
206      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead"
207      body: "*"
208    };
209  }
210
211  // Begins a new transaction. This step can often be skipped:
212  // [Read][google.spanner.v1.Spanner.Read],
213  // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
214  // [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a
215  // side-effect.
216  rpc BeginTransaction(BeginTransactionRequest) returns (Transaction) {
217    option (google.api.http) = {
218      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction"
219      body: "*"
220    };
221    option (google.api.method_signature) = "session,options";
222  }
223
224  // Commits a transaction. The request includes the mutations to be
225  // applied to rows in the database.
226  //
227  // `Commit` might return an `ABORTED` error. This can occur at any time;
228  // commonly, the cause is conflicts with concurrent
229  // transactions. However, it can also happen for a variety of other
230  // reasons. If `Commit` returns `ABORTED`, the caller should re-attempt
231  // the transaction from the beginning, re-using the same session.
232  //
233  // On very rare occasions, `Commit` might return `UNKNOWN`. This can happen,
234  // for example, if the client job experiences a 1+ hour networking failure.
235  // At that point, Cloud Spanner has lost track of the transaction outcome and
236  // we recommend that you perform another read from the database to see the
237  // state of things as they are now.
238  rpc Commit(CommitRequest) returns (CommitResponse) {
239    option (google.api.http) = {
240      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit"
241      body: "*"
242    };
243    option (google.api.method_signature) = "session,transaction_id,mutations";
244    option (google.api.method_signature) =
245        "session,single_use_transaction,mutations";
246  }
247
248  // Rolls back a transaction, releasing any locks it holds. It is a good
249  // idea to call this for any transaction that includes one or more
250  // [Read][google.spanner.v1.Spanner.Read] or
251  // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and ultimately
252  // decides not to commit.
253  //
254  // `Rollback` returns `OK` if it successfully aborts the transaction, the
255  // transaction was already aborted, or the transaction is not
256  // found. `Rollback` never returns `ABORTED`.
257  rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) {
258    option (google.api.http) = {
259      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback"
260      body: "*"
261    };
262    option (google.api.method_signature) = "session,transaction_id";
263  }
264
265  // Creates a set of partition tokens that can be used to execute a query
266  // operation in parallel.  Each of the returned partition tokens can be used
267  // by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to
268  // specify a subset of the query result to read.  The same session and
269  // read-only transaction must be used by the PartitionQueryRequest used to
270  // create the partition tokens and the ExecuteSqlRequests that use the
271  // partition tokens.
272  //
273  // Partition tokens become invalid when the session used to create them
274  // is deleted, is idle for too long, begins a new transaction, or becomes too
275  // old.  When any of these happen, it is not possible to resume the query, and
276  // the whole operation must be restarted from the beginning.
277  rpc PartitionQuery(PartitionQueryRequest) returns (PartitionResponse) {
278    option (google.api.http) = {
279      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery"
280      body: "*"
281    };
282  }
283
284  // Creates a set of partition tokens that can be used to execute a read
285  // operation in parallel.  Each of the returned partition tokens can be used
286  // by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a
287  // subset of the read result to read.  The same session and read-only
288  // transaction must be used by the PartitionReadRequest used to create the
289  // partition tokens and the ReadRequests that use the partition tokens.  There
290  // are no ordering guarantees on rows returned among the returned partition
291  // tokens, or even within each individual StreamingRead call issued with a
292  // partition_token.
293  //
294  // Partition tokens become invalid when the session used to create them
295  // is deleted, is idle for too long, begins a new transaction, or becomes too
296  // old.  When any of these happen, it is not possible to resume the read, and
297  // the whole operation must be restarted from the beginning.
298  rpc PartitionRead(PartitionReadRequest) returns (PartitionResponse) {
299    option (google.api.http) = {
300      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead"
301      body: "*"
302    };
303  }
304
305  // Batches the supplied mutation groups in a collection of efficient
306  // transactions. All mutations in a group are committed atomically. However,
307  // mutations across groups can be committed non-atomically in an unspecified
308  // order and thus, they must be independent of each other. Partial failure is
309  // possible, i.e., some groups may have been committed successfully, while
310  // some may have failed. The results of individual batches are streamed into
311  // the response as the batches are applied.
312  //
313  // BatchWrite requests are not replay protected, meaning that each mutation
314  // group may be applied more than once. Replays of non-idempotent mutations
315  // may have undesirable effects. For example, replays of an insert mutation
316  // may produce an already exists error or if you use generated or commit
317  // timestamp-based keys, it may result in additional rows being added to the
318  // mutation's table. We recommend structuring your mutation groups to be
319  // idempotent to avoid this issue.
320  rpc BatchWrite(BatchWriteRequest) returns (stream BatchWriteResponse) {
321    option (google.api.http) = {
322      post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:batchWrite"
323      body: "*"
324    };
325    option (google.api.method_signature) = "session,mutation_groups";
326  }
327}
328
329// The request for [CreateSession][google.spanner.v1.Spanner.CreateSession].
330message CreateSessionRequest {
331  // Required. The database in which the new session is created.
332  string database = 1 [
333    (google.api.field_behavior) = REQUIRED,
334    (google.api.resource_reference) = {
335      type: "spanner.googleapis.com/Database"
336    }
337  ];
338
339  // Required. The session to create.
340  Session session = 2 [(google.api.field_behavior) = REQUIRED];
341}
342
343// The request for
344// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
345message BatchCreateSessionsRequest {
346  // Required. The database in which the new sessions are created.
347  string database = 1 [
348    (google.api.field_behavior) = REQUIRED,
349    (google.api.resource_reference) = {
350      type: "spanner.googleapis.com/Database"
351    }
352  ];
353
354  // Parameters to be applied to each created session.
355  Session session_template = 2;
356
357  // Required. The number of sessions to be created in this batch call.
358  // The API may return fewer than the requested number of sessions. If a
359  // specific number of sessions are desired, the client can make additional
360  // calls to BatchCreateSessions (adjusting
361  // [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count]
362  // as necessary).
363  int32 session_count = 3 [(google.api.field_behavior) = REQUIRED];
364}
365
366// The response for
367// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
368message BatchCreateSessionsResponse {
369  // The freshly created sessions.
370  repeated Session session = 1;
371}
372
373// A session in the Cloud Spanner API.
374message Session {
375  option (google.api.resource) = {
376    type: "spanner.googleapis.com/Session"
377    pattern: "projects/{project}/instances/{instance}/databases/{database}/sessions/{session}"
378  };
379
380  // Output only. The name of the session. This is always system-assigned.
381  string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
382
383  // The labels for the session.
384  //
385  //  * Label keys must be between 1 and 63 characters long and must conform to
386  //    the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.
387  //  * Label values must be between 0 and 63 characters long and must conform
388  //    to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
389  //  * No more than 64 labels can be associated with a given session.
390  //
391  // See https://goo.gl/xmQnxf for more information on and examples of labels.
392  map<string, string> labels = 2;
393
394  // Output only. The timestamp when the session is created.
395  google.protobuf.Timestamp create_time = 3
396      [(google.api.field_behavior) = OUTPUT_ONLY];
397
398  // Output only. The approximate timestamp when the session is last used. It is
399  // typically earlier than the actual last use time.
400  google.protobuf.Timestamp approximate_last_use_time = 4
401      [(google.api.field_behavior) = OUTPUT_ONLY];
402
403  // The database role which created this session.
404  string creator_role = 5;
405
406  // Optional. If true, specifies a multiplexed session. A multiplexed session
407  // may be used for multiple, concurrent read-only operations but can not be
408  // used for read-write transactions, partitioned reads, or partitioned
409  // queries. Multiplexed sessions can be created via
410  // [CreateSession][google.spanner.v1.Spanner.CreateSession] but not via
411  // [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
412  // Multiplexed sessions may not be deleted nor listed.
413  bool multiplexed = 6 [(google.api.field_behavior) = OPTIONAL];
414}
415
416// The request for [GetSession][google.spanner.v1.Spanner.GetSession].
417message GetSessionRequest {
418  // Required. The name of the session to retrieve.
419  string name = 1 [
420    (google.api.field_behavior) = REQUIRED,
421    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
422  ];
423}
424
425// The request for [ListSessions][google.spanner.v1.Spanner.ListSessions].
426message ListSessionsRequest {
427  // Required. The database in which to list sessions.
428  string database = 1 [
429    (google.api.field_behavior) = REQUIRED,
430    (google.api.resource_reference) = {
431      type: "spanner.googleapis.com/Database"
432    }
433  ];
434
435  // Number of sessions to be returned in the response. If 0 or less, defaults
436  // to the server's maximum allowed page size.
437  int32 page_size = 2;
438
439  // If non-empty, `page_token` should contain a
440  // [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token]
441  // from a previous
442  // [ListSessionsResponse][google.spanner.v1.ListSessionsResponse].
443  string page_token = 3;
444
445  // An expression for filtering the results of the request. Filter rules are
446  // case insensitive. The fields eligible for filtering are:
447  //
448  //   * `labels.key` where key is the name of a label
449  //
450  // Some examples of using filters are:
451  //
452  //   * `labels.env:*` --> The session has the label "env".
453  //   * `labels.env:dev` --> The session has the label "env" and the value of
454  //                        the label contains the string "dev".
455  string filter = 4;
456}
457
458// The response for [ListSessions][google.spanner.v1.Spanner.ListSessions].
459message ListSessionsResponse {
460  // The list of requested sessions.
461  repeated Session sessions = 1;
462
463  // `next_page_token` can be sent in a subsequent
464  // [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more
465  // of the matching sessions.
466  string next_page_token = 2;
467}
468
469// The request for [DeleteSession][google.spanner.v1.Spanner.DeleteSession].
470message DeleteSessionRequest {
471  // Required. The name of the session to delete.
472  string name = 1 [
473    (google.api.field_behavior) = REQUIRED,
474    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
475  ];
476}
477
478// Common request options for various APIs.
479message RequestOptions {
480  // The relative priority for requests. Note that priority is not applicable
481  // for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
482  //
483  // The priority acts as a hint to the Cloud Spanner scheduler and does not
484  // guarantee priority or order of execution. For example:
485  //
486  // * Some parts of a write operation always execute at `PRIORITY_HIGH`,
487  //   regardless of the specified priority. This may cause you to see an
488  //   increase in high priority workload even when executing a low priority
489  //   request. This can also potentially cause a priority inversion where a
490  //   lower priority request will be fulfilled ahead of a higher priority
491  //   request.
492  // * If a transaction contains multiple operations with different priorities,
493  //   Cloud Spanner does not guarantee to process the higher priority
494  //   operations first. There may be other constraints to satisfy, such as
495  //   order of operations.
496  enum Priority {
497    // `PRIORITY_UNSPECIFIED` is equivalent to `PRIORITY_HIGH`.
498    PRIORITY_UNSPECIFIED = 0;
499
500    // This specifies that the request is low priority.
501    PRIORITY_LOW = 1;
502
503    // This specifies that the request is medium priority.
504    PRIORITY_MEDIUM = 2;
505
506    // This specifies that the request is high priority.
507    PRIORITY_HIGH = 3;
508  }
509
510  // Priority for the request.
511  Priority priority = 1;
512
513  // A per-request tag which can be applied to queries or reads, used for
514  // statistics collection.
515  // Both request_tag and transaction_tag can be specified for a read or query
516  // that belongs to a transaction.
517  // This field is ignored for requests where it's not applicable (e.g.
518  // CommitRequest).
519  // Legal characters for `request_tag` values are all printable characters
520  // (ASCII 32 - 126) and the length of a request_tag is limited to 50
521  // characters. Values that exceed this limit are truncated.
522  // Any leading underscore (_) characters will be removed from the string.
523  string request_tag = 2;
524
525  // A tag used for statistics collection about this transaction.
526  // Both request_tag and transaction_tag can be specified for a read or query
527  // that belongs to a transaction.
528  // The value of transaction_tag should be the same for all requests belonging
529  // to the same transaction.
530  // If this request doesn't belong to any transaction, transaction_tag will be
531  // ignored.
532  // Legal characters for `transaction_tag` values are all printable characters
533  // (ASCII 32 - 126) and the length of a transaction_tag is limited to 50
534  // characters. Values that exceed this limit are truncated.
535  // Any leading underscore (_) characters will be removed from the string.
536  string transaction_tag = 3;
537}
538
539// The DirectedReadOptions can be used to indicate which replicas or regions
540// should be used for non-transactional reads or queries.
541//
542// DirectedReadOptions may only be specified for a read-only transaction,
543// otherwise the API will return an `INVALID_ARGUMENT` error.
544message DirectedReadOptions {
545  // The directed read replica selector.
546  // Callers must provide one or more of the following fields for replica
547  // selection:
548  //
549  //   * `location` - The location must be one of the regions within the
550  //      multi-region configuration of your database.
551  //   * `type` - The type of the replica.
552  //
553  // Some examples of using replica_selectors are:
554  //
555  //   * `location:us-east1` --> The "us-east1" replica(s) of any available type
556  //                             will be used to process the request.
557  //   * `type:READ_ONLY`    --> The "READ_ONLY" type replica(s) in nearest
558  //                             available location will be used to process the
559  //                             request.
560  //   * `location:us-east1 type:READ_ONLY` --> The "READ_ONLY" type replica(s)
561  //                          in location "us-east1" will be used to process
562  //                          the request.
563  message ReplicaSelection {
564    // Indicates the type of replica.
565    enum Type {
566      // Not specified.
567      TYPE_UNSPECIFIED = 0;
568
569      // Read-write replicas support both reads and writes.
570      READ_WRITE = 1;
571
572      // Read-only replicas only support reads (not writes).
573      READ_ONLY = 2;
574    }
575
576    // The location or region of the serving requests, e.g. "us-east1".
577    string location = 1;
578
579    // The type of replica.
580    Type type = 2;
581  }
582
583  // An IncludeReplicas contains a repeated set of ReplicaSelection which
584  // indicates the order in which replicas should be considered.
585  message IncludeReplicas {
586    // The directed read replica selector.
587    repeated ReplicaSelection replica_selections = 1;
588
589    // If true, Spanner will not route requests to a replica outside the
590    // include_replicas list when all of the specified replicas are unavailable
591    // or unhealthy. Default value is `false`.
592    bool auto_failover_disabled = 2;
593  }
594
595  // An ExcludeReplicas contains a repeated set of ReplicaSelection that should
596  // be excluded from serving requests.
597  message ExcludeReplicas {
598    // The directed read replica selector.
599    repeated ReplicaSelection replica_selections = 1;
600  }
601
602  // Required. At most one of either include_replicas or exclude_replicas
603  // should be present in the message.
604  oneof replicas {
605    // Include_replicas indicates the order of replicas (as they appear in
606    // this list) to process the request. If auto_failover_disabled is set to
607    // true and all replicas are exhausted without finding a healthy replica,
608    // Spanner will wait for a replica in the list to become available, requests
609    // may fail due to `DEADLINE_EXCEEDED` errors.
610    IncludeReplicas include_replicas = 1;
611
612    // Exclude_replicas indicates that specified replicas should be excluded
613    // from serving requests. Spanner will not route requests to the replicas
614    // in this list.
615    ExcludeReplicas exclude_replicas = 2;
616  }
617}
618
619// The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
620// [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
621message ExecuteSqlRequest {
622  // Mode in which the statement must be processed.
623  enum QueryMode {
624    // The default mode. Only the statement results are returned.
625    NORMAL = 0;
626
627    // This mode returns only the query plan, without any results or
628    // execution statistics information.
629    PLAN = 1;
630
631    // This mode returns both the query plan and the execution statistics along
632    // with the results.
633    PROFILE = 2;
634  }
635
636  // Query optimizer configuration.
637  message QueryOptions {
638    // An option to control the selection of optimizer version.
639    //
640    // This parameter allows individual queries to pick different query
641    // optimizer versions.
642    //
643    // Specifying `latest` as a value instructs Cloud Spanner to use the
644    // latest supported query optimizer version. If not specified, Cloud Spanner
645    // uses the optimizer version set at the database level options. Any other
646    // positive integer (from the list of supported optimizer versions)
647    // overrides the default optimizer version for query execution.
648    //
649    // The list of supported optimizer versions can be queried from
650    // SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS.
651    //
652    // Executing a SQL statement with an invalid optimizer version fails with
653    // an `INVALID_ARGUMENT` error.
654    //
655    // See
656    // https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer
657    // for more information on managing the query optimizer.
658    //
659    // The `optimizer_version` statement hint has precedence over this setting.
660    string optimizer_version = 1;
661
662    // An option to control the selection of optimizer statistics package.
663    //
664    // This parameter allows individual queries to use a different query
665    // optimizer statistics package.
666    //
667    // Specifying `latest` as a value instructs Cloud Spanner to use the latest
668    // generated statistics package. If not specified, Cloud Spanner uses
669    // the statistics package set at the database level options, or the latest
670    // package if the database option is not set.
671    //
672    // The statistics package requested by the query has to be exempt from
673    // garbage collection. This can be achieved with the following DDL
674    // statement:
675    //
676    // ```
677    // ALTER STATISTICS <package_name> SET OPTIONS (allow_gc=false)
678    // ```
679    //
680    // The list of available statistics packages can be queried from
681    // `INFORMATION_SCHEMA.SPANNER_STATISTICS`.
682    //
683    // Executing a SQL statement with an invalid optimizer statistics package
684    // or with a statistics package that allows garbage collection fails with
685    // an `INVALID_ARGUMENT` error.
686    string optimizer_statistics_package = 2;
687  }
688
689  // Required. The session in which the SQL query should be performed.
690  string session = 1 [
691    (google.api.field_behavior) = REQUIRED,
692    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
693  ];
694
695  // The transaction to use.
696  //
697  // For queries, if none is provided, the default is a temporary read-only
698  // transaction with strong concurrency.
699  //
700  // Standard DML statements require a read-write transaction. To protect
701  // against replays, single-use transactions are not supported.  The caller
702  // must either supply an existing transaction ID or begin a new transaction.
703  //
704  // Partitioned DML requires an existing Partitioned DML transaction ID.
705  TransactionSelector transaction = 2;
706
707  // Required. The SQL string.
708  string sql = 3 [(google.api.field_behavior) = REQUIRED];
709
710  // Parameter names and values that bind to placeholders in the SQL string.
711  //
712  // A parameter placeholder consists of the `@` character followed by the
713  // parameter name (for example, `@firstName`). Parameter names must conform
714  // to the naming requirements of identifiers as specified at
715  // https://cloud.google.com/spanner/docs/lexical#identifiers.
716  //
717  // Parameters can appear anywhere that a literal value is expected.  The same
718  // parameter name can be used more than once, for example:
719  //
720  // `"WHERE id > @msg_id AND id < @msg_id + 100"`
721  //
722  // It is an error to execute a SQL statement with unbound parameters.
723  google.protobuf.Struct params = 4;
724
725  // It is not always possible for Cloud Spanner to infer the right SQL type
726  // from a JSON value.  For example, values of type `BYTES` and values
727  // of type `STRING` both appear in
728  // [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings.
729  //
730  // In these cases, `param_types` can be used to specify the exact
731  // SQL type for some or all of the SQL statement parameters. See the
732  // definition of [Type][google.spanner.v1.Type] for more information
733  // about SQL types.
734  map<string, Type> param_types = 5;
735
736  // If this request is resuming a previously interrupted SQL statement
737  // execution, `resume_token` should be copied from the last
738  // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
739  // interruption. Doing this enables the new SQL statement execution to resume
740  // where the last one left off. The rest of the request parameters must
741  // exactly match the request that yielded this token.
742  bytes resume_token = 6;
743
744  // Used to control the amount of debugging information returned in
745  // [ResultSetStats][google.spanner.v1.ResultSetStats]. If
746  // [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is
747  // set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only
748  // be set to
749  // [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL].
750  QueryMode query_mode = 7;
751
752  // If present, results will be restricted to the specified partition
753  // previously created using PartitionQuery().  There must be an exact
754  // match for the values of fields common to this message and the
755  // PartitionQueryRequest message used to create this partition_token.
756  bytes partition_token = 8;
757
758  // A per-transaction sequence number used to identify this request. This field
759  // makes each request idempotent such that if the request is received multiple
760  // times, at most one will succeed.
761  //
762  // The sequence number must be monotonically increasing within the
763  // transaction. If a request arrives for the first time with an out-of-order
764  // sequence number, the transaction may be aborted. Replays of previously
765  // handled requests will yield the same response as the first execution.
766  //
767  // Required for DML statements. Ignored for queries.
768  int64 seqno = 9;
769
770  // Query optimizer configuration to use for the given query.
771  QueryOptions query_options = 10;
772
773  // Common options for this request.
774  RequestOptions request_options = 11;
775
776  // Directed read options for this request.
777  DirectedReadOptions directed_read_options = 15;
778
779  // If this is for a partitioned query and this field is set to `true`, the
780  // request is executed with Spanner Data Boost independent compute resources.
781  //
782  // If the field is set to `true` but the request does not set
783  // `partition_token`, the API returns an `INVALID_ARGUMENT` error.
784  bool data_boost_enabled = 16;
785}
786
787// The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
788message ExecuteBatchDmlRequest {
789  // A single DML statement.
790  message Statement {
791    // Required. The DML string.
792    string sql = 1 [(google.api.field_behavior) = REQUIRED];
793
794    // Parameter names and values that bind to placeholders in the DML string.
795    //
796    // A parameter placeholder consists of the `@` character followed by the
797    // parameter name (for example, `@firstName`). Parameter names can contain
798    // letters, numbers, and underscores.
799    //
800    // Parameters can appear anywhere that a literal value is expected.  The
801    // same parameter name can be used more than once, for example:
802    //
803    // `"WHERE id > @msg_id AND id < @msg_id + 100"`
804    //
805    // It is an error to execute a SQL statement with unbound parameters.
806    google.protobuf.Struct params = 2;
807
808    // It is not always possible for Cloud Spanner to infer the right SQL type
809    // from a JSON value.  For example, values of type `BYTES` and values
810    // of type `STRING` both appear in
811    // [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as
812    // JSON strings.
813    //
814    // In these cases, `param_types` can be used to specify the exact
815    // SQL type for some or all of the SQL statement parameters. See the
816    // definition of [Type][google.spanner.v1.Type] for more information
817    // about SQL types.
818    map<string, Type> param_types = 3;
819  }
820
821  // Required. The session in which the DML statements should be performed.
822  string session = 1 [
823    (google.api.field_behavior) = REQUIRED,
824    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
825  ];
826
827  // Required. The transaction to use. Must be a read-write transaction.
828  //
829  // To protect against replays, single-use transactions are not supported. The
830  // caller must either supply an existing transaction ID or begin a new
831  // transaction.
832  TransactionSelector transaction = 2 [(google.api.field_behavior) = REQUIRED];
833
834  // Required. The list of statements to execute in this batch. Statements are
835  // executed serially, such that the effects of statement `i` are visible to
836  // statement `i+1`. Each statement must be a DML statement. Execution stops at
837  // the first failed statement; the remaining statements are not executed.
838  //
839  // Callers must provide at least one statement.
840  repeated Statement statements = 3 [(google.api.field_behavior) = REQUIRED];
841
842  // Required. A per-transaction sequence number used to identify this request.
843  // This field makes each request idempotent such that if the request is
844  // received multiple times, at most one will succeed.
845  //
846  // The sequence number must be monotonically increasing within the
847  // transaction. If a request arrives for the first time with an out-of-order
848  // sequence number, the transaction may be aborted. Replays of previously
849  // handled requests will yield the same response as the first execution.
850  int64 seqno = 4 [(google.api.field_behavior) = REQUIRED];
851
852  // Common options for this request.
853  RequestOptions request_options = 5;
854}
855
856// The response for
857// [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
858// of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML
859// statement that has successfully executed, in the same order as the statements
860// in the request. If a statement fails, the status in the response body
861// identifies the cause of the failure.
862//
863// To check for DML statements that failed, use the following approach:
864//
865// 1. Check the status in the response message. The
866// [google.rpc.Code][google.rpc.Code] enum
867//    value `OK` indicates that all statements were executed successfully.
868// 2. If the status was not `OK`, check the number of result sets in the
869//    response. If the response contains `N`
870//    [ResultSet][google.spanner.v1.ResultSet] messages, then statement `N+1` in
871//    the request failed.
872//
873// Example 1:
874//
875// * Request: 5 DML statements, all executed successfully.
876// * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the
877// status `OK`.
878//
879// Example 2:
880//
881// * Request: 5 DML statements. The third statement has a syntax error.
882// * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax
883// error (`INVALID_ARGUMENT`)
884//   status. The number of [ResultSet][google.spanner.v1.ResultSet] messages
885//   indicates that the third statement failed, and the fourth and fifth
886//   statements were not executed.
887message ExecuteBatchDmlResponse {
888  // One [ResultSet][google.spanner.v1.ResultSet] for each statement in the
889  // request that ran successfully, in the same order as the statements in the
890  // request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any
891  // rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each
892  // [ResultSet][google.spanner.v1.ResultSet] contain the number of rows
893  // modified by the statement.
894  //
895  // Only the first [ResultSet][google.spanner.v1.ResultSet] in the response
896  // contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata].
897  repeated ResultSet result_sets = 1;
898
899  // If all DML statements are executed successfully, the status is `OK`.
900  // Otherwise, the error status of the first failed statement.
901  google.rpc.Status status = 2;
902}
903
904// Options for a PartitionQueryRequest and
905// PartitionReadRequest.
906message PartitionOptions {
907  // **Note:** This hint is currently ignored by PartitionQuery and
908  // PartitionRead requests.
909  //
910  // The desired data size for each partition generated.  The default for this
911  // option is currently 1 GiB.  This is only a hint. The actual size of each
912  // partition may be smaller or larger than this size request.
913  int64 partition_size_bytes = 1;
914
915  // **Note:** This hint is currently ignored by PartitionQuery and
916  // PartitionRead requests.
917  //
918  // The desired maximum number of partitions to return.  For example, this may
919  // be set to the number of workers available.  The default for this option
920  // is currently 10,000. The maximum value is currently 200,000.  This is only
921  // a hint.  The actual number of partitions returned may be smaller or larger
922  // than this maximum count request.
923  int64 max_partitions = 2;
924}
925
926// The request for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
927message PartitionQueryRequest {
928  // Required. The session used to create the partitions.
929  string session = 1 [
930    (google.api.field_behavior) = REQUIRED,
931    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
932  ];
933
934  // Read only snapshot transactions are supported, read/write and single use
935  // transactions are not.
936  TransactionSelector transaction = 2;
937
938  // Required. The query request to generate partitions for. The request will
939  // fail if the query is not root partitionable. For a query to be root
940  // partitionable, it needs to satisfy a few conditions. For example, if the
941  // query execution plan contains a distributed union operator, then it must be
942  // the first operator in the plan. For more information about other
943  // conditions, see [Read data in
944  // parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel).
945  //
946  // The query request must not contain DML commands, such as INSERT, UPDATE, or
947  // DELETE. Use
948  // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a
949  // PartitionedDml transaction for large, partition-friendly DML operations.
950  string sql = 3 [(google.api.field_behavior) = REQUIRED];
951
952  // Parameter names and values that bind to placeholders in the SQL string.
953  //
954  // A parameter placeholder consists of the `@` character followed by the
955  // parameter name (for example, `@firstName`). Parameter names can contain
956  // letters, numbers, and underscores.
957  //
958  // Parameters can appear anywhere that a literal value is expected.  The same
959  // parameter name can be used more than once, for example:
960  //
961  // `"WHERE id > @msg_id AND id < @msg_id + 100"`
962  //
963  // It is an error to execute a SQL statement with unbound parameters.
964  google.protobuf.Struct params = 4;
965
966  // It is not always possible for Cloud Spanner to infer the right SQL type
967  // from a JSON value.  For example, values of type `BYTES` and values
968  // of type `STRING` both appear in
969  // [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings.
970  //
971  // In these cases, `param_types` can be used to specify the exact
972  // SQL type for some or all of the SQL query parameters. See the
973  // definition of [Type][google.spanner.v1.Type] for more information
974  // about SQL types.
975  map<string, Type> param_types = 5;
976
977  // Additional options that affect how many partitions are created.
978  PartitionOptions partition_options = 6;
979}
980
981// The request for [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
982message PartitionReadRequest {
983  // Required. The session used to create the partitions.
984  string session = 1 [
985    (google.api.field_behavior) = REQUIRED,
986    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
987  ];
988
989  // Read only snapshot transactions are supported, read/write and single use
990  // transactions are not.
991  TransactionSelector transaction = 2;
992
993  // Required. The name of the table in the database to be read.
994  string table = 3 [(google.api.field_behavior) = REQUIRED];
995
996  // If non-empty, the name of an index on
997  // [table][google.spanner.v1.PartitionReadRequest.table]. This index is used
998  // instead of the table primary key when interpreting
999  // [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting
1000  // result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set]
1001  // for further information.
1002  string index = 4;
1003
1004  // The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be
1005  // returned for each row matching this request.
1006  repeated string columns = 5;
1007
1008  // Required. `key_set` identifies the rows to be yielded. `key_set` names the
1009  // primary keys of the rows in
1010  // [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless
1011  // [index][google.spanner.v1.PartitionReadRequest.index] is present. If
1012  // [index][google.spanner.v1.PartitionReadRequest.index] is present, then
1013  // [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names
1014  // index keys in [index][google.spanner.v1.PartitionReadRequest.index].
1015  //
1016  // It is not an error for the `key_set` to name rows that do not
1017  // exist in the database. Read yields nothing for nonexistent rows.
1018  KeySet key_set = 6 [(google.api.field_behavior) = REQUIRED];
1019
1020  // Additional options that affect how many partitions are created.
1021  PartitionOptions partition_options = 9;
1022}
1023
1024// Information returned for each partition returned in a
1025// PartitionResponse.
1026message Partition {
1027  // This token can be passed to Read, StreamingRead, ExecuteSql, or
1028  // ExecuteStreamingSql requests to restrict the results to those identified by
1029  // this partition token.
1030  bytes partition_token = 1;
1031}
1032
1033// The response for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
1034// or [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
1035message PartitionResponse {
1036  // Partitions created by this request.
1037  repeated Partition partitions = 1;
1038
1039  // Transaction created by this request.
1040  Transaction transaction = 2;
1041}
1042
1043// The request for [Read][google.spanner.v1.Spanner.Read] and
1044// [StreamingRead][google.spanner.v1.Spanner.StreamingRead].
1045message ReadRequest {
1046  // Required. The session in which the read should be performed.
1047  string session = 1 [
1048    (google.api.field_behavior) = REQUIRED,
1049    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1050  ];
1051
1052  // The transaction to use. If none is provided, the default is a
1053  // temporary read-only transaction with strong concurrency.
1054  TransactionSelector transaction = 2;
1055
1056  // Required. The name of the table in the database to be read.
1057  string table = 3 [(google.api.field_behavior) = REQUIRED];
1058
1059  // If non-empty, the name of an index on
1060  // [table][google.spanner.v1.ReadRequest.table]. This index is used instead of
1061  // the table primary key when interpreting
1062  // [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows.
1063  // See [key_set][google.spanner.v1.ReadRequest.key_set] for further
1064  // information.
1065  string index = 4;
1066
1067  // Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be
1068  // returned for each row matching this request.
1069  repeated string columns = 5 [(google.api.field_behavior) = REQUIRED];
1070
1071  // Required. `key_set` identifies the rows to be yielded. `key_set` names the
1072  // primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to
1073  // be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present.
1074  // If [index][google.spanner.v1.ReadRequest.index] is present, then
1075  // [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys
1076  // in [index][google.spanner.v1.ReadRequest.index].
1077  //
1078  // If the [partition_token][google.spanner.v1.ReadRequest.partition_token]
1079  // field is empty, rows are yielded in table primary key order (if
1080  // [index][google.spanner.v1.ReadRequest.index] is empty) or index key order
1081  // (if [index][google.spanner.v1.ReadRequest.index] is non-empty).  If the
1082  // [partition_token][google.spanner.v1.ReadRequest.partition_token] field is
1083  // not empty, rows will be yielded in an unspecified order.
1084  //
1085  // It is not an error for the `key_set` to name rows that do not
1086  // exist in the database. Read yields nothing for nonexistent rows.
1087  KeySet key_set = 6 [(google.api.field_behavior) = REQUIRED];
1088
1089  // If greater than zero, only the first `limit` rows are yielded. If `limit`
1090  // is zero, the default is no limit. A limit cannot be specified if
1091  // `partition_token` is set.
1092  int64 limit = 8;
1093
1094  // If this request is resuming a previously interrupted read,
1095  // `resume_token` should be copied from the last
1096  // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
1097  // interruption. Doing this enables the new read to resume where the last read
1098  // left off. The rest of the request parameters must exactly match the request
1099  // that yielded this token.
1100  bytes resume_token = 9;
1101
1102  // If present, results will be restricted to the specified partition
1103  // previously created using PartitionRead().    There must be an exact
1104  // match for the values of fields common to this message and the
1105  // PartitionReadRequest message used to create this partition_token.
1106  bytes partition_token = 10;
1107
1108  // Common options for this request.
1109  RequestOptions request_options = 11;
1110
1111  // Directed read options for this request.
1112  DirectedReadOptions directed_read_options = 14;
1113
1114  // If this is for a partitioned read and this field is set to `true`, the
1115  // request is executed with Spanner Data Boost independent compute resources.
1116  //
1117  // If the field is set to `true` but the request does not set
1118  // `partition_token`, the API returns an `INVALID_ARGUMENT` error.
1119  bool data_boost_enabled = 15;
1120}
1121
1122// The request for
1123// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
1124message BeginTransactionRequest {
1125  // Required. The session in which the transaction runs.
1126  string session = 1 [
1127    (google.api.field_behavior) = REQUIRED,
1128    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1129  ];
1130
1131  // Required. Options for the new transaction.
1132  TransactionOptions options = 2 [(google.api.field_behavior) = REQUIRED];
1133
1134  // Common options for this request.
1135  // Priority is ignored for this request. Setting the priority in this
1136  // request_options struct will not do anything. To set the priority for a
1137  // transaction, set it on the reads and writes that are part of this
1138  // transaction instead.
1139  RequestOptions request_options = 3;
1140}
1141
1142// The request for [Commit][google.spanner.v1.Spanner.Commit].
1143message CommitRequest {
1144  // Required. The session in which the transaction to be committed is running.
1145  string session = 1 [
1146    (google.api.field_behavior) = REQUIRED,
1147    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1148  ];
1149
1150  // Required. The transaction in which to commit.
1151  oneof transaction {
1152    // Commit a previously-started transaction.
1153    bytes transaction_id = 2;
1154
1155    // Execute mutations in a temporary transaction. Note that unlike
1156    // commit of a previously-started transaction, commit with a
1157    // temporary transaction is non-idempotent. That is, if the
1158    // `CommitRequest` is sent to Cloud Spanner more than once (for
1159    // instance, due to retries in the application, or in the
1160    // transport library), it is possible that the mutations are
1161    // executed more than once. If this is undesirable, use
1162    // [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and
1163    // [Commit][google.spanner.v1.Spanner.Commit] instead.
1164    TransactionOptions single_use_transaction = 3;
1165  }
1166
1167  // The mutations to be executed when this transaction commits. All
1168  // mutations are applied atomically, in the order they appear in
1169  // this list.
1170  repeated Mutation mutations = 4;
1171
1172  // If `true`, then statistics related to the transaction will be included in
1173  // the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats].
1174  // Default value is `false`.
1175  bool return_commit_stats = 5;
1176
1177  // Optional. The amount of latency this request is willing to incur in order
1178  // to improve throughput. If this field is not set, Spanner assumes requests
1179  // are relatively latency sensitive and automatically determines an
1180  // appropriate delay time. You can specify a batching delay value between 0
1181  // and 500 ms.
1182  google.protobuf.Duration max_commit_delay = 8
1183      [(google.api.field_behavior) = OPTIONAL];
1184
1185  // Common options for this request.
1186  RequestOptions request_options = 6;
1187}
1188
1189// The request for [Rollback][google.spanner.v1.Spanner.Rollback].
1190message RollbackRequest {
1191  // Required. The session in which the transaction to roll back is running.
1192  string session = 1 [
1193    (google.api.field_behavior) = REQUIRED,
1194    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1195  ];
1196
1197  // Required. The transaction to roll back.
1198  bytes transaction_id = 2 [(google.api.field_behavior) = REQUIRED];
1199}
1200
1201// The request for [BatchWrite][google.spanner.v1.Spanner.BatchWrite].
1202message BatchWriteRequest {
1203  // A group of mutations to be committed together. Related mutations should be
1204  // placed in a group. For example, two mutations inserting rows with the same
1205  // primary key prefix in both parent and child tables are related.
1206  message MutationGroup {
1207    // Required. The mutations in this group.
1208    repeated Mutation mutations = 1 [(google.api.field_behavior) = REQUIRED];
1209  }
1210
1211  // Required. The session in which the batch request is to be run.
1212  string session = 1 [
1213    (google.api.field_behavior) = REQUIRED,
1214    (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1215  ];
1216
1217  // Common options for this request.
1218  RequestOptions request_options = 3;
1219
1220  // Required. The groups of mutations to be applied.
1221  repeated MutationGroup mutation_groups = 4
1222      [(google.api.field_behavior) = REQUIRED];
1223
1224  // Optional. When `exclude_txn_from_change_streams` is set to `true`:
1225  //  * Mutations from all transactions in this batch write operation will not
1226  //  be recorded in change streams with DDL option `allow_txn_exclusion=true`
1227  //  that are tracking columns modified by these transactions.
1228  //  * Mutations from all transactions in this batch write operation will be
1229  //  recorded in change streams with DDL option `allow_txn_exclusion=false or
1230  //  not set` that are tracking columns modified by these transactions.
1231  //
1232  // When `exclude_txn_from_change_streams` is set to `false` or not set,
1233  // mutations from all transactions in this batch write operation will be
1234  // recorded in all change streams that are tracking columns modified by these
1235  // transactions.
1236  bool exclude_txn_from_change_streams = 5
1237      [(google.api.field_behavior) = OPTIONAL];
1238}
1239
1240// The result of applying a batch of mutations.
1241message BatchWriteResponse {
1242  // The mutation groups applied in this batch. The values index into the
1243  // `mutation_groups` field in the corresponding `BatchWriteRequest`.
1244  repeated int32 indexes = 1;
1245
1246  // An `OK` status indicates success. Any other status indicates a failure.
1247  google.rpc.Status status = 2;
1248
1249  // The commit timestamp of the transaction that applied this batch.
1250  // Present if `status` is `OK`, absent otherwise.
1251  google.protobuf.Timestamp commit_timestamp = 3;
1252}
1253