diff --git a/README.md b/README.md index 798e51cec..2f55e5c9a 100644 --- a/README.md +++ b/README.md @@ -233,8 +233,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre | Queryoptions | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/queryoptions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/queryoptions.js,samples/README.md) | | Quickstart | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | | Read data with database role | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/read-data-with-database-role.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/read-data-with-database-role.js,samples/README.md) | -| Performs a read-write transaction with isolation level option | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/repeatable-reads.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/repeatable-reads.js,samples/README.md) | | Performs a read-write transaction with read lock mode option | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/read-lock-mode.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/read-lock-mode.js,samples/README.md) | +| Performs a read-write transaction with isolation level option | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/repeatable-reads.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/repeatable-reads.js,samples/README.md) | | Sets a request tag for a single query | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/request-tag.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/request-tag.js,samples/README.md) | | Run Batch update with RPC priority | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/rpc-priority-batch-dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/rpc-priority-batch-dml.js,samples/README.md) | | Run partitioned update with RPC priority | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/rpc-priority-partitioned-dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/rpc-priority-partitioned-dml.js,samples/README.md) | diff --git a/protos/google/spanner/v1/change_stream.proto b/protos/google/spanner/v1/change_stream.proto index 53c71078d..e7d12e608 100644 --- a/protos/google/spanner/v1/change_stream.proto +++ b/protos/google/spanner/v1/change_stream.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/protos/google/spanner/v1/commit_response.proto b/protos/google/spanner/v1/commit_response.proto index b29663501..6e4459122 100644 --- a/protos/google/spanner/v1/commit_response.proto +++ b/protos/google/spanner/v1/commit_response.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/protos/google/spanner/v1/keys.proto b/protos/google/spanner/v1/keys.proto index bce2a07b0..5e30e831e 100644 --- a/protos/google/spanner/v1/keys.proto +++ b/protos/google/spanner/v1/keys.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/protos/google/spanner/v1/location.proto b/protos/google/spanner/v1/location.proto index a3b27aa4b..870dc0ec0 100644 --- a/protos/google/spanner/v1/location.proto +++ b/protos/google/spanner/v1/location.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/protos/google/spanner/v1/mutation.proto b/protos/google/spanner/v1/mutation.proto index 99641cea9..7e3306a20 100644 --- a/protos/google/spanner/v1/mutation.proto +++ b/protos/google/spanner/v1/mutation.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/protos/google/spanner/v1/query_plan.proto b/protos/google/spanner/v1/query_plan.proto index 8e8e587b0..5850ff97f 100644 --- a/protos/google/spanner/v1/query_plan.proto +++ b/protos/google/spanner/v1/query_plan.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/protos/google/spanner/v1/result_set.proto b/protos/google/spanner/v1/result_set.proto index 4d446709b..3851d688c 100644 --- a/protos/google/spanner/v1/result_set.proto +++ b/protos/google/spanner/v1/result_set.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -61,6 +61,14 @@ message ResultSet { // [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. MultiplexedSessionPrecommitToken precommit_token = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A cache update expresses a set of changes the client should + // incorporate into its location cache. The client should discard the changes + // if they are older than the data it already has. This data can be obtained + // in response to requests that included a `RoutingHint` field, but may also + // be obtained by explicit location-fetching RPCs which may be added in the + // future. + CacheUpdate cache_update = 6 [(google.api.field_behavior) = OPTIONAL]; } // Partial results from a streaming read or SQL query. Streaming reads and diff --git a/protos/google/spanner/v1/spanner.proto b/protos/google/spanner/v1/spanner.proto index 91456ebb5..525cc2ba4 100644 --- a/protos/google/spanner/v1/spanner.proto +++ b/protos/google/spanner/v1/spanner.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -544,8 +544,9 @@ message RequestOptions { // A tag used for statistics collection about this transaction. // Both `request_tag` and `transaction_tag` can be specified for a read or // query that belongs to a transaction. - // The value of transaction_tag should be the same for all requests belonging - // to the same transaction. + // To enable tagging on a transaction, `transaction_tag` must be set to the + // same value for all requests belonging to the same transaction, including + // [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction]. // If this request doesn't belong to any transaction, `transaction_tag` is // ignored. // Legal characters for `transaction_tag` values are all printable characters @@ -1018,7 +1019,8 @@ message PartitionQueryRequest { // operations. string sql = 3 [(google.api.field_behavior) = REQUIRED]; - // Parameter names and values that bind to placeholders in the SQL string. + // Optional. Parameter names and values that bind to placeholders in the SQL + // string. // // A parameter placeholder consists of the `@` character followed by the // parameter name (for example, `@firstName`). Parameter names can contain @@ -1030,18 +1032,18 @@ message PartitionQueryRequest { // `"WHERE id > @msg_id AND id < @msg_id + 100"` // // It's an error to execute a SQL statement with unbound parameters. - google.protobuf.Struct params = 4; + google.protobuf.Struct params = 4 [(google.api.field_behavior) = OPTIONAL]; - // It isn't always possible for Cloud Spanner to infer the right SQL type - // from a JSON value. For example, values of type `BYTES` and values - // of type `STRING` both appear in + // Optional. It isn't always possible for Cloud Spanner to infer the right SQL + // type from a JSON value. For example, values of type `BYTES` and values of + // type `STRING` both appear in // [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings. // // In these cases, `param_types` can be used to specify the exact // SQL type for some or all of the SQL query parameters. See the // definition of [Type][google.spanner.v1.Type] for more information // about SQL types. - map param_types = 5; + map param_types = 5 [(google.api.field_behavior) = OPTIONAL]; // Additional options that affect how many partitions are created. PartitionOptions partition_options = 6; @@ -1407,6 +1409,11 @@ message BatchWriteResponse { google.rpc.Status status = 2; // The commit timestamp of the transaction that applied this batch. - // Present if `status` is `OK`, absent otherwise. + // Present if status is OK and the mutation groups were applied, absent + // otherwise. + // + // For mutation groups with conditions, a status=OK and missing + // commit_timestamp means that the mutation groups were not applied due to the + // condition not being satisfied after evaluation. google.protobuf.Timestamp commit_timestamp = 3; } diff --git a/protos/google/spanner/v1/transaction.proto b/protos/google/spanner/v1/transaction.proto index 4d2a54202..dfdf3b11a 100644 --- a/protos/google/spanner/v1/transaction.proto +++ b/protos/google/spanner/v1/transaction.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/protos/google/spanner/v1/type.proto b/protos/google/spanner/v1/type.proto index 3e01729fc..e3e85a770 100644 --- a/protos/google/spanner/v1/type.proto +++ b/protos/google/spanner/v1/type.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 103c6a802..4e4a305d0 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -36293,6 +36293,9 @@ export namespace google { /** ResultSet precommitToken */ precommitToken?: (google.spanner.v1.IMultiplexedSessionPrecommitToken|null); + + /** ResultSet cacheUpdate */ + cacheUpdate?: (google.spanner.v1.ICacheUpdate|null); } /** Represents a ResultSet. */ @@ -36316,6 +36319,9 @@ export namespace google { /** ResultSet precommitToken. */ public precommitToken?: (google.spanner.v1.IMultiplexedSessionPrecommitToken|null); + /** ResultSet cacheUpdate. */ + public cacheUpdate?: (google.spanner.v1.ICacheUpdate|null); + /** * Creates a new ResultSet instance using the specified properties. * @param [properties] Properties to set diff --git a/protos/protos.js b/protos/protos.js index fb25c835b..5d953ab1b 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -94419,6 +94419,7 @@ * @property {Array.|null} [rows] ResultSet rows * @property {google.spanner.v1.IResultSetStats|null} [stats] ResultSet stats * @property {google.spanner.v1.IMultiplexedSessionPrecommitToken|null} [precommitToken] ResultSet precommitToken + * @property {google.spanner.v1.ICacheUpdate|null} [cacheUpdate] ResultSet cacheUpdate */ /** @@ -94469,6 +94470,14 @@ */ ResultSet.prototype.precommitToken = null; + /** + * ResultSet cacheUpdate. + * @member {google.spanner.v1.ICacheUpdate|null|undefined} cacheUpdate + * @memberof google.spanner.v1.ResultSet + * @instance + */ + ResultSet.prototype.cacheUpdate = null; + /** * Creates a new ResultSet instance using the specified properties. * @function create @@ -94502,6 +94511,8 @@ $root.google.spanner.v1.ResultSetStats.encode(message.stats, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.precommitToken != null && Object.hasOwnProperty.call(message, "precommitToken")) $root.google.spanner.v1.MultiplexedSessionPrecommitToken.encode(message.precommitToken, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.cacheUpdate != null && Object.hasOwnProperty.call(message, "cacheUpdate")) + $root.google.spanner.v1.CacheUpdate.encode(message.cacheUpdate, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); return writer; }; @@ -94556,6 +94567,10 @@ message.precommitToken = $root.google.spanner.v1.MultiplexedSessionPrecommitToken.decode(reader, reader.uint32()); break; } + case 6: { + message.cacheUpdate = $root.google.spanner.v1.CacheUpdate.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -94615,6 +94630,11 @@ if (error) return "precommitToken." + error; } + if (message.cacheUpdate != null && message.hasOwnProperty("cacheUpdate")) { + var error = $root.google.spanner.v1.CacheUpdate.verify(message.cacheUpdate); + if (error) + return "cacheUpdate." + error; + } return null; }; @@ -94655,6 +94675,11 @@ throw TypeError(".google.spanner.v1.ResultSet.precommitToken: object expected"); message.precommitToken = $root.google.spanner.v1.MultiplexedSessionPrecommitToken.fromObject(object.precommitToken); } + if (object.cacheUpdate != null) { + if (typeof object.cacheUpdate !== "object") + throw TypeError(".google.spanner.v1.ResultSet.cacheUpdate: object expected"); + message.cacheUpdate = $root.google.spanner.v1.CacheUpdate.fromObject(object.cacheUpdate); + } return message; }; @@ -94677,6 +94702,7 @@ object.metadata = null; object.stats = null; object.precommitToken = null; + object.cacheUpdate = null; } if (message.metadata != null && message.hasOwnProperty("metadata")) object.metadata = $root.google.spanner.v1.ResultSetMetadata.toObject(message.metadata, options); @@ -94689,6 +94715,8 @@ object.stats = $root.google.spanner.v1.ResultSetStats.toObject(message.stats, options); if (message.precommitToken != null && message.hasOwnProperty("precommitToken")) object.precommitToken = $root.google.spanner.v1.MultiplexedSessionPrecommitToken.toObject(message.precommitToken, options); + if (message.cacheUpdate != null && message.hasOwnProperty("cacheUpdate")) + object.cacheUpdate = $root.google.spanner.v1.CacheUpdate.toObject(message.cacheUpdate, options); return object; }; diff --git a/protos/protos.json b/protos/protos.json index 6d612dffc..9576bee24 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -8743,12 +8743,18 @@ }, "params": { "type": "google.protobuf.Struct", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "paramTypes": { "keyType": "string", "type": "Type", - "id": 5 + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "partitionOptions": { "type": "PartitionOptions", @@ -9848,6 +9854,13 @@ "options": { "(google.api.field_behavior)": "OPTIONAL" } + }, + "cacheUpdate": { + "type": "CacheUpdate", + "id": 6, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, diff --git a/samples/README.md b/samples/README.md index c37709bf0..03b68647e 100644 --- a/samples/README.md +++ b/samples/README.md @@ -116,8 +116,8 @@ and automatic, synchronous replication for high availability. * [Queryoptions](#queryoptions) * [Quickstart](#quickstart) * [Read data with database role](#read-data-with-database-role) - * [Performs a read-write transaction with isolation level option](#performs-a-read-write-transaction-with-isolation-level-option) * [Performs a read-write transaction with read lock mode option](#performs-a-read-write-transaction-with-read-lock-mode-option) + * [Performs a read-write transaction with isolation level option](#performs-a-read-write-transaction-with-isolation-level-option) * [Sets a request tag for a single query](#sets-a-request-tag-for-a-single-query) * [Run Batch update with RPC priority](#run-batch-update-with-rpc-priority) * [Run partitioned update with RPC priority](#run-partitioned-update-with-rpc-priority) @@ -1890,16 +1890,16 @@ __Usage:__ -### Performs a read-write transaction with isolation level option +### Performs a read-write transaction with read lock mode option -View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/repeatable-reads.js). +View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/read-lock-mode.js). -[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/repeatable-reads.js,samples/README.md) +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/read-lock-mode.js,samples/README.md) __Usage:__ -`node repeatable-reads.js ` +`node read-lock-mode.js ` ----- @@ -1907,15 +1907,17 @@ __Usage:__ -### Performs a read-write transaction with read lock mode option +### Performs a read-write transaction with isolation level option -View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/read-lock-mode.js). +View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/repeatable-reads.js). -[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/read-lock-mode.js,samples/README.md) +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/repeatable-reads.js,samples/README.md) __Usage:__ -`node read-lock-mode.js ` + +`node repeatable-reads.js ` + ----- diff --git a/src/v1/spanner_client.ts b/src/v1/spanner_client.ts index 82ef9eb3e..07a538fbd 100644 --- a/src/v1/spanner_client.ts +++ b/src/v1/spanner_client.ts @@ -2056,8 +2056,9 @@ export class SpannerClient { * {@link protos.google.spanner.v1.Spanner.ExecuteStreamingSql|`ExecuteStreamingSql`} with * a `PartitionedDml` transaction for large, partition-friendly DML * operations. - * @param {google.protobuf.Struct} request.params - * Parameter names and values that bind to placeholders in the SQL string. + * @param {google.protobuf.Struct} [request.params] + * Optional. Parameter names and values that bind to placeholders in the SQL + * string. * * A parameter placeholder consists of the `@` character followed by the * parameter name (for example, `@firstName`). Parameter names can contain @@ -2069,10 +2070,10 @@ export class SpannerClient { * `"WHERE id > @msg_id AND id < @msg_id + 100"` * * It's an error to execute a SQL statement with unbound parameters. - * @param {number[]} request.paramTypes - * It isn't always possible for Cloud Spanner to infer the right SQL type - * from a JSON value. For example, values of type `BYTES` and values - * of type `STRING` both appear in + * @param {number[]} [request.paramTypes] + * Optional. It isn't always possible for Cloud Spanner to infer the right SQL + * type from a JSON value. For example, values of type `BYTES` and values of + * type `STRING` both appear in * {@link protos.google.spanner.v1.PartitionQueryRequest.params|params} as JSON strings. * * In these cases, `param_types` can be used to specify the exact