google-cloud-spanner 2.31.0 → 2.33.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/google/cloud/spanner/batch_client.rb +1 -0
- data/lib/google/cloud/spanner/batch_snapshot.rb +4 -0
- data/lib/google/cloud/spanner/client.rb +89 -16
- data/lib/google/cloud/spanner/convert.rb +2 -0
- data/lib/google/cloud/spanner/fields.rb +1 -0
- data/lib/google/cloud/spanner/service.rb +10 -3
- data/lib/google/cloud/spanner/session.rb +87 -16
- data/lib/google/cloud/spanner/snapshot.rb +3 -0
- data/lib/google/cloud/spanner/transaction.rb +19 -6
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5432cd1029cb3077b9eee5511329297355428098e40afa349d93fb0272b2c092
|
|
4
|
+
data.tar.gz: a70271c85a8aa155d2e66e50733c388ca7005f4ce924fb921c253e14a98b3d86
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2191fcfe9aad61cca23733bbdfa78f359d10aa140e3fc77a53c3c4dafb5aa72ac99c94ae09437ab4b8080922610d709c634e4023657c706759180202143a00e1
|
|
7
|
+
data.tar.gz: 682e7a8b1a85c680cfaad9dc4af31c426dad9c80ac19345a034531338a6201173769e161a986a5d53a3382b0fb653f21e9274610800ee931e8d3cd7d72b62c55
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
+
### 2.33.0 (2025-12-12)
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* Support :UUID data type ([#139](https://github.com/googleapis/ruby-spanner/issues/139))
|
|
8
|
+
|
|
9
|
+
### 2.32.0 (2025-12-04)
|
|
10
|
+
|
|
11
|
+
#### Features
|
|
12
|
+
|
|
13
|
+
* Add support for ReadLockMode ([#171](https://github.com/googleapis/ruby-spanner/issues/171))
|
|
14
|
+
|
|
3
15
|
### 2.31.0 (2025-12-02)
|
|
4
16
|
|
|
5
17
|
#### Features
|
|
@@ -138,6 +138,7 @@ module Google
|
|
|
138
138
|
# | `FLOAT64` | `Float` | |
|
|
139
139
|
# | `FLOAT32` | `Float` | |
|
|
140
140
|
# | `STRING` | `String` | |
|
|
141
|
+
# | `UUID` | `String` | |
|
|
141
142
|
# | `DATE` | `Date` | |
|
|
142
143
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
143
144
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -166,6 +167,7 @@ module Google
|
|
|
166
167
|
# * `:INT64`
|
|
167
168
|
# * `:STRING`
|
|
168
169
|
# * `:TIMESTAMP`
|
|
170
|
+
# * `:UUID`
|
|
169
171
|
# * `Array` - Lists are specified by providing the type code in an
|
|
170
172
|
# array. For example, an array of integers are specified as
|
|
171
173
|
# `[:INT64]`.
|
|
@@ -489,6 +491,7 @@ module Google
|
|
|
489
491
|
# | `FLOAT64` | `Float` | |
|
|
490
492
|
# | `FLOAT32` | `Float` | |
|
|
491
493
|
# | `STRING` | `String` | |
|
|
494
|
+
# | `UUID` | `String` | |
|
|
492
495
|
# | `DATE` | `Date` | |
|
|
493
496
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
494
497
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -517,6 +520,7 @@ module Google
|
|
|
517
520
|
# * `:INT64`
|
|
518
521
|
# * `:STRING`
|
|
519
522
|
# * `:TIMESTAMP`
|
|
523
|
+
# * `:UUID`
|
|
520
524
|
# * `Array` - Lists are specified by providing the type code in an
|
|
521
525
|
# array. For example, an array of integers are specified as
|
|
522
526
|
# `[:INT64]`.
|
|
@@ -180,6 +180,7 @@ module Google
|
|
|
180
180
|
# | `FLOAT32` | `Float` | |
|
|
181
181
|
# | `NUMERIC` | `BigDecimal` | |
|
|
182
182
|
# | `STRING` | `String` | |
|
|
183
|
+
# | `UUID` | `String` | |
|
|
183
184
|
# | `DATE` | `Date` | |
|
|
184
185
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
185
186
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -209,6 +210,7 @@ module Google
|
|
|
209
210
|
# * `:INT64`
|
|
210
211
|
# * `:STRING`
|
|
211
212
|
# * `:TIMESTAMP`
|
|
213
|
+
# * `:UUID`
|
|
212
214
|
# * `Array` - Lists are specified by providing the type code in an
|
|
213
215
|
# array. For example, an array of integers are specified as
|
|
214
216
|
# `[:INT64]`.
|
|
@@ -618,6 +620,7 @@ module Google
|
|
|
618
620
|
# | `FLOAT32` | `Float` | |
|
|
619
621
|
# | `NUMERIC` | `BigDecimal` | |
|
|
620
622
|
# | `STRING` | `String` | |
|
|
623
|
+
# | `UUID` | `String` | |
|
|
621
624
|
# | `DATE` | `Date` | |
|
|
622
625
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
623
626
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -648,6 +651,7 @@ module Google
|
|
|
648
651
|
# * `:INT64`
|
|
649
652
|
# * `:STRING`
|
|
650
653
|
# * `:TIMESTAMP`
|
|
654
|
+
# * `:UUID`
|
|
651
655
|
# * `Array` - Lists are specified by providing the type code in an
|
|
652
656
|
# array. For example, an array of integers are specified as
|
|
653
657
|
# `[:INT64]`.
|
|
@@ -1105,6 +1109,13 @@ module Google
|
|
|
1105
1109
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
1106
1110
|
# trigger a retry.
|
|
1107
1111
|
#
|
|
1112
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1113
|
+
# The read lock mode for the transaction.
|
|
1114
|
+
# Can be one of the following:
|
|
1115
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1116
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1117
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1118
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1108
1119
|
#
|
|
1109
1120
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1110
1121
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
@@ -1161,7 +1172,7 @@ module Google
|
|
|
1161
1172
|
def upsert table, rows,
|
|
1162
1173
|
exclude_txn_from_change_streams: false,
|
|
1163
1174
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1164
|
-
call_options: nil
|
|
1175
|
+
call_options: nil, read_lock_mode: nil
|
|
1165
1176
|
request_options = Convert.to_request_options \
|
|
1166
1177
|
request_options, tag_type: :transaction_tag
|
|
1167
1178
|
|
|
@@ -1171,7 +1182,8 @@ module Google
|
|
|
1171
1182
|
isolation_level: isolation_level,
|
|
1172
1183
|
commit_options: commit_options,
|
|
1173
1184
|
request_options: request_options,
|
|
1174
|
-
call_options: call_options
|
|
1185
|
+
call_options: call_options,
|
|
1186
|
+
read_lock_mode: read_lock_mode
|
|
1175
1187
|
end
|
|
1176
1188
|
end
|
|
1177
1189
|
alias save upsert
|
|
@@ -1257,6 +1269,15 @@ module Google
|
|
|
1257
1269
|
# trigger a retry.
|
|
1258
1270
|
#
|
|
1259
1271
|
#
|
|
1272
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1273
|
+
# The read lock mode for the transaction.
|
|
1274
|
+
# Can be one of the following:
|
|
1275
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1276
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1277
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1278
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1279
|
+
#
|
|
1280
|
+
#
|
|
1260
1281
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1261
1282
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
1262
1283
|
#
|
|
@@ -1312,7 +1333,7 @@ module Google
|
|
|
1312
1333
|
def insert table, rows,
|
|
1313
1334
|
exclude_txn_from_change_streams: false,
|
|
1314
1335
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1315
|
-
call_options: nil
|
|
1336
|
+
call_options: nil, read_lock_mode: nil
|
|
1316
1337
|
request_options = Convert.to_request_options \
|
|
1317
1338
|
request_options, tag_type: :transaction_tag
|
|
1318
1339
|
|
|
@@ -1322,7 +1343,8 @@ module Google
|
|
|
1322
1343
|
isolation_level: isolation_level,
|
|
1323
1344
|
commit_options: commit_options,
|
|
1324
1345
|
request_options: request_options,
|
|
1325
|
-
call_options: call_options
|
|
1346
|
+
call_options: call_options,
|
|
1347
|
+
read_lock_mode: read_lock_mode
|
|
1326
1348
|
end
|
|
1327
1349
|
end
|
|
1328
1350
|
|
|
@@ -1406,6 +1428,14 @@ module Google
|
|
|
1406
1428
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
1407
1429
|
# trigger a retry.
|
|
1408
1430
|
#
|
|
1431
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1432
|
+
# The read lock mode for the transaction.
|
|
1433
|
+
# Can be one of the following:
|
|
1434
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1435
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1436
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1437
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1438
|
+
#
|
|
1409
1439
|
#
|
|
1410
1440
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1411
1441
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
@@ -1461,7 +1491,7 @@ module Google
|
|
|
1461
1491
|
def update table, rows,
|
|
1462
1492
|
exclude_txn_from_change_streams: false,
|
|
1463
1493
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1464
|
-
call_options: nil
|
|
1494
|
+
call_options: nil, read_lock_mode: nil
|
|
1465
1495
|
request_options = Convert.to_request_options \
|
|
1466
1496
|
request_options, tag_type: :transaction_tag
|
|
1467
1497
|
|
|
@@ -1471,7 +1501,8 @@ module Google
|
|
|
1471
1501
|
isolation_level: isolation_level,
|
|
1472
1502
|
commit_options: commit_options,
|
|
1473
1503
|
request_options: request_options,
|
|
1474
|
-
call_options: call_options
|
|
1504
|
+
call_options: call_options,
|
|
1505
|
+
read_lock_mode: read_lock_mode
|
|
1475
1506
|
end
|
|
1476
1507
|
end
|
|
1477
1508
|
|
|
@@ -1557,6 +1588,14 @@ module Google
|
|
|
1557
1588
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
1558
1589
|
# trigger a retry.
|
|
1559
1590
|
#
|
|
1591
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1592
|
+
# The read lock mode for the transaction.
|
|
1593
|
+
# Can be one of the following:
|
|
1594
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1595
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1596
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1597
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1598
|
+
#
|
|
1560
1599
|
#
|
|
1561
1600
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1562
1601
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
@@ -1612,14 +1651,15 @@ module Google
|
|
|
1612
1651
|
def replace table, rows,
|
|
1613
1652
|
exclude_txn_from_change_streams: false,
|
|
1614
1653
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1615
|
-
call_options: nil
|
|
1654
|
+
call_options: nil, read_lock_mode: nil
|
|
1616
1655
|
@pool.with_session do |session|
|
|
1617
1656
|
session.replace table, rows,
|
|
1618
1657
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
1619
1658
|
isolation_level: isolation_level,
|
|
1620
1659
|
commit_options: commit_options,
|
|
1621
1660
|
request_options: request_options,
|
|
1622
|
-
call_options: call_options
|
|
1661
|
+
call_options: call_options,
|
|
1662
|
+
read_lock_mode: read_lock_mode
|
|
1623
1663
|
end
|
|
1624
1664
|
end
|
|
1625
1665
|
|
|
@@ -1684,6 +1724,15 @@ module Google
|
|
|
1684
1724
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
1685
1725
|
# trigger a retry.
|
|
1686
1726
|
#
|
|
1727
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1728
|
+
# The read lock mode for the transaction.
|
|
1729
|
+
# Can be one of the following:
|
|
1730
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1731
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1732
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1733
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1734
|
+
#
|
|
1735
|
+
#
|
|
1687
1736
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1688
1737
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
1689
1738
|
#
|
|
@@ -1732,7 +1781,7 @@ module Google
|
|
|
1732
1781
|
def delete table, keys = [],
|
|
1733
1782
|
exclude_txn_from_change_streams: false,
|
|
1734
1783
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1735
|
-
call_options: nil
|
|
1784
|
+
call_options: nil, read_lock_mode: nil
|
|
1736
1785
|
request_options = Convert.to_request_options \
|
|
1737
1786
|
request_options, tag_type: :transaction_tag
|
|
1738
1787
|
|
|
@@ -1742,7 +1791,8 @@ module Google
|
|
|
1742
1791
|
isolation_level: isolation_level,
|
|
1743
1792
|
commit_options: commit_options,
|
|
1744
1793
|
request_options: request_options,
|
|
1745
|
-
call_options: call_options
|
|
1794
|
+
call_options: call_options,
|
|
1795
|
+
read_lock_mode: read_lock_mode
|
|
1746
1796
|
end
|
|
1747
1797
|
end
|
|
1748
1798
|
|
|
@@ -1805,6 +1855,15 @@ module Google
|
|
|
1805
1855
|
# @yield [commit] The block for mutating the data.
|
|
1806
1856
|
# @yieldparam [Google::Cloud::Spanner::Commit] commit The Commit object.
|
|
1807
1857
|
#
|
|
1858
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1859
|
+
# The read lock mode for the transaction.
|
|
1860
|
+
# Can be one of the following:
|
|
1861
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1862
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1863
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1864
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1865
|
+
#
|
|
1866
|
+
#
|
|
1808
1867
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1809
1868
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
1810
1869
|
#
|
|
@@ -1863,7 +1922,7 @@ module Google
|
|
|
1863
1922
|
#
|
|
1864
1923
|
def commit exclude_txn_from_change_streams: false,
|
|
1865
1924
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1866
|
-
call_options: nil, &block
|
|
1925
|
+
call_options: nil, read_lock_mode: nil, &block
|
|
1867
1926
|
raise ArgumentError, "Must provide a block" unless block_given?
|
|
1868
1927
|
|
|
1869
1928
|
request_options = Convert.to_request_options \
|
|
@@ -1876,6 +1935,7 @@ module Google
|
|
|
1876
1935
|
commit_options: commit_options,
|
|
1877
1936
|
request_options: request_options,
|
|
1878
1937
|
call_options: call_options,
|
|
1938
|
+
read_lock_mode: read_lock_mode,
|
|
1879
1939
|
&block
|
|
1880
1940
|
)
|
|
1881
1941
|
end
|
|
@@ -2042,6 +2102,15 @@ module Google
|
|
|
2042
2102
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
2043
2103
|
# trigger a retry.
|
|
2044
2104
|
#
|
|
2105
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
2106
|
+
# The read lock mode for the transaction.
|
|
2107
|
+
# Can be one of the following:
|
|
2108
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
2109
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
2110
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
2111
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
2112
|
+
#
|
|
2113
|
+
#
|
|
2045
2114
|
# @yield [transaction] The block for reading and writing data.
|
|
2046
2115
|
# @yieldparam [Google::Cloud::Spanner::Transaction] transaction The
|
|
2047
2116
|
# Transaction object.
|
|
@@ -2144,7 +2213,7 @@ module Google
|
|
|
2144
2213
|
# end
|
|
2145
2214
|
#
|
|
2146
2215
|
def transaction deadline: 120, exclude_txn_from_change_streams: false,
|
|
2147
|
-
commit_options: nil, request_options: nil, call_options: nil
|
|
2216
|
+
commit_options: nil, request_options: nil, call_options: nil, read_lock_mode: nil
|
|
2148
2217
|
ensure_service!
|
|
2149
2218
|
unless Thread.current[IS_TRANSACTION_RUNNING_KEY].nil?
|
|
2150
2219
|
raise "Nested transactions are not allowed"
|
|
@@ -2158,7 +2227,8 @@ module Google
|
|
|
2158
2227
|
request_options, tag_type: :transaction_tag
|
|
2159
2228
|
|
|
2160
2229
|
@pool.with_session do |session|
|
|
2161
|
-
tx = session.create_empty_transaction
|
|
2230
|
+
tx = session.create_empty_transaction \
|
|
2231
|
+
exclude_txn_from_change_streams: exclude_txn_from_change_streams, read_lock_mode: read_lock_mode
|
|
2162
2232
|
if request_options
|
|
2163
2233
|
tx.transaction_tag = request_options[:transaction_tag]
|
|
2164
2234
|
end
|
|
@@ -2175,7 +2245,8 @@ module Google
|
|
|
2175
2245
|
tx.safe_begin_transaction!(
|
|
2176
2246
|
exclude_from_change_streams: exclude_txn_from_change_streams,
|
|
2177
2247
|
request_options: request_options,
|
|
2178
|
-
call_options: call_options
|
|
2248
|
+
call_options: call_options,
|
|
2249
|
+
read_lock_mode: read_lock_mode
|
|
2179
2250
|
)
|
|
2180
2251
|
end
|
|
2181
2252
|
|
|
@@ -2195,7 +2266,8 @@ module Google
|
|
|
2195
2266
|
commit_options: commit_options,
|
|
2196
2267
|
request_options: request_options,
|
|
2197
2268
|
call_options: call_options,
|
|
2198
|
-
precommit_token: tx.precommit_token
|
|
2269
|
+
precommit_token: tx.precommit_token,
|
|
2270
|
+
read_lock_mode: read_lock_mode
|
|
2199
2271
|
)
|
|
2200
2272
|
|
|
2201
2273
|
tx.precommit_token = commit_resp.precommit_token
|
|
@@ -2216,7 +2288,8 @@ module Google
|
|
|
2216
2288
|
previous_transaction_id = tx.transaction_id if tx.existing_transaction?
|
|
2217
2289
|
tx = session.create_empty_transaction(
|
|
2218
2290
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
2219
|
-
previous_transaction_id: previous_transaction_id
|
|
2291
|
+
previous_transaction_id: previous_transaction_id,
|
|
2292
|
+
read_lock_mode: read_lock_mode
|
|
2220
2293
|
)
|
|
2221
2294
|
if request_options
|
|
2222
2295
|
tx.transaction_tag = request_options[:transaction_tag]
|
|
@@ -261,6 +261,8 @@ module Google
|
|
|
261
261
|
descriptor = Google::Protobuf::DescriptorPool.generated_pool.lookup(type.proto_type_fqn).msgclass
|
|
262
262
|
content = Base64.decode64 value.string_value
|
|
263
263
|
descriptor.decode content
|
|
264
|
+
when :UUID
|
|
265
|
+
value.string_value
|
|
264
266
|
end
|
|
265
267
|
end
|
|
266
268
|
|
|
@@ -540,12 +540,14 @@ module Google
|
|
|
540
540
|
def commit session_name, mutations = [],
|
|
541
541
|
transaction_id: nil, exclude_txn_from_change_streams: false,
|
|
542
542
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
543
|
-
call_options: nil, precommit_token: nil
|
|
543
|
+
call_options: nil, precommit_token: nil, read_lock_mode: nil
|
|
544
544
|
route_to_leader = LARHeaders.commit
|
|
545
545
|
tx_opts = nil
|
|
546
546
|
if transaction_id.nil?
|
|
547
547
|
tx_opts = V1::TransactionOptions.new(
|
|
548
|
-
read_write: V1::TransactionOptions::ReadWrite.new
|
|
548
|
+
read_write: V1::TransactionOptions::ReadWrite.new(
|
|
549
|
+
read_lock_mode: read_lock_mode
|
|
550
|
+
),
|
|
549
551
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
550
552
|
isolation_level: isolation_level
|
|
551
553
|
)
|
|
@@ -640,7 +642,8 @@ module Google
|
|
|
640
642
|
call_options: nil,
|
|
641
643
|
route_to_leader: nil,
|
|
642
644
|
mutation_key: nil,
|
|
643
|
-
previous_transaction_id: nil
|
|
645
|
+
previous_transaction_id: nil,
|
|
646
|
+
read_lock_mode: nil
|
|
644
647
|
read_write = if previous_transaction_id.nil?
|
|
645
648
|
V1::TransactionOptions::ReadWrite.new
|
|
646
649
|
else
|
|
@@ -649,6 +652,10 @@ module Google
|
|
|
649
652
|
)
|
|
650
653
|
end
|
|
651
654
|
|
|
655
|
+
unless read_lock_mode.nil?
|
|
656
|
+
read_write.read_lock_mode = read_lock_mode
|
|
657
|
+
end
|
|
658
|
+
|
|
652
659
|
tx_opts = V1::TransactionOptions.new(
|
|
653
660
|
read_write: read_write,
|
|
654
661
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams
|
|
@@ -135,6 +135,7 @@ module Google
|
|
|
135
135
|
# | `FLOAT32` | `Float` | |
|
|
136
136
|
# | `NUMERIC` | `BigDecimal` | |
|
|
137
137
|
# | `STRING` | `String` | |
|
|
138
|
+
# | `UUID` | `String` | |
|
|
138
139
|
# | `DATE` | `Date` | |
|
|
139
140
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
140
141
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -165,6 +166,7 @@ module Google
|
|
|
165
166
|
# * `:INT64`
|
|
166
167
|
# * `:STRING`
|
|
167
168
|
# * `:TIMESTAMP`
|
|
169
|
+
# * `:UUID`
|
|
168
170
|
# * `Array` - Lists are specified by providing the type code in an
|
|
169
171
|
# array. For example, an array of integers are specified as
|
|
170
172
|
# `[:INT64]`.
|
|
@@ -648,6 +650,15 @@ module Google
|
|
|
648
650
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
649
651
|
# trigger a retry.
|
|
650
652
|
#
|
|
653
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
654
|
+
# The read lock mode for the transaction.
|
|
655
|
+
# Can be one of the following:
|
|
656
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
657
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
658
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
659
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
660
|
+
#
|
|
661
|
+
#
|
|
651
662
|
# @yield [commit] The block for mutating the data.
|
|
652
663
|
# @yieldparam [Google::Cloud::Spanner::Commit] commit The Commit object.
|
|
653
664
|
#
|
|
@@ -684,7 +695,7 @@ module Google
|
|
|
684
695
|
#
|
|
685
696
|
def commit transaction_id: nil, exclude_txn_from_change_streams: false,
|
|
686
697
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
687
|
-
call_options: nil
|
|
698
|
+
call_options: nil, read_lock_mode: nil
|
|
688
699
|
ensure_service!
|
|
689
700
|
commit = Commit.new
|
|
690
701
|
yield commit
|
|
@@ -698,6 +709,7 @@ module Google
|
|
|
698
709
|
transaction_id: transaction_id,
|
|
699
710
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
700
711
|
isolation_level: isolation_level,
|
|
712
|
+
read_lock_mode: read_lock_mode,
|
|
701
713
|
commit_options: commit_options,
|
|
702
714
|
request_options: request_options,
|
|
703
715
|
call_options: call_options,
|
|
@@ -830,6 +842,7 @@ module Google
|
|
|
830
842
|
# | `FLOAT32` | `Float` | |
|
|
831
843
|
# | `NUMERIC` | `BigDecimal` | |
|
|
832
844
|
# | `STRING` | `String` | |
|
|
845
|
+
# | `UUID` | `String` | |
|
|
833
846
|
# | `DATE` | `Date` | |
|
|
834
847
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
835
848
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -888,6 +901,15 @@ module Google
|
|
|
888
901
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
889
902
|
# trigger a retry.
|
|
890
903
|
#
|
|
904
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
905
|
+
# The read lock mode for the transaction.
|
|
906
|
+
# Can be one of the following:
|
|
907
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
908
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
909
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
910
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
911
|
+
#
|
|
912
|
+
#
|
|
891
913
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
892
914
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
893
915
|
#
|
|
@@ -919,14 +941,15 @@ module Google
|
|
|
919
941
|
def upsert table, *rows,
|
|
920
942
|
transaction_id: nil, exclude_txn_from_change_streams: false,
|
|
921
943
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
922
|
-
call_options: nil
|
|
944
|
+
call_options: nil, read_lock_mode: nil
|
|
923
945
|
opts = {
|
|
924
946
|
transaction_id: transaction_id,
|
|
925
947
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
926
948
|
isolation_level: isolation_level,
|
|
927
949
|
commit_options: commit_options,
|
|
928
950
|
request_options: request_options,
|
|
929
|
-
call_options: call_options
|
|
951
|
+
call_options: call_options,
|
|
952
|
+
read_lock_mode: read_lock_mode
|
|
930
953
|
}
|
|
931
954
|
commit(**opts) do |c|
|
|
932
955
|
c.upsert table, rows
|
|
@@ -954,6 +977,7 @@ module Google
|
|
|
954
977
|
# | `FLOAT32` | `Float` | |
|
|
955
978
|
# | `NUMERIC` | `BigDecimal` | |
|
|
956
979
|
# | `STRING` | `String` | |
|
|
980
|
+
# | `UUID` | `String` | |
|
|
957
981
|
# | `DATE` | `Date` | |
|
|
958
982
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
959
983
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -1012,6 +1036,15 @@ module Google
|
|
|
1012
1036
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
1013
1037
|
# trigger a retry.
|
|
1014
1038
|
#
|
|
1039
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1040
|
+
# The read lock mode for the transaction.
|
|
1041
|
+
# Can be one of the following:
|
|
1042
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1043
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1044
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1045
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1046
|
+
#
|
|
1047
|
+
#
|
|
1015
1048
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1016
1049
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
1017
1050
|
#
|
|
@@ -1043,14 +1076,15 @@ module Google
|
|
|
1043
1076
|
def insert table, *rows,
|
|
1044
1077
|
transaction_id: nil, exclude_txn_from_change_streams: false,
|
|
1045
1078
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1046
|
-
call_options: nil
|
|
1079
|
+
call_options: nil, read_lock_mode: nil
|
|
1047
1080
|
opts = {
|
|
1048
1081
|
transaction_id: transaction_id,
|
|
1049
1082
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
1050
1083
|
isolation_level: isolation_level,
|
|
1051
1084
|
commit_options: commit_options,
|
|
1052
1085
|
request_options: request_options,
|
|
1053
|
-
call_options: call_options
|
|
1086
|
+
call_options: call_options,
|
|
1087
|
+
read_lock_mode: read_lock_mode
|
|
1054
1088
|
}
|
|
1055
1089
|
commit(**opts) do |c|
|
|
1056
1090
|
c.insert table, rows
|
|
@@ -1077,6 +1111,7 @@ module Google
|
|
|
1077
1111
|
# | `FLOAT32` | `Float` | |
|
|
1078
1112
|
# | `NUMERIC` | `BigDecimal` | |
|
|
1079
1113
|
# | `STRING` | `String` | |
|
|
1114
|
+
# | `UUID` | `String` | |
|
|
1080
1115
|
# | `DATE` | `Date` | |
|
|
1081
1116
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
1082
1117
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -1135,6 +1170,15 @@ module Google
|
|
|
1135
1170
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
1136
1171
|
# trigger a retry.
|
|
1137
1172
|
#
|
|
1173
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1174
|
+
# The read lock mode for the transaction.
|
|
1175
|
+
# Can be one of the following:
|
|
1176
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1177
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1178
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1179
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1180
|
+
#
|
|
1181
|
+
#
|
|
1138
1182
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1139
1183
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
1140
1184
|
#
|
|
@@ -1166,14 +1210,15 @@ module Google
|
|
|
1166
1210
|
def update table, *rows,
|
|
1167
1211
|
transaction_id: nil, exclude_txn_from_change_streams: false,
|
|
1168
1212
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1169
|
-
call_options: nil
|
|
1213
|
+
call_options: nil, read_lock_mode: nil
|
|
1170
1214
|
opts = {
|
|
1171
1215
|
transaction_id: transaction_id,
|
|
1172
1216
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
1173
1217
|
isolation_level: isolation_level,
|
|
1174
1218
|
commit_options: commit_options,
|
|
1175
1219
|
request_options: request_options,
|
|
1176
|
-
call_options: call_options
|
|
1220
|
+
call_options: call_options,
|
|
1221
|
+
read_lock_mode: read_lock_mode
|
|
1177
1222
|
}
|
|
1178
1223
|
commit(**opts) do |c|
|
|
1179
1224
|
c.update table, rows
|
|
@@ -1202,6 +1247,7 @@ module Google
|
|
|
1202
1247
|
# | `FLOAT32` | `Float` | |
|
|
1203
1248
|
# | `NUMERIC` | `BigDecimal` | |
|
|
1204
1249
|
# | `STRING` | `String` | |
|
|
1250
|
+
# | `UUID` | `String` | |
|
|
1205
1251
|
# | `DATE` | `Date` | |
|
|
1206
1252
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
1207
1253
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -1261,6 +1307,15 @@ module Google
|
|
|
1261
1307
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
1262
1308
|
# trigger a retry.
|
|
1263
1309
|
#
|
|
1310
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1311
|
+
# The read lock mode for the transaction.
|
|
1312
|
+
# Can be one of the following:
|
|
1313
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1314
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1315
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1316
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1317
|
+
#
|
|
1318
|
+
#
|
|
1264
1319
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1265
1320
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
1266
1321
|
#
|
|
@@ -1291,14 +1346,16 @@ module Google
|
|
|
1291
1346
|
#
|
|
1292
1347
|
def replace table, *rows,
|
|
1293
1348
|
transaction_id: nil, exclude_txn_from_change_streams: false,
|
|
1294
|
-
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1349
|
+
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1350
|
+
call_options: nil, read_lock_mode: nil
|
|
1295
1351
|
opts = {
|
|
1296
1352
|
transaction_id: transaction_id,
|
|
1297
1353
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
1298
1354
|
isolation_level: isolation_level,
|
|
1299
1355
|
commit_options: commit_options,
|
|
1300
1356
|
request_options: request_options,
|
|
1301
|
-
call_options: call_options
|
|
1357
|
+
call_options: call_options,
|
|
1358
|
+
read_lock_mode: read_lock_mode
|
|
1302
1359
|
}
|
|
1303
1360
|
commit(**opts) do |c|
|
|
1304
1361
|
c.replace table, rows
|
|
@@ -1364,6 +1421,15 @@ module Google
|
|
|
1364
1421
|
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
|
1365
1422
|
# trigger a retry.
|
|
1366
1423
|
#
|
|
1424
|
+
# @param [Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode] read_lock_mode
|
|
1425
|
+
# The read lock mode for the transaction.
|
|
1426
|
+
# Can be one of the following:
|
|
1427
|
+
# * `:READ_LOCK_MODE_UNSPECIFIED` : The default unspecified read lock mode.
|
|
1428
|
+
# * `:PESSIMISTIC` : The pessimistic lock mode, where read locks are acquired immediately on read.
|
|
1429
|
+
# * `:OPTIMISTIC` : The optimistic lock mode, where locks for reads are not acquired on read
|
|
1430
|
+
# but instead on a commit to validate that the data has not changed since the transaction started.
|
|
1431
|
+
#
|
|
1432
|
+
#
|
|
1367
1433
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
|
1368
1434
|
# committed. If commit options are set it returns {CommitResponse}.
|
|
1369
1435
|
#
|
|
@@ -1392,14 +1458,15 @@ module Google
|
|
|
1392
1458
|
def delete table, keys = [],
|
|
1393
1459
|
transaction_id: nil, exclude_txn_from_change_streams: false,
|
|
1394
1460
|
isolation_level: nil, commit_options: nil, request_options: nil,
|
|
1395
|
-
call_options: nil
|
|
1461
|
+
call_options: nil, read_lock_mode: nil
|
|
1396
1462
|
opts = {
|
|
1397
1463
|
transaction_id: transaction_id,
|
|
1398
1464
|
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
1399
1465
|
isolation_level: isolation_level,
|
|
1400
1466
|
commit_options: commit_options,
|
|
1401
1467
|
request_options: request_options,
|
|
1402
|
-
call_options: call_options
|
|
1468
|
+
call_options: call_options,
|
|
1469
|
+
read_lock_mode: read_lock_mode
|
|
1403
1470
|
}
|
|
1404
1471
|
commit(**opts) do |c|
|
|
1405
1472
|
c.delete table, keys
|
|
@@ -1423,12 +1490,15 @@ module Google
|
|
|
1423
1490
|
# or write transactions from being tracked in change streams.
|
|
1424
1491
|
# @private
|
|
1425
1492
|
# @return [::Google::Cloud::Spanner::Transaction]
|
|
1426
|
-
def create_transaction exclude_txn_from_change_streams: false
|
|
1493
|
+
def create_transaction exclude_txn_from_change_streams: false, read_lock_mode: nil
|
|
1427
1494
|
route_to_leader = LARHeaders.begin_transaction true
|
|
1428
1495
|
tx_grpc = service.begin_transaction path,
|
|
1429
1496
|
route_to_leader: route_to_leader,
|
|
1430
|
-
exclude_txn_from_change_streams: exclude_txn_from_change_streams
|
|
1431
|
-
|
|
1497
|
+
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
1498
|
+
read_lock_mode: read_lock_mode
|
|
1499
|
+
Transaction.from_grpc \
|
|
1500
|
+
tx_grpc, self,
|
|
1501
|
+
exclude_txn_from_change_streams: exclude_txn_from_change_streams, read_lock_mode: read_lock_mode
|
|
1432
1502
|
end
|
|
1433
1503
|
|
|
1434
1504
|
# Creates a new empty transaction wrapper without a server-side object.
|
|
@@ -1444,9 +1514,10 @@ module Google
|
|
|
1444
1514
|
# of a new ReadWrite transaction when retry is attempted.
|
|
1445
1515
|
# @private
|
|
1446
1516
|
# @return [::Google::Cloud::Spanner::Transaction] The new *empty-wrapper* transaction object.
|
|
1447
|
-
def create_empty_transaction exclude_txn_from_change_streams: false, previous_transaction_id: nil
|
|
1517
|
+
def create_empty_transaction exclude_txn_from_change_streams: false, previous_transaction_id: nil,
|
|
1518
|
+
read_lock_mode: nil
|
|
1448
1519
|
Transaction.from_grpc nil, self, exclude_txn_from_change_streams: exclude_txn_from_change_streams,
|
|
1449
|
-
previous_transaction_id: previous_transaction_id
|
|
1520
|
+
previous_transaction_id: previous_transaction_id, read_lock_mode: read_lock_mode
|
|
1450
1521
|
end
|
|
1451
1522
|
|
|
1452
1523
|
# If the session is non-multiplexed, keeps the session alive by executing `"SELECT 1"`.
|
|
@@ -103,6 +103,7 @@ module Google
|
|
|
103
103
|
# | `FLOAT32` | `Float` | |
|
|
104
104
|
# | `NUMERIC` | `BigDecimal` | |
|
|
105
105
|
# | `STRING` | `String` | |
|
|
106
|
+
# | `UUID` | `String` | |
|
|
106
107
|
# | `DATE` | `Date` | |
|
|
107
108
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
|
108
109
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
|
@@ -132,6 +133,7 @@ module Google
|
|
|
132
133
|
# * `:INT64`
|
|
133
134
|
# * `:STRING`
|
|
134
135
|
# * `:TIMESTAMP`
|
|
136
|
+
# * `:UUID`
|
|
135
137
|
# * `Array` - Lists are specified by providing the type code in an
|
|
136
138
|
# array. For example, an array of integers are specified as
|
|
137
139
|
# `[:INT64]`.
|
|
@@ -469,6 +471,7 @@ module Google
|
|
|
469
471
|
# * `:INT64`
|
|
470
472
|
# * `:STRING`
|
|
471
473
|
# * `:TIMESTAMP`
|
|
474
|
+
# * `:UUID`
|
|
472
475
|
# * `Array` - Lists are specified by providing the type code in an
|
|
473
476
|
# array. For example, an array of integers are specified as
|
|
474
477
|
# `[:INT64]`.
|
|
@@ -111,6 +111,9 @@ module Google
|
|
|
111
111
|
# @return [::String, nil]
|
|
112
112
|
attr_reader :previous_transaction_id
|
|
113
113
|
|
|
114
|
+
# @private Whether to add a read lock mode on the transaction.
|
|
115
|
+
attr_accessor :read_lock_mode
|
|
116
|
+
|
|
114
117
|
# Creates a new `Spanner::Transaction` instance from a `V1::Transaction` object.
|
|
115
118
|
# @param grpc [::Google::Cloud::Spanner::V1::Transaction] Underlying `V1::Transaction` object.
|
|
116
119
|
# @param session [::Google::Cloud::Spanner::Session] The session this transaction is running in.
|
|
@@ -123,10 +126,11 @@ module Google
|
|
|
123
126
|
# of a new ReadWrite transaction when retry is attempted.
|
|
124
127
|
# @private
|
|
125
128
|
# @return [::Google::Cloud::Spanner::Transaction]
|
|
126
|
-
def initialize grpc, session, exclude_txn_from_change_streams, previous_transaction_id: nil
|
|
129
|
+
def initialize grpc, session, exclude_txn_from_change_streams, previous_transaction_id: nil, read_lock_mode: nil
|
|
127
130
|
@grpc = grpc
|
|
128
131
|
@session = session
|
|
129
132
|
@exclude_txn_from_change_streams = exclude_txn_from_change_streams
|
|
133
|
+
@read_lock_mode = read_lock_mode
|
|
130
134
|
|
|
131
135
|
# throwing away empty strings for simplicity
|
|
132
136
|
unless previous_transaction_id.nil? || previous_transaction_id.empty?
|
|
@@ -136,6 +140,7 @@ module Google
|
|
|
136
140
|
@commit = Commit.new
|
|
137
141
|
@seqno = 0
|
|
138
142
|
@exclude_txn_from_change_streams = false
|
|
143
|
+
@read_lock_mode = nil
|
|
139
144
|
|
|
140
145
|
# Mutex to enfore thread safety for transaction creation and query executions.
|
|
141
146
|
#
|
|
@@ -1250,8 +1255,10 @@ module Google
|
|
|
1250
1255
|
# of a new ReadWrite transaction when retry is attempted.
|
|
1251
1256
|
# @private
|
|
1252
1257
|
# @return [::Google::Cloud::Spanner::Transaction]
|
|
1253
|
-
def self.from_grpc grpc, session, exclude_txn_from_change_streams: false, previous_transaction_id: nil
|
|
1254
|
-
|
|
1258
|
+
def self.from_grpc grpc, session, exclude_txn_from_change_streams: false, previous_transaction_id: nil,
|
|
1259
|
+
read_lock_mode: nil
|
|
1260
|
+
new grpc, session, exclude_txn_from_change_streams, previous_transaction_id: previous_transaction_id,
|
|
1261
|
+
read_lock_mode: read_lock_mode
|
|
1255
1262
|
end
|
|
1256
1263
|
|
|
1257
1264
|
##
|
|
@@ -1278,7 +1285,8 @@ module Google
|
|
|
1278
1285
|
# @private
|
|
1279
1286
|
# @return [::Google::Cloud::Spanner::V1::Transaction, nil] The new transaction
|
|
1280
1287
|
# object, or `nil` if a transaction already exists.
|
|
1281
|
-
def safe_begin_transaction! exclude_from_change_streams: false, request_options: nil, call_options: nil
|
|
1288
|
+
def safe_begin_transaction! exclude_from_change_streams: false, request_options: nil, call_options: nil,
|
|
1289
|
+
read_lock_mode: nil
|
|
1282
1290
|
# If a read-write transaction on a multiplexed session commit mutations
|
|
1283
1291
|
# without performing any reads or queries, one of the mutations from the mutation set
|
|
1284
1292
|
# must be sent as a mutation key for `BeginTransaction`.
|
|
@@ -1299,7 +1307,8 @@ module Google
|
|
|
1299
1307
|
call_options: call_options,
|
|
1300
1308
|
route_to_leader: route_to_leader,
|
|
1301
1309
|
mutation_key: mutation_key,
|
|
1302
|
-
previous_transaction_id: previous_transaction_id
|
|
1310
|
+
previous_transaction_id: previous_transaction_id,
|
|
1311
|
+
read_lock_mode: read_lock_mode
|
|
1303
1312
|
)
|
|
1304
1313
|
end
|
|
1305
1314
|
end
|
|
@@ -1343,7 +1352,7 @@ module Google
|
|
|
1343
1352
|
# or write transactions from being tracked in change streams.
|
|
1344
1353
|
# @private
|
|
1345
1354
|
# @return [::Google::Cloud::Spanner::V1::TransactionSelector]
|
|
1346
|
-
def tx_selector exclude_txn_from_change_streams: false
|
|
1355
|
+
def tx_selector exclude_txn_from_change_streams: false, read_lock_mode: nil
|
|
1347
1356
|
return V1::TransactionSelector.new id: transaction_id if existing_transaction?
|
|
1348
1357
|
|
|
1349
1358
|
read_write = if @previous_transaction_id.nil?
|
|
@@ -1354,6 +1363,10 @@ module Google
|
|
|
1354
1363
|
)
|
|
1355
1364
|
end
|
|
1356
1365
|
|
|
1366
|
+
unless read_lock_mode.nil?
|
|
1367
|
+
read_write.read_lock_mode = read_lock_mode
|
|
1368
|
+
end
|
|
1369
|
+
|
|
1357
1370
|
V1::TransactionSelector.new(
|
|
1358
1371
|
begin: V1::TransactionOptions.new(
|
|
1359
1372
|
read_write: read_write,
|