MCPcopy Create free account
hub / github.com/cloudspannerecosystem/spanner-cli / Execute

Method Execute

statement.go:895–918  ·  view source on GitHub ↗
(ctx context.Context, session *Session)

Source from the content-addressed store, hash-verified

893}
894
895func (s *PartitionedDmlStatement) Execute(ctx context.Context, session *Session) (*Result, error) {
896 if session.InReadWriteTransaction() {
897 // PartitionedUpdate creates a new transaction and it could cause dead lock with the current running transaction.
898 return nil, errors.New(`Partitioned DML statement can not be run in a read-write transaction`)
899 }
900 if session.InReadOnlyTransaction() {
901 // Just for user-friendly.
902 return nil, errors.New(`Partitioned DML statement can not be run in a read-only transaction`)
903 }
904
905 stmt := spanner.NewStatement(s.Dml)
906 ctx, cancel := context.WithTimeout(ctx, pdmlTimeout)
907 defer cancel()
908
909 count, err := session.client.PartitionedUpdate(ctx, stmt)
910 if err != nil {
911 return nil, err
912 }
913 return &Result{
914 IsMutation: true,
915 AffectedRows: int(count),
916 AffectedRowsType: rowCountTypeLowerBound,
917 }, nil
918}
919
920type ExplainAnalyzeDmlStatement struct {
921 Dml string

Callers

nothing calls this directly

Calls 2

InReadOnlyTransactionMethod · 0.80

Tested by

no test coverage detected