-
Notifications
You must be signed in to change notification settings - Fork 4
/
tx.go
37 lines (31 loc) · 832 Bytes
/
tx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// mysqlx - MySQL driver for Go's database/sql package and MySQL X Protocol.
// Copyright (c) 2017-2018 Alexey Palazhchenko
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package mysqlx
import (
"context"
"database/sql/driver"
)
// tx represents transaction.
//
// It implements driver.Tx.
type tx struct {
c *conn
}
// Commit commits the transaction.
func (t *tx) Commit() error {
_, err := t.c.ExecContext(context.Background(), "COMMIT", nil)
return err
}
// Rollback aborts the transaction.
func (t *tx) Rollback() error {
_, err := t.c.ExecContext(context.Background(), "ROLLBACK", nil)
return err
}
// check interfaces
var (
_ driver.Tx = (*tx)(nil)
)