- HTTP request
- Path parameters
- Request body
- Response body
- Authorization Scopes
- Mutation
- Write
- Delete
- CommitStats
- Try it!
Commits a transaction. The request includes the mutations to be applied to rows in the database.
sessions.commit
might return an ABORTED
error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If sessions.commit
returns ABORTED
, the caller should re-attempt the transaction from the beginning, re-using the same session.
On very rare occasions, sessions.commit
might return UNKNOWN
. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.
HTTP request
POST https://spanner.googleapis.com/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
session |
Required. The session in which the transaction to be committed is running. Authorization requires the following IAM permission on the specified resource
|
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "mutations": [ { object ( |
Fields | |
---|---|
mutations[] |
The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list. |
returnCommitStats |
If |
requestOptions |
Common options for this request. |
Union field transaction . Required. The transaction in which to commit. transaction can be only one of the following: |
|
transactionId |
sessions.commit a previously-started transaction. A base64-encoded string. |
singleUseTransaction |
Execute mutations in a temporary transaction. Note that unlike commit of a previously-started transaction, commit with a temporary transaction is non-idempotent. That is, if the |
Response body
If successful, the response body contains data with the following structure:
The response for sessions.commit
.
JSON representation |
---|
{
"commitTimestamp": string,
"commitStats": {
object ( |
Fields | |
---|---|
commitTimestamp |
The Cloud Spanner timestamp at which the transaction committed. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: |
commitStats |
The statistics about this sessions.commit. Not returned by default. For more information, see |
Authorization Scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/spanner.data
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.
Mutation
A modification to one or more Cloud Spanner rows. Mutations can be applied to a Cloud Spanner database by sending them in a sessions.commit
call.
JSON representation |
---|
{ // Union field |
Fields | |
---|---|
Union field operation . Required. The operation to perform. operation can be only one of the following: |
|
insert |
Insert new rows in a table. If any of the rows already exist, the write or transaction fails with error |
update |
Update existing rows in a table. If any of the rows does not already exist, the transaction fails with error |
insertOrUpdate |
Like When using |
replace |
Like In an interleaved table, if you create the child table with the |
delete |
Delete rows from a table. Succeeds whether or not the named rows were present. |
Write
Arguments to insert
, update
, insertOrUpdate
, and replace
operations.
JSON representation |
---|
{ "table": string, "columns": [ string ], "values": [ array ] } |
Fields | |
---|---|
table |
Required. The table whose rows will be written. |
columns[] |
The names of the columns in The list of columns must contain enough columns to allow Cloud Spanner to derive values for all primary key columns in the row(s) to be modified. |
values[] |
The values to be written. |
Delete
Arguments to delete
operations.
JSON representation |
---|
{
"table": string,
"keySet": {
object ( |
Fields | |
---|---|
table |
Required. The table whose rows will be deleted. |
keySet |
Required. The primary keys of the rows within |
CommitStats
Additional statistics about a commit.
JSON representation |
---|
{ "mutationCount": string } |
Fields | |
---|---|
mutationCount |
The total number of mutations for the transaction. Knowing the |