Skip to content

feat: Update transaction.proto to include different lock modes #1723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions protos/google/spanner/v1/result_set.proto
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ message ResultSetMetadata {
// If the read or SQL query began a transaction as a side-effect, the
// information about the new transaction is yielded here.
Transaction transaction = 2;

// A SQL query can be parameterized. In PLAN mode, these parameters can be
// undeclared. This indicates the field names and types for those undeclared
// parameters in the SQL query. For example, a SQL query like `"SELECT * FROM
// Users where UserId = @userId and UserName = @userName "` could return a
// `undeclared_parameters` value like:
//
// "fields": [
// { "name": "UserId", "type": { "code": "INT64" } },
// { "name": "UserName", "type": { "code": "STRING" } },
// ]
StructType undeclared_parameters = 3;
}

// Additional statistics about a [ResultSet][google.spanner.v1.ResultSet] or [PartialResultSet][google.spanner.v1.PartialResultSet].
Expand Down
49 changes: 39 additions & 10 deletions protos/google/spanner/v1/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
//
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.
Expand All @@ -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;
}
}
22 changes: 22 additions & 0 deletions protos/protos.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 93 additions & 3 deletions protos/protos.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading