From 4fed510395e50548dc05d7198b5e09ac94860bb3 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 18 Oct 2022 11:54:12 +0100 Subject: [PATCH] feat: Update transaction.proto to include different lock modes (#9236) PiperOrigin-RevId: 481838475 Source-Link: googleapis/googleapis@922f1f3 Source-Link: googleapis/googleapis-gen@bf32c6e --- .../Google.Cloud.Spanner.V1/Transaction.g.cs | 142 ++++++++++++++---- 1 file changed, 115 insertions(+), 27 deletions(-) diff --git a/apis/Google.Cloud.Spanner.V1/Google.Cloud.Spanner.V1/Transaction.g.cs b/apis/Google.Cloud.Spanner.V1/Google.Cloud.Spanner.V1/Transaction.g.cs index 1f708fa7c9d5..cc85df153552 100644 --- a/apis/Google.Cloud.Spanner.V1/Google.Cloud.Spanner.V1/Transaction.g.cs +++ b/apis/Google.Cloud.Spanner.V1/Google.Cloud.Spanner.V1/Transaction.g.cs @@ -26,34 +26,38 @@ public static partial class TransactionReflection { string.Concat( "CiNnb29nbGUvc3Bhbm5lci92MS90cmFuc2FjdGlvbi5wcm90bxIRZ29vZ2xl", "LnNwYW5uZXIudjEaHmdvb2dsZS9wcm90b2J1Zi9kdXJhdGlvbi5wcm90bxof", - "Z29vZ2xlL3Byb3RvYnVmL3RpbWVzdGFtcC5wcm90byLDBAoSVHJhbnNhY3Rp", + "Z29vZ2xlL3Byb3RvYnVmL3RpbWVzdGFtcC5wcm90byLrBQoSVHJhbnNhY3Rp", "b25PcHRpb25zEkUKCnJlYWRfd3JpdGUYASABKAsyLy5nb29nbGUuc3Bhbm5l", "ci52MS5UcmFuc2FjdGlvbk9wdGlvbnMuUmVhZFdyaXRlSAASTwoPcGFydGl0", "aW9uZWRfZG1sGAMgASgLMjQuZ29vZ2xlLnNwYW5uZXIudjEuVHJhbnNhY3Rp", "b25PcHRpb25zLlBhcnRpdGlvbmVkRG1sSAASQwoJcmVhZF9vbmx5GAIgASgL", "Mi4uZ29vZ2xlLnNwYW5uZXIudjEuVHJhbnNhY3Rpb25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bGUuc3Bhbm5l", + "ci52MS5UcmFuc2FjdGlvbk9wdGlvbnNIAEIKCghzZWxlY3RvckK2AQoVY29t", + "Lmdvb2dsZS5zcGFubmVyLnYxQhBUcmFuc2FjdGlvblByb3RvUAFaOGdvb2ds", + "ZS5nb2xhbmcub3JnL2dlbnByb3RvL2dvb2dsZWFwaXMvc3Bhbm5lci92MTtz", + "cGFubmVyqgIXR29vZ2xlLkNsb3VkLlNwYW5uZXIuVjHKAhdHb29nbGVcQ2xv", + "dWRcU3Bhbm5lclxWMeoCGkdvb2dsZTo6Q2xvdWQ6OlNwYW5uZXI6OlYxYgZw", + "cm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.TransactionOptions), global::Google.Cloud.Spanner.V1.TransactionOptions.Parser, new[]{ "ReadWrite", "PartitionedDml", "ReadOnly" }, new[]{ "Mode" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite), global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.TransactionOptions), global::Google.Cloud.Spanner.V1.TransactionOptions.Parser, new[]{ "ReadWrite", "PartitionedDml", "ReadOnly" }, new[]{ "Mode" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite), global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Parser, new[]{ "ReadLockMode" }, null, new[]{ typeof(global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode) }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.TransactionOptions.Types.PartitionedDml), global::Google.Cloud.Spanner.V1.TransactionOptions.Types.PartitionedDml.Parser, null, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadOnly), global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadOnly.Parser, new[]{ "Strong", "MinReadTimestamp", "MaxStaleness", "ReadTimestamp", "ExactStaleness", "ReturnReadTimestamp" }, new[]{ "TimestampBound" }, null, null, null)}), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.Transaction), global::Google.Cloud.Spanner.V1.Transaction.Parser, new[]{ "Id", "ReadTimestamp" }, null, null, null, null), @@ -94,7 +98,8 @@ public static partial class TransactionReflection { /// /// Queries on change streams must be performed with the snapshot read-only /// transaction mode, specifying a strong read. Please see - /// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong] for more details. + /// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong] + /// for more details. /// /// 3. Partitioned DML. This type of transaction is used to execute /// a single Partitioned DML statement. Partitioned DML partitions @@ -230,7 +235,8 @@ public static partial class TransactionReflection { /// Queries on change streams (see below for more details) must also specify /// the strong read timestamp bound. /// - /// See [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong]. + /// See + /// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong]. /// /// Exact staleness: /// @@ -251,7 +257,9 @@ public static partial class TransactionReflection { /// equivalent boundedly stale concurrency modes. On the other hand, /// boundedly stale reads usually return fresher results. /// - /// See [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp] and + /// See + /// [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp] + /// and /// [TransactionOptions.ReadOnly.exact_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness]. /// /// Bounded staleness: @@ -281,7 +289,9 @@ public static partial class TransactionReflection { /// which rows will be read, it can only be used with single-use /// read-only transactions. /// - /// See [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness] and + /// See + /// [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness] + /// and /// [TransactionOptions.ReadOnly.min_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp]. /// /// Old read timestamps and garbage collection: @@ -784,6 +794,7 @@ public sealed partial class ReadWrite : pb::IMessage [global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] public ReadWrite(ReadWrite other) : this() { + readLockMode_ = other.readLockMode_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -793,6 +804,21 @@ public sealed partial class ReadWrite : pb::IMessage return new ReadWrite(this); } + /// Field number for the "read_lock_mode" field. + public const int ReadLockModeFieldNumber = 1; + private global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode readLockMode_ = global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode.Unspecified; + /// + /// Read lock mode for the transaction. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode ReadLockMode { + get { return readLockMode_; } + set { + readLockMode_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] public override bool Equals(object other) { @@ -808,6 +834,7 @@ public sealed partial class ReadWrite : pb::IMessage if (ReferenceEquals(other, this)) { return true; } + if (ReadLockMode != other.ReadLockMode) return false; return Equals(_unknownFields, other._unknownFields); } @@ -815,6 +842,7 @@ public sealed partial class ReadWrite : pb::IMessage [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] public override int GetHashCode() { int hash = 1; + if (ReadLockMode != global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode.Unspecified) hash ^= ReadLockMode.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -833,6 +861,10 @@ public sealed partial class ReadWrite : pb::IMessage #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE output.WriteRawMessage(this); #else + if (ReadLockMode != global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode.Unspecified) { + output.WriteRawTag(8); + output.WriteEnum((int) ReadLockMode); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -843,6 +875,10 @@ public sealed partial class ReadWrite : pb::IMessage [global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (ReadLockMode != global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode.Unspecified) { + output.WriteRawTag(8); + output.WriteEnum((int) ReadLockMode); + } if (_unknownFields != null) { _unknownFields.WriteTo(ref output); } @@ -853,6 +889,9 @@ public sealed partial class ReadWrite : pb::IMessage [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] public int CalculateSize() { int size = 0; + if (ReadLockMode != global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode.Unspecified) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) ReadLockMode); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -865,6 +904,9 @@ public sealed partial class ReadWrite : pb::IMessage if (other == null) { return; } + if (other.ReadLockMode != global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode.Unspecified) { + ReadLockMode = other.ReadLockMode; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -880,6 +922,10 @@ public sealed partial class ReadWrite : pb::IMessage default: _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; + case 8: { + ReadLockMode = (global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode) input.ReadEnum(); + break; + } } } #endif @@ -895,11 +941,50 @@ public sealed partial class ReadWrite : pb::IMessage default: _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; + case 8: { + ReadLockMode = (global::Google.Cloud.Spanner.V1.TransactionOptions.Types.ReadWrite.Types.ReadLockMode) input.ReadEnum(); + break; + } } } } #endif + #region Nested types + /// Container for nested types declared in the ReadWrite message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static partial class Types { + /// + /// `ReadLockMode` is used to set the read lock mode for read-write + /// transactions. + /// + public enum ReadLockMode { + /// + /// Default value. + /// + /// If the value is not specified, the pessimistic read lock is used. + /// + [pbr::OriginalName("READ_LOCK_MODE_UNSPECIFIED")] Unspecified = 0, + /// + /// Pessimistic lock mode. + /// + /// Read locks are acquired immediately on read. + /// + [pbr::OriginalName("PESSIMISTIC")] Pessimistic = 1, + /// + /// Optimistic lock mode. + /// + /// Locks for reads within the transaction are not acquired on read. + /// Instead the locks are acquired on a commit to validate that + /// read/queried data has not changed since the transaction started. + /// + [pbr::OriginalName("OPTIMISTIC")] Optimistic = 2, + } + + } + #endregion + } /// @@ -1245,7 +1330,8 @@ public sealed partial class ReadOnly : pb::IMessage private bool returnReadTimestamp_; /// /// If true, the Cloud Spanner-selected read timestamp is included in - /// the [Transaction][google.spanner.v1.Transaction] message that describes the transaction. + /// the [Transaction][google.spanner.v1.Transaction] message that describes + /// the transaction. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] @@ -1856,7 +1942,8 @@ public sealed partial class Transaction : pb::IMessage /// [Read][google.spanner.v1.Spanner.Read] or /// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs. /// - /// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more information about transactions. + /// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more + /// information about transactions. /// public sealed partial class TransactionSelector : pb::IMessage #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE @@ -1950,7 +2037,8 @@ public sealed partial class TransactionSelector : pb::IMessage /// Begin a new transaction and execute this read or SQL query in /// it. The transaction ID of the new transaction is returned in - /// [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], which is a [Transaction][google.spanner.v1.Transaction]. + /// [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], + /// which is a [Transaction][google.spanner.v1.Transaction]. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]