@google-cloud/spanner 7.18.0 → 7.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -0
  3. package/build/protos/google/spanner/admin/database/v1/backup.proto +757 -0
  4. package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +230 -0
  5. package/build/protos/google/spanner/admin/database/v1/common.proto +132 -0
  6. package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +1209 -0
  7. package/build/protos/google/spanner/admin/instance/v1/common.proto +64 -0
  8. package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +2110 -0
  9. package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1520 -0
  10. package/build/protos/google/spanner/v1/commit_response.proto +59 -0
  11. package/build/protos/google/spanner/v1/keys.proto +163 -0
  12. package/build/protos/google/spanner/v1/mutation.proto +107 -0
  13. package/build/protos/google/spanner/v1/query_plan.proto +128 -0
  14. package/build/protos/google/spanner/v1/result_set.proto +237 -0
  15. package/build/protos/google/spanner/v1/spanner.proto +1389 -0
  16. package/build/protos/google/spanner/v1/transaction.proto +575 -0
  17. package/build/protos/google/spanner/v1/type.proto +214 -0
  18. package/build/protos/protos.d.ts +39317 -0
  19. package/build/protos/protos.js +100360 -0
  20. package/build/protos/protos.json +10271 -0
  21. package/build/src/backup.d.ts +349 -0
  22. package/build/src/backup.js +246 -0
  23. package/build/src/batch-transaction.d.ts +247 -0
  24. package/build/src/batch-transaction.js +384 -0
  25. package/build/src/codec.d.ts +362 -0
  26. package/build/src/codec.js +791 -0
  27. package/build/src/common-grpc/service-object.d.ts +80 -0
  28. package/build/src/common-grpc/service-object.js +101 -0
  29. package/build/src/common-grpc/service.d.ts +445 -0
  30. package/build/src/common-grpc/service.js +826 -0
  31. package/build/src/common.d.ts +66 -0
  32. package/build/src/common.js +54 -0
  33. package/build/src/database.d.ts +2103 -0
  34. package/build/src/database.js +1655 -0
  35. package/build/src/extra_proto_list.json +1 -0
  36. package/build/src/helper.d.ts +45 -0
  37. package/build/src/helper.js +71 -0
  38. package/build/src/index.d.ts +1195 -0
  39. package/build/src/index.js +1059 -0
  40. package/build/src/instance-config.d.ts +294 -0
  41. package/build/src/instance-config.js +216 -0
  42. package/build/src/instance.d.ts +832 -0
  43. package/build/src/instance.js +781 -0
  44. package/build/src/instrument.d.ts +85 -0
  45. package/build/src/instrument.js +215 -0
  46. package/build/src/multiplexed-session.d.ts +136 -0
  47. package/build/src/multiplexed-session.js +197 -0
  48. package/build/src/partial-result-stream.d.ts +253 -0
  49. package/build/src/partial-result-stream.js +400 -0
  50. package/build/src/session-factory.d.ts +100 -0
  51. package/build/src/session-factory.js +93 -0
  52. package/build/src/session-pool.d.ts +471 -0
  53. package/build/src/session-pool.js +754 -0
  54. package/build/src/session.d.ts +258 -0
  55. package/build/src/session.js +348 -0
  56. package/build/src/spanner_grpc_config.json +92 -0
  57. package/build/src/table.d.ts +831 -0
  58. package/build/src/table.js +277 -0
  59. package/build/src/transaction-runner.d.ts +185 -0
  60. package/build/src/transaction-runner.js +282 -0
  61. package/build/src/transaction.d.ts +1691 -0
  62. package/build/src/transaction.js +2004 -0
  63. package/build/src/v1/database_admin_client.d.ts +2301 -0
  64. package/build/src/v1/database_admin_client.js +2286 -0
  65. package/build/src/v1/database_admin_client_config.json +160 -0
  66. package/build/src/v1/database_admin_proto_list.json +6 -0
  67. package/build/src/v1/gapic_metadata.json +27 -0
  68. package/build/src/v1/index.d.ts +4 -0
  69. package/build/src/v1/index.js +29 -0
  70. package/build/src/v1/instance_admin_client.d.ts +1985 -0
  71. package/build/src/v1/instance_admin_client.js +1768 -0
  72. package/build/src/v1/instance_admin_client_config.json +129 -0
  73. package/build/src/v1/instance_admin_proto_list.json +4 -0
  74. package/build/src/v1/spanner_client.d.ts +1250 -0
  75. package/build/src/v1/spanner_client.js +1086 -0
  76. package/build/src/v1/spanner_client_config.json +119 -0
  77. package/build/src/v1/spanner_executor_proxy_client.d.ts +418 -0
  78. package/build/src/v1/spanner_executor_proxy_client.js +706 -0
  79. package/build/src/v1/spanner_executor_proxy_client_config.json +30 -0
  80. package/build/src/v1/spanner_executor_proxy_proto_list.json +14 -0
  81. package/build/src/v1/spanner_proto_list.json +10 -0
  82. package/package.json +1 -1
@@ -0,0 +1,575 @@
1
+ // Copyright 2024 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
+
15
+ syntax = "proto3";
16
+
17
+ package google.spanner.v1;
18
+
19
+ import "google/api/field_behavior.proto";
20
+ import "google/protobuf/duration.proto";
21
+ import "google/protobuf/timestamp.proto";
22
+
23
+ option csharp_namespace = "Google.Cloud.Spanner.V1";
24
+ option go_package = "cloud.google.com/go/spanner/apiv1/spannerpb;spannerpb";
25
+ option java_multiple_files = true;
26
+ option java_outer_classname = "TransactionProto";
27
+ option java_package = "com.google.spanner.v1";
28
+ option php_namespace = "Google\\Cloud\\Spanner\\V1";
29
+ option ruby_package = "Google::Cloud::Spanner::V1";
30
+
31
+ // Transactions:
32
+ //
33
+ // Each session can have at most one active transaction at a time (note that
34
+ // standalone reads and queries use a transaction internally and do count
35
+ // towards the one transaction limit). After the active transaction is
36
+ // completed, the session can immediately be re-used for the next transaction.
37
+ // It is not necessary to create a new session for each transaction.
38
+ //
39
+ // Transaction modes:
40
+ //
41
+ // Cloud Spanner supports three transaction modes:
42
+ //
43
+ // 1. Locking read-write. This type of transaction is the only way
44
+ // to write data into Cloud Spanner. These transactions rely on
45
+ // pessimistic locking and, if necessary, two-phase commit.
46
+ // Locking read-write transactions may abort, requiring the
47
+ // application to retry.
48
+ //
49
+ // 2. Snapshot read-only. Snapshot read-only transactions provide guaranteed
50
+ // consistency across several reads, but do not allow
51
+ // writes. Snapshot read-only transactions can be configured to read at
52
+ // timestamps in the past, or configured to perform a strong read
53
+ // (where Spanner will select a timestamp such that the read is
54
+ // guaranteed to see the effects of all transactions that have committed
55
+ // before the start of the read). Snapshot read-only transactions do not
56
+ // need to be committed.
57
+ //
58
+ // Queries on change streams must be performed with the snapshot read-only
59
+ // transaction mode, specifying a strong read. Please see
60
+ // [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong]
61
+ // for more details.
62
+ //
63
+ // 3. Partitioned DML. This type of transaction is used to execute
64
+ // a single Partitioned DML statement. Partitioned DML partitions
65
+ // the key space and runs the DML statement over each partition
66
+ // in parallel using separate, internal transactions that commit
67
+ // independently. Partitioned DML transactions do not need to be
68
+ // committed.
69
+ //
70
+ // For transactions that only read, snapshot read-only transactions
71
+ // provide simpler semantics and are almost always faster. In
72
+ // particular, read-only transactions do not take locks, so they do
73
+ // not conflict with read-write transactions. As a consequence of not
74
+ // taking locks, they also do not abort, so retry loops are not needed.
75
+ //
76
+ // Transactions may only read-write data in a single database. They
77
+ // may, however, read-write data in different tables within that
78
+ // database.
79
+ //
80
+ // Locking read-write transactions:
81
+ //
82
+ // Locking transactions may be used to atomically read-modify-write
83
+ // data anywhere in a database. This type of transaction is externally
84
+ // consistent.
85
+ //
86
+ // Clients should attempt to minimize the amount of time a transaction
87
+ // is active. Faster transactions commit with higher probability
88
+ // and cause less contention. Cloud Spanner attempts to keep read locks
89
+ // active as long as the transaction continues to do reads, and the
90
+ // transaction has not been terminated by
91
+ // [Commit][google.spanner.v1.Spanner.Commit] or
92
+ // [Rollback][google.spanner.v1.Spanner.Rollback]. Long periods of
93
+ // inactivity at the client may cause Cloud Spanner to release a
94
+ // transaction's locks and abort it.
95
+ //
96
+ // Conceptually, a read-write transaction consists of zero or more
97
+ // reads or SQL statements followed by
98
+ // [Commit][google.spanner.v1.Spanner.Commit]. At any time before
99
+ // [Commit][google.spanner.v1.Spanner.Commit], the client can send a
100
+ // [Rollback][google.spanner.v1.Spanner.Rollback] request to abort the
101
+ // transaction.
102
+ //
103
+ // Semantics:
104
+ //
105
+ // Cloud Spanner can commit the transaction if all read locks it acquired
106
+ // are still valid at commit time, and it is able to acquire write
107
+ // locks for all writes. Cloud Spanner can abort the transaction for any
108
+ // reason. If a commit attempt returns `ABORTED`, Cloud Spanner guarantees
109
+ // that the transaction has not modified any user data in Cloud Spanner.
110
+ //
111
+ // Unless the transaction commits, Cloud Spanner makes no guarantees about
112
+ // how long the transaction's locks were held for. It is an error to
113
+ // use Cloud Spanner locks for any sort of mutual exclusion other than
114
+ // between Cloud Spanner transactions themselves.
115
+ //
116
+ // Retrying aborted transactions:
117
+ //
118
+ // When a transaction aborts, the application can choose to retry the
119
+ // whole transaction again. To maximize the chances of successfully
120
+ // committing the retry, the client should execute the retry in the
121
+ // same session as the original attempt. The original session's lock
122
+ // priority increases with each consecutive abort, meaning that each
123
+ // attempt has a slightly better chance of success than the previous.
124
+ //
125
+ // Under some circumstances (for example, many transactions attempting to
126
+ // modify the same row(s)), a transaction can abort many times in a
127
+ // short period before successfully committing. Thus, it is not a good
128
+ // idea to cap the number of retries a transaction can attempt;
129
+ // instead, it is better to limit the total amount of time spent
130
+ // retrying.
131
+ //
132
+ // Idle transactions:
133
+ //
134
+ // A transaction is considered idle if it has no outstanding reads or
135
+ // SQL queries and has not started a read or SQL query within the last 10
136
+ // seconds. Idle transactions can be aborted by Cloud Spanner so that they
137
+ // don't hold on to locks indefinitely. If an idle transaction is aborted, the
138
+ // commit will fail with error `ABORTED`.
139
+ //
140
+ // If this behavior is undesirable, periodically executing a simple
141
+ // SQL query in the transaction (for example, `SELECT 1`) prevents the
142
+ // transaction from becoming idle.
143
+ //
144
+ // Snapshot read-only transactions:
145
+ //
146
+ // Snapshot read-only transactions provides a simpler method than
147
+ // locking read-write transactions for doing several consistent
148
+ // reads. However, this type of transaction does not support writes.
149
+ //
150
+ // Snapshot transactions do not take locks. Instead, they work by
151
+ // choosing a Cloud Spanner timestamp, then executing all reads at that
152
+ // timestamp. Since they do not acquire locks, they do not block
153
+ // concurrent read-write transactions.
154
+ //
155
+ // Unlike locking read-write transactions, snapshot read-only
156
+ // transactions never abort. They can fail if the chosen read
157
+ // timestamp is garbage collected; however, the default garbage
158
+ // collection policy is generous enough that most applications do not
159
+ // need to worry about this in practice.
160
+ //
161
+ // Snapshot read-only transactions do not need to call
162
+ // [Commit][google.spanner.v1.Spanner.Commit] or
163
+ // [Rollback][google.spanner.v1.Spanner.Rollback] (and in fact are not
164
+ // permitted to do so).
165
+ //
166
+ // To execute a snapshot transaction, the client specifies a timestamp
167
+ // bound, which tells Cloud Spanner how to choose a read timestamp.
168
+ //
169
+ // The types of timestamp bound are:
170
+ //
171
+ // - Strong (the default).
172
+ // - Bounded staleness.
173
+ // - Exact staleness.
174
+ //
175
+ // If the Cloud Spanner database to be read is geographically distributed,
176
+ // stale read-only transactions can execute more quickly than strong
177
+ // or read-write transactions, because they are able to execute far
178
+ // from the leader replica.
179
+ //
180
+ // Each type of timestamp bound is discussed in detail below.
181
+ //
182
+ // Strong: Strong reads are guaranteed to see the effects of all transactions
183
+ // that have committed before the start of the read. Furthermore, all
184
+ // rows yielded by a single read are consistent with each other -- if
185
+ // any part of the read observes a transaction, all parts of the read
186
+ // see the transaction.
187
+ //
188
+ // Strong reads are not repeatable: two consecutive strong read-only
189
+ // transactions might return inconsistent results if there are
190
+ // concurrent writes. If consistency across reads is required, the
191
+ // reads should be executed within a transaction or at an exact read
192
+ // timestamp.
193
+ //
194
+ // Queries on change streams (see below for more details) must also specify
195
+ // the strong read timestamp bound.
196
+ //
197
+ // See
198
+ // [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].
199
+ //
200
+ // Exact staleness:
201
+ //
202
+ // These timestamp bounds execute reads at a user-specified
203
+ // timestamp. Reads at a timestamp are guaranteed to see a consistent
204
+ // prefix of the global transaction history: they observe
205
+ // modifications done by all transactions with a commit timestamp less than or
206
+ // equal to the read timestamp, and observe none of the modifications done by
207
+ // transactions with a larger commit timestamp. They will block until
208
+ // all conflicting transactions that may be assigned commit timestamps
209
+ // <= the read timestamp have finished.
210
+ //
211
+ // The timestamp can either be expressed as an absolute Cloud Spanner commit
212
+ // timestamp or a staleness relative to the current time.
213
+ //
214
+ // These modes do not require a "negotiation phase" to pick a
215
+ // timestamp. As a result, they execute slightly faster than the
216
+ // equivalent boundedly stale concurrency modes. On the other hand,
217
+ // boundedly stale reads usually return fresher results.
218
+ //
219
+ // See
220
+ // [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp]
221
+ // and
222
+ // [TransactionOptions.ReadOnly.exact_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness].
223
+ //
224
+ // Bounded staleness:
225
+ //
226
+ // Bounded staleness modes allow Cloud Spanner to pick the read timestamp,
227
+ // subject to a user-provided staleness bound. Cloud Spanner chooses the
228
+ // newest timestamp within the staleness bound that allows execution
229
+ // of the reads at the closest available replica without blocking.
230
+ //
231
+ // All rows yielded are consistent with each other -- if any part of
232
+ // the read observes a transaction, all parts of the read see the
233
+ // transaction. Boundedly stale reads are not repeatable: two stale
234
+ // reads, even if they use the same staleness bound, can execute at
235
+ // different timestamps and thus return inconsistent results.
236
+ //
237
+ // Boundedly stale reads execute in two phases: the first phase
238
+ // negotiates a timestamp among all replicas needed to serve the
239
+ // read. In the second phase, reads are executed at the negotiated
240
+ // timestamp.
241
+ //
242
+ // As a result of the two phase execution, bounded staleness reads are
243
+ // usually a little slower than comparable exact staleness
244
+ // reads. However, they are typically able to return fresher
245
+ // results, and are more likely to execute at the closest replica.
246
+ //
247
+ // Because the timestamp negotiation requires up-front knowledge of
248
+ // which rows will be read, it can only be used with single-use
249
+ // read-only transactions.
250
+ //
251
+ // See
252
+ // [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness]
253
+ // and
254
+ // [TransactionOptions.ReadOnly.min_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp].
255
+ //
256
+ // Old read timestamps and garbage collection:
257
+ //
258
+ // Cloud Spanner continuously garbage collects deleted and overwritten data
259
+ // in the background to reclaim storage space. This process is known
260
+ // as "version GC". By default, version GC reclaims versions after they
261
+ // are one hour old. Because of this, Cloud Spanner cannot perform reads
262
+ // at read timestamps more than one hour in the past. This
263
+ // restriction also applies to in-progress reads and/or SQL queries whose
264
+ // timestamp become too old while executing. Reads and SQL queries with
265
+ // too-old read timestamps fail with the error `FAILED_PRECONDITION`.
266
+ //
267
+ // You can configure and extend the `VERSION_RETENTION_PERIOD` of a
268
+ // database up to a period as long as one week, which allows Cloud Spanner
269
+ // to perform reads up to one week in the past.
270
+ //
271
+ // Querying change Streams:
272
+ //
273
+ // A Change Stream is a schema object that can be configured to watch data
274
+ // changes on the entire database, a set of tables, or a set of columns
275
+ // in a database.
276
+ //
277
+ // When a change stream is created, Spanner automatically defines a
278
+ // corresponding SQL Table-Valued Function (TVF) that can be used to query
279
+ // the change records in the associated change stream using the
280
+ // ExecuteStreamingSql API. The name of the TVF for a change stream is
281
+ // generated from the name of the change stream: READ_<change_stream_name>.
282
+ //
283
+ // All queries on change stream TVFs must be executed using the
284
+ // ExecuteStreamingSql API with a single-use read-only transaction with a
285
+ // strong read-only timestamp_bound. The change stream TVF allows users to
286
+ // specify the start_timestamp and end_timestamp for the time range of
287
+ // interest. All change records within the retention period is accessible
288
+ // using the strong read-only timestamp_bound. All other TransactionOptions
289
+ // are invalid for change stream queries.
290
+ //
291
+ // In addition, if TransactionOptions.read_only.return_read_timestamp is set
292
+ // to true, a special value of 2^63 - 2 will be returned in the
293
+ // [Transaction][google.spanner.v1.Transaction] message that describes the
294
+ // transaction, instead of a valid read timestamp. This special value should be
295
+ // discarded and not used for any subsequent queries.
296
+ //
297
+ // Please see https://cloud.google.com/spanner/docs/change-streams
298
+ // for more details on how to query the change stream TVFs.
299
+ //
300
+ // Partitioned DML transactions:
301
+ //
302
+ // Partitioned DML transactions are used to execute DML statements with a
303
+ // different execution strategy that provides different, and often better,
304
+ // scalability properties for large, table-wide operations than DML in a
305
+ // ReadWrite transaction. Smaller scoped statements, such as an OLTP workload,
306
+ // should prefer using ReadWrite transactions.
307
+ //
308
+ // Partitioned DML partitions the keyspace and runs the DML statement on each
309
+ // partition in separate, internal transactions. These transactions commit
310
+ // automatically when complete, and run independently from one another.
311
+ //
312
+ // To reduce lock contention, this execution strategy only acquires read locks
313
+ // on rows that match the WHERE clause of the statement. Additionally, the
314
+ // smaller per-partition transactions hold locks for less time.
315
+ //
316
+ // That said, Partitioned DML is not a drop-in replacement for standard DML used
317
+ // in ReadWrite transactions.
318
+ //
319
+ // - The DML statement must be fully-partitionable. Specifically, the statement
320
+ // must be expressible as the union of many statements which each access only
321
+ // a single row of the table.
322
+ //
323
+ // - The statement is not applied atomically to all rows of the table. Rather,
324
+ // the statement is applied atomically to partitions of the table, in
325
+ // independent transactions. Secondary index rows are updated atomically
326
+ // with the base table rows.
327
+ //
328
+ // - Partitioned DML does not guarantee exactly-once execution semantics
329
+ // against a partition. The statement will be applied at least once to each
330
+ // partition. It is strongly recommended that the DML statement should be
331
+ // idempotent to avoid unexpected results. For instance, it is potentially
332
+ // dangerous to run a statement such as
333
+ // `UPDATE table SET column = column + 1` as it could be run multiple times
334
+ // against some rows.
335
+ //
336
+ // - The partitions are committed automatically - there is no support for
337
+ // Commit or Rollback. If the call returns an error, or if the client issuing
338
+ // the ExecuteSql call dies, it is possible that some rows had the statement
339
+ // executed on them successfully. It is also possible that statement was
340
+ // never executed against other rows.
341
+ //
342
+ // - Partitioned DML transactions may only contain the execution of a single
343
+ // DML statement via ExecuteSql or ExecuteStreamingSql.
344
+ //
345
+ // - If any error is encountered during the execution of the partitioned DML
346
+ // operation (for instance, a UNIQUE INDEX violation, division by zero, or a
347
+ // value that cannot be stored due to schema constraints), then the
348
+ // operation is stopped at that point and an error is returned. It is
349
+ // possible that at this point, some partitions have been committed (or even
350
+ // committed multiple times), and other partitions have not been run at all.
351
+ //
352
+ // Given the above, Partitioned DML is good fit for large, database-wide,
353
+ // operations that are idempotent, such as deleting old rows from a very large
354
+ // table.
355
+ message TransactionOptions {
356
+ // Message type to initiate a read-write transaction. Currently this
357
+ // transaction type has no options.
358
+ message ReadWrite {
359
+ // `ReadLockMode` is used to set the read lock mode for read-write
360
+ // transactions.
361
+ enum ReadLockMode {
362
+ // Default value.
363
+ //
364
+ // If the value is not specified, the pessimistic read lock is used.
365
+ READ_LOCK_MODE_UNSPECIFIED = 0;
366
+
367
+ // Pessimistic lock mode.
368
+ //
369
+ // Read locks are acquired immediately on read.
370
+ PESSIMISTIC = 1;
371
+
372
+ // Optimistic lock mode.
373
+ //
374
+ // Locks for reads within the transaction are not acquired on read.
375
+ // Instead the locks are acquired on a commit to validate that
376
+ // read/queried data has not changed since the transaction started.
377
+ OPTIMISTIC = 2;
378
+ }
379
+
380
+ // Read lock mode for the transaction.
381
+ ReadLockMode read_lock_mode = 1;
382
+
383
+ // Optional. Clients should pass the transaction ID of the previous
384
+ // transaction attempt that was aborted if this transaction is being
385
+ // executed on a multiplexed session.
386
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
387
+ // error.
388
+ bytes multiplexed_session_previous_transaction_id = 2
389
+ [(google.api.field_behavior) = OPTIONAL];
390
+ }
391
+
392
+ // Message type to initiate a Partitioned DML transaction.
393
+ message PartitionedDml {}
394
+
395
+ // Message type to initiate a read-only transaction.
396
+ message ReadOnly {
397
+ // How to choose the timestamp for the read-only transaction.
398
+ oneof timestamp_bound {
399
+ // Read at a timestamp where all previously committed transactions
400
+ // are visible.
401
+ bool strong = 1;
402
+
403
+ // Executes all reads at a timestamp >= `min_read_timestamp`.
404
+ //
405
+ // This is useful for requesting fresher data than some previous
406
+ // read, or data that is fresh enough to observe the effects of some
407
+ // previously committed transaction whose timestamp is known.
408
+ //
409
+ // Note that this option can only be used in single-use transactions.
410
+ //
411
+ // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
412
+ // Example: `"2014-10-02T15:01:23.045123456Z"`.
413
+ google.protobuf.Timestamp min_read_timestamp = 2;
414
+
415
+ // Read data at a timestamp >= `NOW - max_staleness`
416
+ // seconds. Guarantees that all writes that have committed more
417
+ // than the specified number of seconds ago are visible. Because
418
+ // Cloud Spanner chooses the exact timestamp, this mode works even if
419
+ // the client's local clock is substantially skewed from Cloud Spanner
420
+ // commit timestamps.
421
+ //
422
+ // Useful for reading the freshest data available at a nearby
423
+ // replica, while bounding the possible staleness if the local
424
+ // replica has fallen behind.
425
+ //
426
+ // Note that this option can only be used in single-use
427
+ // transactions.
428
+ google.protobuf.Duration max_staleness = 3;
429
+
430
+ // Executes all reads at the given timestamp. Unlike other modes,
431
+ // reads at a specific timestamp are repeatable; the same read at
432
+ // the same timestamp always returns the same data. If the
433
+ // timestamp is in the future, the read will block until the
434
+ // specified timestamp, modulo the read's deadline.
435
+ //
436
+ // Useful for large scale consistent reads such as mapreduces, or
437
+ // for coordinating many reads against a consistent snapshot of the
438
+ // data.
439
+ //
440
+ // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
441
+ // Example: `"2014-10-02T15:01:23.045123456Z"`.
442
+ google.protobuf.Timestamp read_timestamp = 4;
443
+
444
+ // Executes all reads at a timestamp that is `exact_staleness`
445
+ // old. The timestamp is chosen soon after the read is started.
446
+ //
447
+ // Guarantees that all writes that have committed more than the
448
+ // specified number of seconds ago are visible. Because Cloud Spanner
449
+ // chooses the exact timestamp, this mode works even if the client's
450
+ // local clock is substantially skewed from Cloud Spanner commit
451
+ // timestamps.
452
+ //
453
+ // Useful for reading at nearby replicas without the distributed
454
+ // timestamp negotiation overhead of `max_staleness`.
455
+ google.protobuf.Duration exact_staleness = 5;
456
+ }
457
+
458
+ // If true, the Cloud Spanner-selected read timestamp is included in
459
+ // the [Transaction][google.spanner.v1.Transaction] message that describes
460
+ // the transaction.
461
+ bool return_read_timestamp = 6;
462
+ }
463
+
464
+ // Required. The type of transaction.
465
+ oneof mode {
466
+ // Transaction may write.
467
+ //
468
+ // Authorization to begin a read-write transaction requires
469
+ // `spanner.databases.beginOrRollbackReadWriteTransaction` permission
470
+ // on the `session` resource.
471
+ ReadWrite read_write = 1;
472
+
473
+ // Partitioned DML transaction.
474
+ //
475
+ // Authorization to begin a Partitioned DML transaction requires
476
+ // `spanner.databases.beginPartitionedDmlTransaction` permission
477
+ // on the `session` resource.
478
+ PartitionedDml partitioned_dml = 3;
479
+
480
+ // Transaction will not write.
481
+ //
482
+ // Authorization to begin a read-only transaction requires
483
+ // `spanner.databases.beginReadOnlyTransaction` permission
484
+ // on the `session` resource.
485
+ ReadOnly read_only = 2;
486
+ }
487
+
488
+ // When `exclude_txn_from_change_streams` is set to `true`:
489
+ // * Mutations from this transaction will not be recorded in change streams
490
+ // with DDL option `allow_txn_exclusion=true` that are tracking columns
491
+ // modified by these transactions.
492
+ // * Mutations from this transaction will be recorded in change streams with
493
+ // DDL option `allow_txn_exclusion=false or not set` that are tracking
494
+ // columns modified by these transactions.
495
+ //
496
+ // When `exclude_txn_from_change_streams` is set to `false` or not set,
497
+ // mutations from this transaction will be recorded in all change streams that
498
+ // are tracking columns modified by these transactions.
499
+ // `exclude_txn_from_change_streams` may only be specified for read-write or
500
+ // partitioned-dml transactions, otherwise the API will return an
501
+ // `INVALID_ARGUMENT` error.
502
+ bool exclude_txn_from_change_streams = 5;
503
+ }
504
+
505
+ // A transaction.
506
+ message Transaction {
507
+ // `id` may be used to identify the transaction in subsequent
508
+ // [Read][google.spanner.v1.Spanner.Read],
509
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql],
510
+ // [Commit][google.spanner.v1.Spanner.Commit], or
511
+ // [Rollback][google.spanner.v1.Spanner.Rollback] calls.
512
+ //
513
+ // Single-use read-only transactions do not have IDs, because
514
+ // single-use transactions do not support multiple requests.
515
+ bytes id = 1;
516
+
517
+ // For snapshot read-only transactions, the read timestamp chosen
518
+ // for the transaction. Not returned by default: see
519
+ // [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp].
520
+ //
521
+ // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
522
+ // Example: `"2014-10-02T15:01:23.045123456Z"`.
523
+ google.protobuf.Timestamp read_timestamp = 2;
524
+
525
+ // A precommit token will be included in the response of a BeginTransaction
526
+ // request if the read-write transaction is on a multiplexed session and
527
+ // a mutation_key was specified in the
528
+ // [BeginTransaction][google.spanner.v1.BeginTransactionRequest].
529
+ // The precommit token with the highest sequence number from this transaction
530
+ // attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit]
531
+ // request for this transaction.
532
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
533
+ // error.
534
+ MultiplexedSessionPrecommitToken precommit_token = 3;
535
+ }
536
+
537
+ // This message is used to select the transaction in which a
538
+ // [Read][google.spanner.v1.Spanner.Read] or
539
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs.
540
+ //
541
+ // See [TransactionOptions][google.spanner.v1.TransactionOptions] for more
542
+ // information about transactions.
543
+ message TransactionSelector {
544
+ // If no fields are set, the default is a single use transaction
545
+ // with strong concurrency.
546
+ oneof selector {
547
+ // Execute the read or SQL query in a temporary transaction.
548
+ // This is the most efficient way to execute a transaction that
549
+ // consists of a single SQL query.
550
+ TransactionOptions single_use = 1;
551
+
552
+ // Execute the read or SQL query in a previously-started transaction.
553
+ bytes id = 2;
554
+
555
+ // Begin a new transaction and execute this read or SQL query in
556
+ // it. The transaction ID of the new transaction is returned in
557
+ // [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction],
558
+ // which is a [Transaction][google.spanner.v1.Transaction].
559
+ TransactionOptions begin = 3;
560
+ }
561
+ }
562
+
563
+ // When a read-write transaction is executed on a multiplexed session,
564
+ // this precommit token is sent back to the client
565
+ // as a part of the [Transaction] message in the BeginTransaction response and
566
+ // also as a part of the [ResultSet] and [PartialResultSet] responses.
567
+ message MultiplexedSessionPrecommitToken {
568
+ // Opaque precommit token.
569
+ bytes precommit_token = 1;
570
+
571
+ // An incrementing seq number is generated on every precommit token
572
+ // that is returned. Clients should remember the precommit token with the
573
+ // highest sequence number from the current transaction attempt.
574
+ int32 seq_num = 2;
575
+ }