forked from snowflakedb/gosnowflake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaction.go
35 lines (30 loc) · 757 Bytes
/
transaction.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
// Copyright (c) 2017-2022 Snowflake Computing Inc. All rights reserved.
package gosnowflake
import (
"database/sql/driver"
)
type snowflakeTx struct {
sc *snowflakeConn
}
func (tx *snowflakeTx) Commit() (err error) {
if tx.sc == nil || tx.sc.rest == nil {
return driver.ErrBadConn
}
_, err = tx.sc.exec(tx.sc.ctx, "COMMIT", false /* noResult */, false /* isInternal */, false /* describeOnly */, nil)
if err != nil {
return
}
tx.sc = nil
return
}
func (tx *snowflakeTx) Rollback() (err error) {
if tx.sc == nil || tx.sc.rest == nil {
return driver.ErrBadConn
}
_, err = tx.sc.exec(tx.sc.ctx, "ROLLBACK", false /* noResult */, false /* isInternal */, false /* describeOnly */, nil)
if err != nil {
return
}
tx.sc = nil
return
}