The representation of a Cloud Spanner transaction.
A transaction is a set of reads and writes that execute atomically at a single logical point in time across the columns/rows/tables in a database. Those reads and writes are grouped by passing them the same Transaction.
All reads/writes in the transaction must be executed within the same session, and that session may have only one transaction active at a time.
Spanner supports these transaction modes:
ReadOnly. Provides guaranteed consistency across several reads, but does not allow writes. Can be configured to read at timestamps in the past. Does not need to be committed and does not take locks.
ReadWrite. Supports reading and writing data at a single point in time. Uses pessimistic locking and, if necessary, two-phase commit. May abort, requiring the application to rerun.
SingleUse. A restricted form of a ReadOnly transaction where Spanner chooses the read timestamp.
Constructors
Transaction(ReadOnlyOptions)
Construction of read-only and read-write transactions.
Parameter
Name
Description
opts
ReadOnlyOptions
Transaction(ReadWriteOptions)
Construction of read-only and read-write transactions.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-22 UTC."],[[["\u003cp\u003eThis document outlines the \u003ccode\u003eTransaction\u003c/code\u003e class within the Google Cloud Spanner C++ client library, offering different version references.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eTransaction\u003c/code\u003e class represents a set of reads and writes that execute atomically in a Cloud Spanner database and can be found in the specified URL version paths.\u003c/p\u003e\n"],["\u003cp\u003eSpanner transactions support ReadOnly, ReadWrite, and SingleUse modes, each with specific capabilities and constraints, which are all listed in this documentation.\u003c/p\u003e\n"],["\u003cp\u003eTransactions can be constructed using \u003ccode\u003eReadOnlyOptions\u003c/code\u003e or \u003ccode\u003eReadWriteOptions\u003c/code\u003e, and these are lazy-evaluated, meaning RPCs are made upon the first server request.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eTransaction\u003c/code\u003e class supports regular value type operations, including copy, assignment, and move, through various constructors and operators.\u003c/p\u003e\n"]]],[],null,[]]