Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAbortedDueToConcurrentModification = status.Error(codes.Aborted, "Transaction was aborted due to a concurrent modification")
ErrAbortedDueToConcurrentModification is returned by a read/write transaction that was aborted by Cloud Spanner, and where the internal retry attempt failed because it detected that the results during the retry were different from the initial attempt.
Functions ¶
This section is empty.
Types ¶
type AutocommitDMLMode ¶
type AutocommitDMLMode int
AutocommitDMLMode indicates whether a single DML statement should be executed in a normal atomic transaction or as a Partitioned DML statement. See https://cloud.google.com/spanner/docs/dml-partitioned for more information.
const ( Transactional AutocommitDMLMode = iota PartitionedNonAtomic )
func (AutocommitDMLMode) String ¶
func (mode AutocommitDMLMode) String() string
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver represents a Google Cloud Spanner database/sql driver.
type SpannerConn ¶
type SpannerConn interface { // StartBatchDDL starts a DDL batch on the connection. After calling this // method all subsequent DDL statements will be cached locally. Calling // RunBatch will send all cached DDL statements to Spanner as one batch. // Use DDL batching to speed up the execution of multiple DDL statements. // Note that a DDL batch is not atomic. It is possible that some DDL // statements are executed successfully and some not. // See https://cloud.google.com/spanner/docs/schema-updates#order_of_execution_of_statements_in_batches // for more information on how Cloud Spanner handles DDL batches. StartBatchDDL() error // StartBatchDML starts a DML batch on the connection. After calling this // method all subsequent DML statements will be cached locally. Calling // RunBatch will send all cached DML statements to Spanner as one batch. // Use DML batching to speed up the execution of multiple DML statements. // DML batches can be executed both outside of a transaction and during // a read/write transaction. If a DML batch is executed outside an active // transaction, the batch will be applied atomically to the database if // successful and rolled back if one or more of the statements fail. // If a DML batch is executed as part of a transaction, the error will // be returned to the application, and the application can decide whether // to commit or rollback the transaction. StartBatchDML() error // RunBatch sends all batched DDL or DML statements to Spanner. This is a // no-op if no statements have been batched or if there is no active batch. RunBatch(ctx context.Context) error // AbortBatch aborts the current DDL or DML batch and discards all batched // statements. AbortBatch() error // InDDLBatch returns true if the connection is currently in a DDL batch. InDDLBatch() bool // InDMLBatch returns true if the connection is currently in a DML batch. InDMLBatch() bool // RetryAbortsInternally returns true if the connection automatically // retries all aborted transactions. RetryAbortsInternally() bool // SetRetryAbortsInternally enables/disables the automatic retry of aborted // transactions. If disabled, any aborted error from a transaction will be // propagated to the application. SetRetryAbortsInternally(retry bool) error // AutocommitDMLMode returns the current mode that is used for DML // statements outside a transaction. The default is Transactional. AutocommitDMLMode() AutocommitDMLMode // SetAutocommitDMLMode sets the mode to use for DML statements that are // executed outside transactions. The default is Transactional. Change to // PartitionedNonAtomic to use Partitioned DML instead of Transactional DML. // See https://cloud.google.com/spanner/docs/dml-partitioned for more // information on Partitioned DML. SetAutocommitDMLMode(mode AutocommitDMLMode) error // ReadOnlyStaleness returns the current staleness that is used for // queries in autocommit mode, and for read-only transactions. ReadOnlyStaleness() spanner.TimestampBound // SetReadOnlyStaleness sets the staleness to use for queries in autocommit // mode and for read-only transaction. SetReadOnlyStaleness(staleness spanner.TimestampBound) error // Apply writes an array of mutations to the database. This method may only be called while the connection // is outside a transaction. Use BufferWrite to write mutations in a transaction. // See also spanner.Client#Apply Apply(ctx context.Context, ms []*spanner.Mutation, opts ...spanner.ApplyOption) (commitTimestamp time.Time, err error) // BufferWrite writes an array of mutations to the current transaction. This method may only be called while the // connection is in a read/write transaction. Use Apply to write mutations outside a transaction. // See also spanner.ReadWriteTransaction#BufferWrite BufferWrite(ms []*spanner.Mutation) error // CommitTimestamp returns the commit timestamp of the last implicit or explicit read/write transaction that // was executed on the connection, or an error if the connection has not executed a read/write transaction // that committed successfully. The timestamp is in the local timezone. CommitTimestamp() (commitTimestamp time.Time, err error) }
SpannerConn is the public interface for the raw Spanner connection for the sql driver. This interface can be used with the db.Conn().Raw() method.