@google-cloud/spanner 7.15.0 → 7.17.0

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 (38) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +2 -0
  3. package/build/protos/google/spanner/admin/instance/v1/common.proto +7 -0
  4. package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +139 -16
  5. package/build/protos/google/spanner/v1/commit_response.proto +9 -0
  6. package/build/protos/google/spanner/v1/result_set.proto +21 -0
  7. package/build/protos/google/spanner/v1/spanner.proto +61 -2
  8. package/build/protos/google/spanner/v1/transaction.proto +34 -0
  9. package/build/protos/google/spanner/v1/type.proto +43 -30
  10. package/build/protos/protos.d.ts +1724 -1112
  11. package/build/protos/protos.js +5185 -3528
  12. package/build/protos/protos.json +321 -129
  13. package/build/src/common.d.ts +8 -0
  14. package/build/src/common.js +19 -1
  15. package/build/src/database.d.ts +8 -1
  16. package/build/src/database.js +63 -56
  17. package/build/src/helper.d.ts +45 -0
  18. package/build/src/helper.js +71 -0
  19. package/build/src/index.d.ts +1 -1
  20. package/build/src/index.js +18 -11
  21. package/build/src/instance-config.d.ts +1 -0
  22. package/build/src/instance.d.ts +2 -1
  23. package/build/src/instance.js +12 -13
  24. package/build/src/instrument.d.ts +3 -0
  25. package/build/src/instrument.js +5 -1
  26. package/build/src/multiplexed-session.d.ts +136 -0
  27. package/build/src/multiplexed-session.js +197 -0
  28. package/build/src/session-factory.d.ts +101 -0
  29. package/build/src/session-factory.js +93 -0
  30. package/build/src/session-pool.d.ts +1 -39
  31. package/build/src/session-pool.js +6 -58
  32. package/build/src/session.d.ts +2 -1
  33. package/build/src/session.js +5 -6
  34. package/build/src/transaction.d.ts +1 -1
  35. package/build/src/transaction.js +8 -9
  36. package/build/src/v1/spanner_client.d.ts +44 -0
  37. package/build/src/v1/spanner_client.js +10 -0
  38. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/nodejs-spanner?activeTab=versions
6
6
 
7
+ ## [7.17.0](https://github.com/googleapis/nodejs-spanner/compare/v7.16.0...v7.17.0) (2024-12-27)
8
+
9
+
10
+ ### Features
11
+
12
+ * Add the last statement option to ExecuteSqlRequest and ExecuteBatchDmlRequest ([#2196](https://github.com/googleapis/nodejs-spanner/issues/2196)) ([223f167](https://github.com/googleapis/nodejs-spanner/commit/223f167c1c9bc4da26155637eabbcabce5487ede))
13
+ * Enable e2e tracing ([#2202](https://github.com/googleapis/nodejs-spanner/issues/2202)) ([3cc257e](https://github.com/googleapis/nodejs-spanner/commit/3cc257e99925594776b9a1886f0173ce2dfe904f))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * Span events Issue 2166 ([#2184](https://github.com/googleapis/nodejs-spanner/issues/2184)) ([97ed577](https://github.com/googleapis/nodejs-spanner/commit/97ed5776dbdf5e90f8398fffea08e2a968045f9b))
19
+
20
+ ## [7.16.0](https://github.com/googleapis/nodejs-spanner/compare/v7.15.0...v7.16.0) (2024-11-09)
21
+
22
+
23
+ ### Features
24
+
25
+ * **spanner:** Add support for Cloud Spanner Default Backup Schedules ([#2135](https://github.com/googleapis/nodejs-spanner/issues/2135)) ([19f137c](https://github.com/googleapis/nodejs-spanner/commit/19f137c870796d60902be8d9d3a82f4abcfc693f))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **deps:** Update dependency google-gax to v4.4.1 ([#2100](https://github.com/googleapis/nodejs-spanner/issues/2100)) ([2e94bcd](https://github.com/googleapis/nodejs-spanner/commit/2e94bcd06d99a98c7767281e8035d000e186692b))
31
+
7
32
  ## [7.15.0](https://github.com/googleapis/nodejs-spanner/compare/v7.14.0...v7.15.0) (2024-10-30)
8
33
 
9
34
 
package/README.md CHANGED
@@ -109,6 +109,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
109
109
  | Batch | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/batch.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/batch.js,samples/README.md) |
110
110
  | Creates a full backup schedule | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/create-full-backup-schedule.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/create-full-backup-schedule.js,samples/README.md) |
111
111
  | Creates an incremental backup schedule | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/create-incremental-backup-schedule.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/create-incremental-backup-schedule.js,samples/README.md) |
112
+ | Create-instance-without-default-backup-schedules | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/create-instance-without-default-backup-schedules.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/create-instance-without-default-backup-schedules.js,samples/README.md) |
112
113
  | CRUD | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/crud.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/crud.js,samples/README.md) |
113
114
  | Creates a new database with a specific default leader | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-create-with-default-leader.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/database-create-with-default-leader.js,samples/README.md) |
114
115
  | Database-create-with-encryption-key | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-create-with-encryption-key.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/database-create-with-encryption-key.js,samples/README.md) |
@@ -206,6 +207,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
206
207
  | Executes a read/write transaction with transaction and request tags | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/transaction-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/transaction-tag.js,samples/README.md) |
207
208
  | Transaction | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/transaction.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/transaction.js,samples/README.md) |
208
209
  | Updates a backup schedule | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/update-backup-schedule.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/update-backup-schedule.js,samples/README.md) |
210
+ | Updates an instance. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/update-instance-default-backup-schedule-type.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/update-instance-default-backup-schedule-type.js,samples/README.md) |
209
211
 
210
212
 
211
213
 
@@ -16,6 +16,7 @@ syntax = "proto3";
16
16
 
17
17
  package google.spanner.admin.instance.v1;
18
18
 
19
+ import "google/api/field_behavior.proto";
19
20
  import "google/protobuf/timestamp.proto";
20
21
 
21
22
  option csharp_namespace = "Google.Cloud.Spanner.Admin.Instance.V1";
@@ -54,3 +55,9 @@ enum FulfillmentPeriod {
54
55
  // to complete.
55
56
  FULFILLMENT_PERIOD_EXTENDED = 2;
56
57
  }
58
+
59
+ // ReplicaSelection identifies replicas with common properties.
60
+ message ReplicaSelection {
61
+ // Required. Name of the location of the replicas (e.g., "us-central1").
62
+ string location = 1 [(google.api.field_behavior) = REQUIRED];
63
+ }
@@ -803,6 +803,34 @@ message InstanceConfig {
803
803
  State state = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
804
804
  }
805
805
 
806
+ // ReplicaComputeCapacity describes the amount of server resources that are
807
+ // allocated to each replica identified by the replica selection.
808
+ message ReplicaComputeCapacity {
809
+ // Required. Identifies replicas by specified properties.
810
+ // All replicas in the selection have the same amount of compute capacity.
811
+ ReplicaSelection replica_selection = 1
812
+ [(google.api.field_behavior) = REQUIRED];
813
+
814
+ // Compute capacity allocated to each replica identified by the specified
815
+ // selection.
816
+ // The unit is selected based on the unit used to specify the instance size
817
+ // for non-autoscaling instances, or the unit used in autoscaling limit for
818
+ // autoscaling instances.
819
+ oneof compute_capacity {
820
+ // The number of nodes allocated to each replica.
821
+ //
822
+ // This may be zero in API responses for instances that are not yet in
823
+ // state `READY`.
824
+ int32 node_count = 2;
825
+
826
+ // The number of processing units allocated to each replica.
827
+ //
828
+ // This may be zero in API responses for instances that are not yet in
829
+ // state `READY`.
830
+ int32 processing_units = 3;
831
+ }
832
+ }
833
+
806
834
  // Autoscaling configuration for an instance.
807
835
  message AutoscalingConfig {
808
836
  // The autoscaling limits for the instance. Users can define the minimum and
@@ -854,6 +882,37 @@ message AutoscalingConfig {
854
882
  [(google.api.field_behavior) = REQUIRED];
855
883
  }
856
884
 
885
+ // AsymmetricAutoscalingOption specifies the scaling of replicas identified by
886
+ // the given selection.
887
+ message AsymmetricAutoscalingOption {
888
+ // Overrides the top-level autoscaling configuration for the replicas
889
+ // identified by `replica_selection`. All fields in this message are
890
+ // optional. Any unspecified fields will use the corresponding values from
891
+ // the top-level autoscaling configuration.
892
+ message AutoscalingConfigOverrides {
893
+ // Optional. If specified, overrides the min/max limit in the top-level
894
+ // autoscaling configuration for the selected replicas.
895
+ AutoscalingLimits autoscaling_limits = 1
896
+ [(google.api.field_behavior) = OPTIONAL];
897
+
898
+ // Optional. If specified, overrides the autoscaling target
899
+ // high_priority_cpu_utilization_percent in the top-level autoscaling
900
+ // configuration for the selected replicas.
901
+ int32 autoscaling_target_high_priority_cpu_utilization_percent = 2
902
+ [(google.api.field_behavior) = OPTIONAL];
903
+ }
904
+
905
+ // Required. Selects the replicas to which this AsymmetricAutoscalingOption
906
+ // applies. Only read-only replicas are supported.
907
+ ReplicaSelection replica_selection = 1
908
+ [(google.api.field_behavior) = REQUIRED];
909
+
910
+ // Optional. Overrides applied to the top-level autoscaling configuration
911
+ // for the selected replicas.
912
+ AutoscalingConfigOverrides overrides = 2
913
+ [(google.api.field_behavior) = OPTIONAL];
914
+ }
915
+
857
916
  // Required. Autoscaling limits for an instance.
858
917
  AutoscalingLimits autoscaling_limits = 1
859
918
  [(google.api.field_behavior) = REQUIRED];
@@ -861,6 +920,18 @@ message AutoscalingConfig {
861
920
  // Required. The autoscaling targets for an instance.
862
921
  AutoscalingTargets autoscaling_targets = 2
863
922
  [(google.api.field_behavior) = REQUIRED];
923
+
924
+ // Optional. Optional asymmetric autoscaling options.
925
+ // Replicas matching the replica selection criteria will be autoscaled
926
+ // independently from other replicas. The autoscaler will scale the replicas
927
+ // based on the utilization of replicas identified by the replica selection.
928
+ // Replica selections should not overlap with each other.
929
+ //
930
+ // Other replicas (those do not match any replica selection) will be
931
+ // autoscaled together and will have the same compute capacity allocated to
932
+ // them.
933
+ repeated AsymmetricAutoscalingOption asymmetric_autoscaling_options = 3
934
+ [(google.api.field_behavior) = OPTIONAL];
864
935
  }
865
936
 
866
937
  // An isolated set of Cloud Spanner resources on which databases can be hosted.
@@ -901,6 +972,24 @@ message Instance {
901
972
  ENTERPRISE_PLUS = 3;
902
973
  }
903
974
 
975
+ // Indicates the default backup behavior for new databases within the
976
+ // instance.
977
+ enum DefaultBackupScheduleType {
978
+ // Not specified.
979
+ DEFAULT_BACKUP_SCHEDULE_TYPE_UNSPECIFIED = 0;
980
+
981
+ // No default backup schedule will be created automatically on creation of a
982
+ // database within the instance.
983
+ NONE = 1;
984
+
985
+ // A default backup schedule will be created automatically on creation of a
986
+ // database within the instance. The default backup schedule creates a full
987
+ // backup every 24 hours and retains the backup for a period of 7 days. Once
988
+ // created, the default backup schedule can be edited/deleted similar to any
989
+ // other backup schedule.
990
+ AUTOMATIC = 2;
991
+ }
992
+
904
993
  // Required. A unique identifier for the instance, which cannot be changed
905
994
  // after the instance is created. Values are of the form
906
995
  // `projects/<project>/instances/[a-z][-a-z0-9]*[a-z0-9]`. The final
@@ -922,34 +1011,56 @@ message Instance {
922
1011
  // Must be unique per project and between 4 and 30 characters in length.
923
1012
  string display_name = 3 [(google.api.field_behavior) = REQUIRED];
924
1013
 
925
- // The number of nodes allocated to this instance. At most one of either
926
- // node_count or processing_units should be present in the message.
1014
+ // The number of nodes allocated to this instance. At most, one of either
1015
+ // `node_count` or `processing_units` should be present in the message.
927
1016
  //
928
- // Users can set the node_count field to specify the target number of nodes
1017
+ // Users can set the `node_count` field to specify the target number of nodes
929
1018
  // allocated to the instance.
930
1019
  //
931
- // This may be zero in API responses for instances that are not yet in state
932
- // `READY`.
1020
+ // If autoscaling is enabled, `node_count` is treated as an `OUTPUT_ONLY`
1021
+ // field and reflects the current number of nodes allocated to the instance.
933
1022
  //
934
- // See [the
935
- // documentation](https://cloud.google.com/spanner/docs/compute-capacity)
936
- // for more information about nodes and processing units.
1023
+ // This might be zero in API responses for instances that are not yet in the
1024
+ // `READY` state.
1025
+ //
1026
+ // If the instance has varying node count across replicas (achieved by
1027
+ // setting asymmetric_autoscaling_options in autoscaling config), the
1028
+ // node_count here is the maximum node count across all replicas.
1029
+ //
1030
+ // For more information, see
1031
+ // [Compute capacity, nodes, and processing
1032
+ // units](https://cloud.google.com/spanner/docs/compute-capacity).
937
1033
  int32 node_count = 5;
938
1034
 
939
- // The number of processing units allocated to this instance. At most one of
940
- // processing_units or node_count should be present in the message.
1035
+ // The number of processing units allocated to this instance. At most, one of
1036
+ // either `processing_units` or `node_count` should be present in the message.
941
1037
  //
942
- // Users can set the processing_units field to specify the target number of
1038
+ // Users can set the `processing_units` field to specify the target number of
943
1039
  // processing units allocated to the instance.
944
1040
  //
945
- // This may be zero in API responses for instances that are not yet in state
946
- // `READY`.
1041
+ // If autoscaling is enabled, `processing_units` is treated as an
1042
+ // `OUTPUT_ONLY` field and reflects the current number of processing units
1043
+ // allocated to the instance.
947
1044
  //
948
- // See [the
949
- // documentation](https://cloud.google.com/spanner/docs/compute-capacity)
950
- // for more information about nodes and processing units.
1045
+ // This might be zero in API responses for instances that are not yet in the
1046
+ // `READY` state.
1047
+ //
1048
+ // If the instance has varying processing units per replica
1049
+ // (achieved by setting asymmetric_autoscaling_options in autoscaling config),
1050
+ // the processing_units here is the maximum processing units across all
1051
+ // replicas.
1052
+ //
1053
+ // For more information, see
1054
+ // [Compute capacity, nodes and processing
1055
+ // units](https://cloud.google.com/spanner/docs/compute-capacity).
951
1056
  int32 processing_units = 9;
952
1057
 
1058
+ // Output only. Lists the compute capacity per ReplicaSelection. A replica
1059
+ // selection identifies a set of replicas with common properties. Replicas
1060
+ // identified by a ReplicaSelection are scaled with the same compute capacity.
1061
+ repeated ReplicaComputeCapacity replica_compute_capacity = 19
1062
+ [(google.api.field_behavior) = OUTPUT_ONLY];
1063
+
953
1064
  // Optional. The autoscaling configuration. Autoscaling is enabled if this
954
1065
  // field is set. When autoscaling is enabled, node_count and processing_units
955
1066
  // are treated as OUTPUT_ONLY fields and reflect the current compute capacity
@@ -1000,6 +1111,18 @@ message Instance {
1000
1111
 
1001
1112
  // Optional. The `Edition` of the current instance.
1002
1113
  Edition edition = 20 [(google.api.field_behavior) = OPTIONAL];
1114
+
1115
+ // Optional. Controls the default backup behavior for new databases within the
1116
+ // instance.
1117
+ //
1118
+ // Note that `AUTOMATIC` is not permitted for free instances, as backups and
1119
+ // backup schedules are not allowed for free instances.
1120
+ //
1121
+ // In the `GetInstance` or `ListInstances` response, if the value of
1122
+ // default_backup_schedule_type is unset or NONE, no default backup
1123
+ // schedule will be created for new databases within the instance.
1124
+ DefaultBackupScheduleType default_backup_schedule_type = 23
1125
+ [(google.api.field_behavior) = OPTIONAL];
1003
1126
  }
1004
1127
 
1005
1128
  // The request for
@@ -17,6 +17,7 @@ syntax = "proto3";
17
17
  package google.spanner.v1;
18
18
 
19
19
  import "google/protobuf/timestamp.proto";
20
+ import "google/spanner/v1/transaction.proto";
20
21
 
21
22
  option csharp_namespace = "Google.Cloud.Spanner.V1";
22
23
  option go_package = "cloud.google.com/go/spanner/apiv1/spannerpb;spannerpb";
@@ -47,4 +48,12 @@ message CommitResponse {
47
48
  // For more information, see
48
49
  // [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats].
49
50
  CommitStats commit_stats = 2;
51
+
52
+ // Clients should examine and retry the commit if any of the following
53
+ // reasons are populated.
54
+ oneof MultiplexedSessionRetry {
55
+ // If specified, transaction has not committed yet.
56
+ // Clients must retry the commit with the new precommit token.
57
+ MultiplexedSessionPrecommitToken precommit_token = 4;
58
+ }
50
59
  }
@@ -16,6 +16,7 @@ syntax = "proto3";
16
16
 
17
17
  package google.spanner.v1;
18
18
 
19
+ import "google/api/field_behavior.proto";
19
20
  import "google/protobuf/struct.proto";
20
21
  import "google/spanner/v1/query_plan.proto";
21
22
  import "google/spanner/v1/transaction.proto";
@@ -53,6 +54,16 @@ message ResultSet {
53
54
  // Other fields may or may not be populated, based on the
54
55
  // [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
55
56
  ResultSetStats stats = 3;
57
+
58
+ // Optional. A precommit token will be included if the read-write transaction
59
+ // is on a multiplexed session.
60
+ // The precommit token with the highest sequence number from this transaction
61
+ // attempt should be passed to the
62
+ // [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
63
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
64
+ // error.
65
+ MultiplexedSessionPrecommitToken precommit_token = 5
66
+ [(google.api.field_behavior) = OPTIONAL];
56
67
  }
57
68
 
58
69
  // Partial results from a streaming read or SQL query. Streaming reads and
@@ -157,6 +168,16 @@ message PartialResultSet {
157
168
  // This field will also be present in the last response for DML
158
169
  // statements.
159
170
  ResultSetStats stats = 5;
171
+
172
+ // Optional. A precommit token will be included if the read-write transaction
173
+ // is on a multiplexed session.
174
+ // The precommit token with the highest sequence number from this transaction
175
+ // attempt should be passed to the
176
+ // [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
177
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
178
+ // error.
179
+ MultiplexedSessionPrecommitToken precommit_token = 8
180
+ [(google.api.field_behavior) = OPTIONAL];
160
181
  }
161
182
 
162
183
  // Metadata about a [ResultSet][google.spanner.v1.ResultSet] or [PartialResultSet][google.spanner.v1.PartialResultSet].
@@ -628,9 +628,19 @@ message ExecuteSqlRequest {
628
628
  // execution statistics information.
629
629
  PLAN = 1;
630
630
 
631
- // This mode returns both the query plan and the execution statistics along
632
- // with the results.
631
+ // This mode returns the query plan, overall execution statistics,
632
+ // operator level execution statistics along with the results. This has a
633
+ // performance overhead compared to the other modes. It is not recommended
634
+ // to use this mode for production traffic.
633
635
  PROFILE = 2;
636
+
637
+ // This mode returns the overall (but not operator-level) execution
638
+ // statistics along with the results.
639
+ WITH_STATS = 3;
640
+
641
+ // This mode returns the query plan, overall (but not operator-level)
642
+ // execution statistics along with the results.
643
+ WITH_PLAN_AND_STATS = 4;
634
644
  }
635
645
 
636
646
  // Query optimizer configuration.
@@ -782,6 +792,17 @@ message ExecuteSqlRequest {
782
792
  // If the field is set to `true` but the request does not set
783
793
  // `partition_token`, the API returns an `INVALID_ARGUMENT` error.
784
794
  bool data_boost_enabled = 16;
795
+
796
+ // Optional. If set to true, this statement marks the end of the transaction.
797
+ // The transaction should be committed or aborted after this statement
798
+ // executes, and attempts to execute any other requests against this
799
+ // transaction (including reads and queries) will be rejected.
800
+ //
801
+ // For DML statements, setting this option may cause some error reporting to
802
+ // be deferred until commit time (e.g. validation of unique constraints).
803
+ // Given this, successful execution of a DML statement should not be assumed
804
+ // until a subsequent Commit call completes successfully.
805
+ bool last_statement = 17 [(google.api.field_behavior) = OPTIONAL];
785
806
  }
786
807
 
787
808
  // The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
@@ -851,6 +872,17 @@ message ExecuteBatchDmlRequest {
851
872
 
852
873
  // Common options for this request.
853
874
  RequestOptions request_options = 5;
875
+
876
+ // Optional. If set to true, this request marks the end of the transaction.
877
+ // The transaction should be committed or aborted after these statements
878
+ // execute, and attempts to execute any other requests against this
879
+ // transaction (including reads and queries) will be rejected.
880
+ //
881
+ // Setting this option may cause some error reporting to be deferred until
882
+ // commit time (e.g. validation of unique constraints). Given this, successful
883
+ // execution of statements should not be assumed until a subsequent Commit
884
+ // call completes successfully.
885
+ bool last_statements = 6 [(google.api.field_behavior) = OPTIONAL];
854
886
  }
855
887
 
856
888
  // The response for
@@ -899,6 +931,16 @@ message ExecuteBatchDmlResponse {
899
931
  // If all DML statements are executed successfully, the status is `OK`.
900
932
  // Otherwise, the error status of the first failed statement.
901
933
  google.rpc.Status status = 2;
934
+
935
+ // Optional. A precommit token will be included if the read-write transaction
936
+ // is on a multiplexed session.
937
+ // The precommit token with the highest sequence number from this transaction
938
+ // attempt should be passed to the
939
+ // [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
940
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
941
+ // error.
942
+ MultiplexedSessionPrecommitToken precommit_token = 3
943
+ [(google.api.field_behavior) = OPTIONAL];
902
944
  }
903
945
 
904
946
  // Options for a PartitionQueryRequest and
@@ -1215,6 +1257,14 @@ message BeginTransactionRequest {
1215
1257
  // transaction, set it on the reads and writes that are part of this
1216
1258
  // transaction instead.
1217
1259
  RequestOptions request_options = 3;
1260
+
1261
+ // Optional. Required for read-write transactions on a multiplexed session
1262
+ // that commit mutations but do not perform any reads or queries. Clients
1263
+ // should randomly select one of the mutations from the mutation set and send
1264
+ // it as a part of this request.
1265
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
1266
+ // error.
1267
+ Mutation mutation_key = 4 [(google.api.field_behavior) = OPTIONAL];
1218
1268
  }
1219
1269
 
1220
1270
  // The request for [Commit][google.spanner.v1.Spanner.Commit].
@@ -1262,6 +1312,15 @@ message CommitRequest {
1262
1312
 
1263
1313
  // Common options for this request.
1264
1314
  RequestOptions request_options = 6;
1315
+
1316
+ // Optional. If the read-write transaction was executed on a multiplexed
1317
+ // session, the precommit token with the highest sequence number received in
1318
+ // this transaction attempt, should be included here. Failing to do so will
1319
+ // result in a FailedPrecondition error.
1320
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
1321
+ // error.
1322
+ MultiplexedSessionPrecommitToken precommit_token = 9
1323
+ [(google.api.field_behavior) = OPTIONAL];
1265
1324
  }
1266
1325
 
1267
1326
  // The request for [Rollback][google.spanner.v1.Spanner.Rollback].
@@ -16,6 +16,7 @@ syntax = "proto3";
16
16
 
17
17
  package google.spanner.v1;
18
18
 
19
+ import "google/api/field_behavior.proto";
19
20
  import "google/protobuf/duration.proto";
20
21
  import "google/protobuf/timestamp.proto";
21
22
 
@@ -378,6 +379,14 @@ message TransactionOptions {
378
379
 
379
380
  // Read lock mode for the transaction.
380
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];
381
390
  }
382
391
 
383
392
  // Message type to initiate a Partitioned DML transaction.
@@ -512,6 +521,17 @@ message Transaction {
512
521
  // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
513
522
  // Example: `"2014-10-02T15:01:23.045123456Z"`.
514
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;
515
535
  }
516
536
 
517
537
  // This message is used to select the transaction in which a
@@ -539,3 +559,17 @@ message TransactionSelector {
539
559
  TransactionOptions begin = 3;
540
560
  }
541
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
+ }
@@ -32,20 +32,24 @@ message Type {
32
32
  // Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
33
33
  TypeCode code = 1 [(google.api.field_behavior) = REQUIRED];
34
34
 
35
- // If [code][google.spanner.v1.Type.code] == [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type`
36
- // is the type of the array elements.
35
+ // If [code][google.spanner.v1.Type.code] ==
36
+ // [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the
37
+ // type of the array elements.
37
38
  Type array_element_type = 2;
38
39
 
39
- // If [code][google.spanner.v1.Type.code] == [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type`
40
- // provides type information for the struct's fields.
40
+ // If [code][google.spanner.v1.Type.code] ==
41
+ // [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides
42
+ // type information for the struct's fields.
41
43
  StructType struct_type = 3;
42
44
 
43
- // The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that disambiguates SQL type that Spanner will
44
- // use to represent values of this type during query processing. This is
45
- // necessary for some type codes because a single [TypeCode][google.spanner.v1.TypeCode] can be mapped
46
- // to different SQL types depending on the SQL dialect. [type_annotation][google.spanner.v1.Type.type_annotation]
47
- // typically is not needed to process the content of a value (it doesn't
48
- // affect serialization) and clients can ignore it on the read path.
45
+ // The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that
46
+ // disambiguates SQL type that Spanner will use to represent values of this
47
+ // type during query processing. This is necessary for some type codes because
48
+ // a single [TypeCode][google.spanner.v1.TypeCode] can be mapped to different
49
+ // SQL types depending on the SQL dialect.
50
+ // [type_annotation][google.spanner.v1.Type.type_annotation] typically is not
51
+ // needed to process the content of a value (it doesn't affect serialization)
52
+ // and clients can ignore it on the read path.
49
53
  TypeAnnotationCode type_annotation = 4;
50
54
 
51
55
  // If [code][google.spanner.v1.Type.code] ==
@@ -56,7 +60,8 @@ message Type {
56
60
  string proto_type_fqn = 5;
57
61
  }
58
62
 
59
- // `StructType` defines the fields of a [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
63
+ // `StructType` defines the fields of a
64
+ // [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
60
65
  message StructType {
61
66
  // Message representing a single field of a struct.
62
67
  message Field {
@@ -76,9 +81,9 @@ message StructType {
76
81
  // The list of fields that make up this struct. Order is
77
82
  // significant, because values of this struct type are represented as
78
83
  // lists, where the order of field values matches the order of
79
- // fields in the [StructType][google.spanner.v1.StructType]. In turn, the order of fields
80
- // matches the order of columns in a read request, or the order of
81
- // fields in the `SELECT` clause of a query.
84
+ // fields in the [StructType][google.spanner.v1.StructType]. In turn, the
85
+ // order of fields matches the order of columns in a read request, or the
86
+ // order of fields in the `SELECT` clause of a query.
82
87
  repeated Field fields = 1;
83
88
  }
84
89
 
@@ -137,14 +142,14 @@ enum TypeCode {
137
142
  STRUCT = 9;
138
143
 
139
144
  // Encoded as `string`, in decimal format or scientific notation format.
140
- // <br>Decimal format:
141
- // <br>`[+-]Digits[.[Digits]]` or
142
- // <br>`[+-][Digits].Digits`
145
+ // Decimal format:
146
+ // `[+-]Digits[.[Digits]]` or
147
+ // `[+-][Digits].Digits`
143
148
  //
144
149
  // Scientific notation:
145
- // <br>`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
146
- // <br>`[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
147
- // <br>(ExponentIndicator is `"e"` or `"E"`)
150
+ // `[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
151
+ // `[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
152
+ // (ExponentIndicator is `"e"` or `"E"`)
148
153
  NUMERIC = 10;
149
154
 
150
155
  // Encoded as a JSON-formatted `string` as described in RFC 7159. The
@@ -163,6 +168,13 @@ enum TypeCode {
163
168
 
164
169
  // Encoded as `string`, in decimal format.
165
170
  ENUM = 14;
171
+
172
+ // Encoded as `string`, in `ISO8601` duration format -
173
+ // `P[n]Y[n]M[n]DT[n]H[n]M[n[.fraction]]S`
174
+ // where `n` is an integer.
175
+ // For example, `P1Y2M3DT4H5M6.5S` represents time duration of 1 year, 2
176
+ // months, 3 days, 4 hours, 5 minutes, and 6.5 seconds.
177
+ INTERVAL = 16;
166
178
  }
167
179
 
168
180
  // `TypeAnnotationCode` is used as a part of [Type][google.spanner.v1.Type] to
@@ -175,19 +187,20 @@ enum TypeAnnotationCode {
175
187
  TYPE_ANNOTATION_CODE_UNSPECIFIED = 0;
176
188
 
177
189
  // PostgreSQL compatible NUMERIC type. This annotation needs to be applied to
178
- // [Type][google.spanner.v1.Type] instances having [NUMERIC][google.spanner.v1.TypeCode.NUMERIC]
179
- // type code to specify that values of this type should be treated as
180
- // PostgreSQL NUMERIC values. Currently this annotation is always needed for
181
- // [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] when a client interacts with PostgreSQL-enabled
182
- // Spanner databases.
190
+ // [Type][google.spanner.v1.Type] instances having
191
+ // [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] type code to specify that
192
+ // values of this type should be treated as PostgreSQL NUMERIC values.
193
+ // Currently this annotation is always needed for
194
+ // [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] when a client interacts with
195
+ // PostgreSQL-enabled Spanner databases.
183
196
  PG_NUMERIC = 2;
184
197
 
185
198
  // PostgreSQL compatible JSONB type. This annotation needs to be applied to
186
- // [Type][google.spanner.v1.Type] instances having [JSON][google.spanner.v1.TypeCode.JSON]
187
- // type code to specify that values of this type should be treated as
188
- // PostgreSQL JSONB values. Currently this annotation is always needed for
189
- // [JSON][google.spanner.v1.TypeCode.JSON] when a client interacts with PostgreSQL-enabled
190
- // Spanner databases.
199
+ // [Type][google.spanner.v1.Type] instances having
200
+ // [JSON][google.spanner.v1.TypeCode.JSON] type code to specify that values of
201
+ // this type should be treated as PostgreSQL JSONB values. Currently this
202
+ // annotation is always needed for [JSON][google.spanner.v1.TypeCode.JSON]
203
+ // when a client interacts with PostgreSQL-enabled Spanner databases.
191
204
  PG_JSONB = 3;
192
205
 
193
206
  // PostgreSQL compatible OID type. This annotation can be used by a client