-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
82 additions
and
51 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
module github.com/DATA-DOG/go-txdb | ||
|
||
go 1.12 | ||
|
||
require ( | ||
github.com/go-sql-driver/mysql v1.4.1 | ||
github.com/lib/pq v1.1.1 | ||
google.golang.org/appengine v1.6.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package txdb | ||
|
||
import "fmt" | ||
|
||
// SavePoint defines the syntax to create savepoints | ||
// within transaction | ||
type SavePoint interface { | ||
Create(id string) string | ||
Release(id string) string | ||
Rollback(id string) string | ||
} | ||
|
||
type defaultSavePoint struct{} | ||
|
||
func (dsp *defaultSavePoint) Create(id string) string { | ||
return fmt.Sprintf("SAVEPOINT %s", id) | ||
} | ||
func (dsp *defaultSavePoint) Release(id string) string { | ||
return fmt.Sprintf("RELEASE SAVEPOINT %s", id) | ||
} | ||
func (dsp *defaultSavePoint) Rollback(id string) string { | ||
return fmt.Sprintf("ROLLBACK TO SAVEPOINT %s", id) | ||
} | ||
|
||
// SavePointOption allows to modify the logic for | ||
// transaction save points. In such cases if your driver | ||
// does not support it, use nil. If not compatible with default | ||
// use custom. | ||
func SavePointOption(savePoint SavePoint) func(*conn) error { | ||
return func(c *conn) error { | ||
c.savePoint = savePoint | ||
return nil | ||
} | ||
} |