From d0195b45423b73969636bc911980613a46dffa97 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 2 Nov 2022 20:55:10 +0530 Subject: [PATCH] feat: Update transaction.proto to include different lock modes (#2112) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Update transaction.proto to include different lock modes PiperOrigin-RevId: 481838475 Source-Link: https://github.com/googleapis/googleapis/commit/922f1f33bb239addc9816fbbecbf15376e03a4aa Source-Link: https://github.com/googleapis/googleapis-gen/commit/bf32c6e413d4d7fd3c99b725fab653eb983d9dd6 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmYzMmM2ZTQxM2Q0ZDdmZDNjOTliNzI1ZmFiNjUzZWI5ODNkOWRkNiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../google/spanner/v1/TransactionOptions.java | 409 +++++++++++++++++- .../google/spanner/v1/TransactionProto.java | 50 ++- .../spanner/v1/TransactionSelector.java | 42 +- .../v1/TransactionSelectorOrBuilder.java | 9 +- .../proto/google/spanner/v1/transaction.proto | 49 ++- 5 files changed, 495 insertions(+), 64 deletions(-) diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptions.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptions.java index df94389838..15830e93dd 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptions.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptions.java @@ -45,7 +45,8 @@ * need to be committed. * 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 * the key space and runs the DML statement over each partition @@ -151,7 +152,8 @@ * timestamp. * 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: * These timestamp bounds execute reads at a user-specified * timestamp. Reads at a timestamp are guaranteed to see a consistent @@ -167,7 +169,9 @@ * timestamp. As a result, they execute slightly faster than the * 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: * Bounded staleness modes allow Cloud Spanner to pick the read timestamp, @@ -190,7 +194,9 @@ * Because the timestamp negotiation requires up-front knowledge of * 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: * Cloud Spanner continuously garbage collects deleted and overwritten data @@ -316,7 +322,33 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { public interface ReadWriteOrBuilder extends // @@protoc_insertion_point(interface_extends:google.spanner.v1.TransactionOptions.ReadWrite) - com.google.protobuf.MessageOrBuilder {} + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Read lock mode for the transaction.
+     * 
+ * + * .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * + * @return The enum numeric value on the wire for readLockMode. + */ + int getReadLockModeValue(); + /** + * + * + *
+     * Read lock mode for the transaction.
+     * 
+ * + * .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * + * @return The readLockMode. + */ + com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode getReadLockMode(); + } /** * * @@ -337,7 +369,9 @@ private ReadWrite(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } - private ReadWrite() {} + private ReadWrite() { + readLockMode_ = 0; + } @java.lang.Override @SuppressWarnings({"unused"}) @@ -365,6 +399,214 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.TransactionOptions.ReadWrite.Builder.class); } + /** + * + * + *
+     * `ReadLockMode` is used to set the read lock mode for read-write
+     * transactions.
+     * 
+ * + * Protobuf enum {@code google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode} + */ + public enum ReadLockMode implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * Default value.
+       * If the value is not specified, the pessimistic read lock is used.
+       * 
+ * + * READ_LOCK_MODE_UNSPECIFIED = 0; + */ + READ_LOCK_MODE_UNSPECIFIED(0), + /** + * + * + *
+       * Pessimistic lock mode.
+       * Read locks are acquired immediately on read.
+       * 
+ * + * PESSIMISTIC = 1; + */ + 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.
+       * 
+ * + * OPTIMISTIC = 2; + */ + OPTIMISTIC(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+       * Default value.
+       * If the value is not specified, the pessimistic read lock is used.
+       * 
+ * + * READ_LOCK_MODE_UNSPECIFIED = 0; + */ + public static final int READ_LOCK_MODE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+       * Pessimistic lock mode.
+       * Read locks are acquired immediately on read.
+       * 
+ * + * PESSIMISTIC = 1; + */ + public static final int PESSIMISTIC_VALUE = 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.
+       * 
+ * + * OPTIMISTIC = 2; + */ + public static final int OPTIMISTIC_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ReadLockMode valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ReadLockMode forNumber(int value) { + switch (value) { + case 0: + return READ_LOCK_MODE_UNSPECIFIED; + case 1: + return PESSIMISTIC; + case 2: + return OPTIMISTIC; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ReadLockMode findValueByNumber(int number) { + return ReadLockMode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.spanner.v1.TransactionOptions.ReadWrite.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final ReadLockMode[] VALUES = values(); + + public static ReadLockMode valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ReadLockMode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode) + } + + public static final int READ_LOCK_MODE_FIELD_NUMBER = 1; + private int readLockMode_; + /** + * + * + *
+     * Read lock mode for the transaction.
+     * 
+ * + * .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * + * @return The enum numeric value on the wire for readLockMode. + */ + @java.lang.Override + public int getReadLockModeValue() { + return readLockMode_; + } + /** + * + * + *
+     * Read lock mode for the transaction.
+     * 
+ * + * .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * + * @return The readLockMode. + */ + @java.lang.Override + public com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode getReadLockMode() { + @SuppressWarnings("deprecation") + com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode result = + com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode.valueOf(readLockMode_); + return result == null + ? com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode.UNRECOGNIZED + : result; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -379,6 +621,12 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (readLockMode_ + != com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode + .READ_LOCK_MODE_UNSPECIFIED + .getNumber()) { + output.writeEnum(1, readLockMode_); + } getUnknownFields().writeTo(output); } @@ -388,6 +636,12 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; + if (readLockMode_ + != com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode + .READ_LOCK_MODE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, readLockMode_); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -404,6 +658,7 @@ public boolean equals(final java.lang.Object obj) { com.google.spanner.v1.TransactionOptions.ReadWrite other = (com.google.spanner.v1.TransactionOptions.ReadWrite) obj; + if (readLockMode_ != other.readLockMode_) return false; if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @@ -415,6 +670,8 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + READ_LOCK_MODE_FIELD_NUMBER; + hash = (53 * hash) + readLockMode_; hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -556,6 +813,8 @@ private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { @java.lang.Override public Builder clear() { super.clear(); + readLockMode_ = 0; + return this; } @@ -583,6 +842,7 @@ public com.google.spanner.v1.TransactionOptions.ReadWrite build() { public com.google.spanner.v1.TransactionOptions.ReadWrite buildPartial() { com.google.spanner.v1.TransactionOptions.ReadWrite result = new com.google.spanner.v1.TransactionOptions.ReadWrite(this); + result.readLockMode_ = readLockMode_; onBuilt(); return result; } @@ -635,6 +895,9 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(com.google.spanner.v1.TransactionOptions.ReadWrite other) { if (other == com.google.spanner.v1.TransactionOptions.ReadWrite.getDefaultInstance()) return this; + if (other.readLockMode_ != 0) { + setReadLockModeValue(other.getReadLockModeValue()); + } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; @@ -661,6 +924,12 @@ public Builder mergeFrom( case 0: done = true; break; + case 8: + { + readLockMode_ = input.readEnum(); + + break; + } // case 8 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -678,6 +947,105 @@ public Builder mergeFrom( return this; } + private int readLockMode_ = 0; + /** + * + * + *
+       * Read lock mode for the transaction.
+       * 
+ * + * .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * + * + * @return The enum numeric value on the wire for readLockMode. + */ + @java.lang.Override + public int getReadLockModeValue() { + return readLockMode_; + } + /** + * + * + *
+       * Read lock mode for the transaction.
+       * 
+ * + * .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * + * + * @param value The enum numeric value on the wire for readLockMode to set. + * @return This builder for chaining. + */ + public Builder setReadLockModeValue(int value) { + + readLockMode_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Read lock mode for the transaction.
+       * 
+ * + * .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * + * + * @return The readLockMode. + */ + @java.lang.Override + public com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode getReadLockMode() { + @SuppressWarnings("deprecation") + com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode result = + com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode.valueOf(readLockMode_); + return result == null + ? com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode.UNRECOGNIZED + : result; + } + /** + * + * + *
+       * Read lock mode for the transaction.
+       * 
+ * + * .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * + * + * @param value The readLockMode to set. + * @return This builder for chaining. + */ + public Builder setReadLockMode( + com.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode value) { + if (value == null) { + throw new NullPointerException(); + } + + readLockMode_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+       * Read lock mode for the transaction.
+       * 
+ * + * .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * + * + * @return This builder for chaining. + */ + public Builder clearReadLockMode() { + + readLockMode_ = 0; + onChanged(); + return this; + } + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { @@ -1446,7 +1814,8 @@ public interface ReadOnlyOrBuilder * *
      * 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.
      * 
* * bool return_read_timestamp = 6; @@ -1908,7 +2277,8 @@ public com.google.protobuf.DurationOrBuilder getExactStalenessOrBuilder() { * *
      * 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.
      * 
* * bool return_read_timestamp = 6; @@ -3672,7 +4042,8 @@ public com.google.protobuf.DurationOrBuilder getExactStalenessOrBuilder() { * *
        * 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.
        * 
* * bool return_read_timestamp = 6; @@ -3688,7 +4059,8 @@ public boolean getReturnReadTimestamp() { * *
        * 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.
        * 
* * bool return_read_timestamp = 6; @@ -3707,7 +4079,8 @@ public Builder setReturnReadTimestamp(boolean value) { * *
        * 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.
        * 
* * bool return_read_timestamp = 6; @@ -4246,7 +4619,8 @@ protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.Build * need to be committed. * 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 * the key space and runs the DML statement over each partition @@ -4352,7 +4726,8 @@ protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.Build * timestamp. * 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: * These timestamp bounds execute reads at a user-specified * timestamp. Reads at a timestamp are guaranteed to see a consistent @@ -4368,7 +4743,9 @@ protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.Build * timestamp. As a result, they execute slightly faster than the * 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: * Bounded staleness modes allow Cloud Spanner to pick the read timestamp, @@ -4391,7 +4768,9 @@ protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.Build * Because the timestamp negotiation requires up-front knowledge of * 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: * Cloud Spanner continuously garbage collects deleted and overwritten data diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionProto.java index 4ce4f322c0..ac4e24ae4c 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionProto.java @@ -63,32 +63,36 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "\n#google/spanner/v1/transaction.proto\022\021g" + "oogle.spanner.v1\032\036google/protobuf/durati" + "on.proto\032\037google/protobuf/timestamp.prot" - + "o\"\303\004\n\022TransactionOptions\022E\n\nread_write\030\001" + + "o\"\353\005\n\022TransactionOptions\022E\n\nread_write\030\001" + " \001(\0132/.google.spanner.v1.TransactionOpti" + "ons.ReadWriteH\000\022O\n\017partitioned_dml\030\003 \001(\013" + "24.google.spanner.v1.TransactionOptions." + "PartitionedDmlH\000\022C\n\tread_only\030\002 \001(\0132..go" + "ogle.spanner.v1.TransactionOptions.ReadO" - + "nlyH\000\032\013\n\tReadWrite\032\020\n\016PartitionedDml\032\250\002\n" - + "\010ReadOnly\022\020\n\006strong\030\001 \001(\010H\000\0228\n\022min_read_" - + "timestamp\030\002 \001(\0132\032.google.protobuf.Timest" - + "ampH\000\0222\n\rmax_staleness\030\003 \001(\0132\031.google.pr" - + "otobuf.DurationH\000\0224\n\016read_timestamp\030\004 \001(" - + "\0132\032.google.protobuf.TimestampH\000\0224\n\017exact" - + "_staleness\030\005 \001(\0132\031.google.protobuf.Durat" - + "ionH\000\022\035\n\025return_read_timestamp\030\006 \001(\010B\021\n\017" - + "timestamp_boundB\006\n\004mode\"M\n\013Transaction\022\n" - + "\n\002id\030\001 \001(\014\0222\n\016read_timestamp\030\002 \001(\0132\032.goo" - + "gle.protobuf.Timestamp\"\244\001\n\023TransactionSe" - + "lector\022;\n\nsingle_use\030\001 \001(\0132%.google.span" - + "ner.v1.TransactionOptionsH\000\022\014\n\002id\030\002 \001(\014H" - + "\000\0226\n\005begin\030\003 \001(\0132%.google.spanner.v1.Tra" - + "nsactionOptionsH\000B\n\n\010selectorB\266\001\n\025com.go" - + "ogle.spanner.v1B\020TransactionProtoP\001Z8goo" - + "gle.golang.org/genproto/googleapis/spann" - + "er/v1;spanner\252\002\027Google.Cloud.Spanner.V1\312" - + "\002\027Google\\Cloud\\Spanner\\V1\352\002\032Google::Clou" - + "d::Spanner::V1b\006proto3" + + "nlyH\000\032\262\001\n\tReadWrite\022T\n\016read_lock_mode\030\001 " + + "\001(\0162<.google.spanner.v1.TransactionOptio" + + "ns.ReadWrite.ReadLockMode\"O\n\014ReadLockMod" + + "e\022\036\n\032READ_LOCK_MODE_UNSPECIFIED\020\000\022\017\n\013PES" + + "SIMISTIC\020\001\022\016\n\nOPTIMISTIC\020\002\032\020\n\016Partitione" + + "dDml\032\250\002\n\010ReadOnly\022\020\n\006strong\030\001 \001(\010H\000\0228\n\022m" + + "in_read_timestamp\030\002 \001(\0132\032.google.protobu" + + "f.TimestampH\000\0222\n\rmax_staleness\030\003 \001(\0132\031.g" + + "oogle.protobuf.DurationH\000\0224\n\016read_timest" + + "amp\030\004 \001(\0132\032.google.protobuf.TimestampH\000\022" + + "4\n\017exact_staleness\030\005 \001(\0132\031.google.protob" + + "uf.DurationH\000\022\035\n\025return_read_timestamp\030\006" + + " \001(\010B\021\n\017timestamp_boundB\006\n\004mode\"M\n\013Trans" + + "action\022\n\n\002id\030\001 \001(\014\0222\n\016read_timestamp\030\002 \001" + + "(\0132\032.google.protobuf.Timestamp\"\244\001\n\023Trans" + + "actionSelector\022;\n\nsingle_use\030\001 \001(\0132%.goo" + + "gle.spanner.v1.TransactionOptionsH\000\022\014\n\002i" + + "d\030\002 \001(\014H\000\0226\n\005begin\030\003 \001(\0132%.google.spanne" + + "r.v1.TransactionOptionsH\000B\n\n\010selectorB\266\001" + + "\n\025com.google.spanner.v1B\020TransactionProt" + + "oP\001Z8google.golang.org/genproto/googleap" + + "is/spanner/v1;spanner\252\002\027Google.Cloud.Spa" + + "nner.V1\312\002\027Google\\Cloud\\Spanner\\V1\352\002\032Goog" + + "le::Cloud::Spanner::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -110,7 +114,9 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { internal_static_google_spanner_v1_TransactionOptions_ReadWrite_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_v1_TransactionOptions_ReadWrite_descriptor, - new java.lang.String[] {}); + new java.lang.String[] { + "ReadLockMode", + }); internal_static_google_spanner_v1_TransactionOptions_PartitionedDml_descriptor = internal_static_google_spanner_v1_TransactionOptions_descriptor.getNestedTypes().get(1); internal_static_google_spanner_v1_TransactionOptions_PartitionedDml_fieldAccessorTable = diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelector.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelector.java index 940b3a1f62..4b6ac35ad2 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelector.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelector.java @@ -25,7 +25,8 @@ * This message is used to select the transaction in which a * [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. * * * Protobuf type {@code google.spanner.v1.TransactionSelector} @@ -217,7 +218,8 @@ public com.google.protobuf.ByteString getId() { *
    * 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].
    * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -234,7 +236,8 @@ public boolean hasBegin() { *
    * 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].
    * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -254,7 +257,8 @@ public com.google.spanner.v1.TransactionOptions getBegin() { *
    * 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].
    * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -478,7 +482,8 @@ protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.Build * This message is used to select the transaction in which a * [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. * * * Protobuf type {@code google.spanner.v1.TransactionSelector} @@ -1020,7 +1025,8 @@ public Builder clearId() { *
      * 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].
      * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -1037,7 +1043,8 @@ public boolean hasBegin() { *
      * 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].
      * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -1064,7 +1071,8 @@ public com.google.spanner.v1.TransactionOptions getBegin() { *
      * 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].
      * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -1088,7 +1096,8 @@ public Builder setBegin(com.google.spanner.v1.TransactionOptions value) { *
      * 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].
      * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -1109,7 +1118,8 @@ public Builder setBegin(com.google.spanner.v1.TransactionOptions.Builder builder *
      * 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].
      * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -1143,7 +1153,8 @@ public Builder mergeBegin(com.google.spanner.v1.TransactionOptions value) { *
      * 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].
      * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -1170,7 +1181,8 @@ public Builder clearBegin() { *
      * 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].
      * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -1184,7 +1196,8 @@ public com.google.spanner.v1.TransactionOptions.Builder getBeginBuilder() { *
      * 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].
      * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -1206,7 +1219,8 @@ public com.google.spanner.v1.TransactionOptionsOrBuilder getBeginOrBuilder() { *
      * 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].
      * 
* * .google.spanner.v1.TransactionOptions begin = 3; diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelectorOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelectorOrBuilder.java index 8e33337d0c..ff10cc1510 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelectorOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelectorOrBuilder.java @@ -95,7 +95,8 @@ public interface TransactionSelectorOrBuilder *
    * 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].
    * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -109,7 +110,8 @@ public interface TransactionSelectorOrBuilder *
    * 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].
    * 
* * .google.spanner.v1.TransactionOptions begin = 3; @@ -123,7 +125,8 @@ public interface TransactionSelectorOrBuilder *
    * 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].
    * 
* * .google.spanner.v1.TransactionOptions begin = 3; diff --git a/proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/transaction.proto b/proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/transaction.proto index 3577f797cb..49ab5cf523 100644 --- a/proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/transaction.proto +++ b/proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/transaction.proto @@ -56,7 +56,8 @@ option ruby_package = "Google::Cloud::Spanner::V1"; // // 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 @@ -192,7 +193,8 @@ option ruby_package = "Google::Cloud::Spanner::V1"; // 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: // @@ -213,7 +215,9 @@ option ruby_package = "Google::Cloud::Spanner::V1"; // 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: @@ -243,7 +247,9 @@ option ruby_package = "Google::Cloud::Spanner::V1"; // 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: @@ -349,14 +355,34 @@ message TransactionOptions { // Message type to initiate a read-write transaction. Currently this // transaction type has no options. message ReadWrite { + // `ReadLockMode` is used to set the read lock mode for read-write + // transactions. + enum ReadLockMode { + // Default value. + // + // If the value is not specified, the pessimistic read lock is used. + READ_LOCK_MODE_UNSPECIFIED = 0; - } + // Pessimistic lock mode. + // + // Read locks are acquired immediately on read. + PESSIMISTIC = 1; - // Message type to initiate a Partitioned DML transaction. - message PartitionedDml { + // 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. + OPTIMISTIC = 2; + } + // Read lock mode for the transaction. + ReadLockMode read_lock_mode = 1; } + // Message type to initiate a Partitioned DML transaction. + message PartitionedDml {} + // Message type to initiate a read-only transaction. message ReadOnly { // How to choose the timestamp for the read-only transaction. @@ -421,7 +447,8 @@ message TransactionOptions { } // 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. bool return_read_timestamp = 6; } @@ -475,7 +502,8 @@ message Transaction { // [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. message TransactionSelector { // If no fields are set, the default is a single use transaction // with strong concurrency. @@ -490,7 +518,8 @@ message TransactionSelector { // 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]. TransactionOptions begin = 3; } }