1- // Copyright 2018 Google Inc.
1+ // Copyright 2018 Google LLC
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -88,12 +88,12 @@ service Spanner {
8888 };
8989 }
9090
91- // Executes an SQL query , returning all rows in a single reply. This
91+ // Executes an SQL statement , returning all results in a single reply. This
9292 // method cannot be used to return a result set larger than 10 MiB;
9393 // if the query yields more data than that, the query fails with
9494 // a `FAILED_PRECONDITION` error.
9595 //
96- // Queries inside read-write transactions might return `ABORTED`. If
96+ // Operations inside read-write transactions might return `ABORTED`. If
9797 // this occurs, the application should restart the transaction from
9898 // the beginning. See [Transaction][google.spanner.v1.Transaction] for more details.
9999 //
@@ -197,8 +197,11 @@ service Spanner {
197197 // of the query result to read. The same session and read-only transaction
198198 // must be used by the PartitionQueryRequest used to create the
199199 // partition tokens and the ExecuteSqlRequests that use the partition tokens.
200+ //
200201 // Partition tokens become invalid when the session used to create them
201- // is deleted or begins a new transaction.
202+ // is deleted, is idle for too long, begins a new transaction, or becomes too
203+ // old. When any of these happen, it is not possible to resume the query, and
204+ // the whole operation must be restarted from the beginning.
202205 rpc PartitionQuery (PartitionQueryRequest ) returns (PartitionResponse ) {
203206 option (google.api.http ) = {
204207 post : "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery"
@@ -211,9 +214,14 @@ service Spanner {
211214 // by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read
212215 // result to read. The same session and read-only transaction must be used by
213216 // the PartitionReadRequest used to create the partition tokens and the
214- // ReadRequests that use the partition tokens.
217+ // ReadRequests that use the partition tokens. There are no ordering
218+ // guarantees on rows returned among the returned partition tokens, or even
219+ // within each individual StreamingRead call issued with a partition_token.
220+ //
215221 // Partition tokens become invalid when the session used to create them
216- // is deleted or begins a new transaction.
222+ // is deleted, is idle for too long, begins a new transaction, or becomes too
223+ // old. When any of these happen, it is not possible to resume the read, and
224+ // the whole operation must be restarted from the beginning.
217225 rpc PartitionRead (PartitionReadRequest ) returns (PartitionResponse ) {
218226 option (google.api.http ) = {
219227 post : "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead"
@@ -309,18 +317,17 @@ message DeleteSessionRequest {
309317// The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
310318// [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
311319message ExecuteSqlRequest {
312- // Mode in which the query must be processed.
320+ // Mode in which the statement must be processed.
313321 enum QueryMode {
314- // The default mode where only the query result, without any information
315- // about the query plan is returned.
322+ // The default mode. Only the statement results are returned.
316323 NORMAL = 0 ;
317324
318- // This mode returns only the query plan, without any result rows or
325+ // This mode returns only the query plan, without any results or
319326 // execution statistics information.
320327 PLAN = 1 ;
321328
322329 // This mode returns both the query plan and the execution statistics along
323- // with the result rows .
330+ // with the results .
324331 PROFILE = 2 ;
325332 }
326333
@@ -329,12 +336,23 @@ message ExecuteSqlRequest {
329336
330337 // The transaction to use. If none is provided, the default is a
331338 // temporary read-only transaction with strong concurrency.
339+ //
340+ // The transaction to use.
341+ //
342+ // For queries, if none is provided, the default is a temporary read-only
343+ // transaction with strong concurrency.
344+ //
345+ // Standard DML statements require a ReadWrite transaction. Single-use
346+ // transactions are not supported (to avoid replay). The caller must
347+ // either supply an existing transaction ID or begin a new transaction.
348+ //
349+ // Partitioned DML requires an existing PartitionedDml transaction ID.
332350 TransactionSelector transaction = 2 ;
333351
334- // Required. The SQL query string.
352+ // Required. The SQL string.
335353 string sql = 3 ;
336354
337- // The SQL query string can contain parameter placeholders. A parameter
355+ // The SQL string can contain parameter placeholders. A parameter
338356 // placeholder consists of `'@'` followed by the parameter
339357 // name. Parameter names consist of any combination of letters,
340358 // numbers, and underscores.
@@ -343,7 +361,7 @@ message ExecuteSqlRequest {
343361 // parameter name can be used more than once, for example:
344362 // `"WHERE id > @msg_id AND id < @msg_id + 100"`
345363 //
346- // It is an error to execute an SQL query with unbound parameters.
364+ // It is an error to execute an SQL statement with unbound parameters.
347365 //
348366 // Parameter values are specified using `params`, which is a JSON
349367 // object whose keys are parameter names, and whose values are the
@@ -355,15 +373,15 @@ message ExecuteSqlRequest {
355373 // of type `STRING` both appear in [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings.
356374 //
357375 // In these cases, `param_types` can be used to specify the exact
358- // SQL type for some or all of the SQL query parameters. See the
376+ // SQL type for some or all of the SQL statement parameters. See the
359377 // definition of [Type][google.spanner.v1.Type] for more information
360378 // about SQL types.
361379 map <string , Type > param_types = 5 ;
362380
363- // If this request is resuming a previously interrupted SQL query
381+ // If this request is resuming a previously interrupted SQL statement
364382 // execution, `resume_token` should be copied from the last
365383 // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the interruption. Doing this
366- // enables the new SQL query execution to resume where the last one left
384+ // enables the new SQL statement execution to resume where the last one left
367385 // off. The rest of the request parameters must exactly match the
368386 // request that yielded this token.
369387 bytes resume_token = 6 ;
@@ -378,6 +396,18 @@ message ExecuteSqlRequest {
378396 // match for the values of fields common to this message and the
379397 // PartitionQueryRequest message used to create this partition_token.
380398 bytes partition_token = 8 ;
399+
400+ // A per-transaction sequence number used to identify this request. This
401+ // makes each request idempotent such that if the request is received multiple
402+ // times, at most one will succeed.
403+ //
404+ // The sequence number must be monotonically increasing within the
405+ // transaction. If a request arrives for the first time with an out-of-order
406+ // sequence number, the transaction may be aborted. Replays of previously
407+ // handled requests will yield the same response as the first execution.
408+ //
409+ // Required for DML statements. Ignored for queries.
410+ int64 seqno = 9 ;
381411}
382412
383413// Options for a PartitionQueryRequest and
@@ -417,6 +447,10 @@ message PartitionQueryRequest {
417447 // union operator conceptually divides one or more tables into multiple
418448 // splits, remotely evaluates a subquery independently on each split, and
419449 // then unions all results.
450+ //
451+ // This must not contain DML commands, such as INSERT, UPDATE, or
452+ // DELETE. Use [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a
453+ // PartitionedDml transaction for large, partition-friendly DML operations.
420454 string sql = 3 ;
421455
422456 // The SQL query string can contain parameter placeholders. A parameter
0 commit comments