(ctx context.Context, stmts []string, opts db.ExecuteOptions)
| 196 | } |
| 197 | |
| 198 | func (d *Driver) executeInTransactionMode(ctx context.Context, stmts []string, opts db.ExecuteOptions) (int64, error) { |
| 199 | var rowCount int64 |
| 200 | |
| 201 | // Log transaction start |
| 202 | opts.LogTransactionControl(storepb.TaskRunLog_TransactionControl_BEGIN, "") |
| 203 | |
| 204 | committed := false |
| 205 | if _, err := d.client.ReadWriteTransaction(ctx, func(ctx context.Context, rwt *spanner.ReadWriteTransaction) error { |
| 206 | spannerStmts := []spanner.Statement{} |
| 207 | for _, stmt := range stmts { |
| 208 | spannerStmts = append(spannerStmts, spanner.NewStatement(stmt)) |
| 209 | } |
| 210 | counts, err := rwt.BatchUpdate(ctx, spannerStmts) |
| 211 | if err != nil { |
| 212 | return err |
| 213 | } |
| 214 | for _, count := range counts { |
| 215 | rowCount += count |
| 216 | } |
| 217 | committed = true |
| 218 | return nil |
| 219 | }); err != nil { |
| 220 | opts.LogTransactionControl(storepb.TaskRunLog_TransactionControl_ROLLBACK, "") |
| 221 | return 0, err |
| 222 | } |
| 223 | |
| 224 | if committed { |
| 225 | opts.LogTransactionControl(storepb.TaskRunLog_TransactionControl_COMMIT, "") |
| 226 | } |
| 227 | return rowCount, nil |
| 228 | } |
| 229 | |
| 230 | func (d *Driver) executeInAutoCommitMode(ctx context.Context, stmts []string, _ db.ExecuteOptions) (int64, error) { |
| 231 | var rowCount int64 |
no test coverage detected