Don’t use readonly transactions for mysql

This commit is contained in:
Tobie Morgan Hitchcock 2018-02-11 16:43:59 +00:00
parent 5c18ee20a7
commit bb8c623f88

View file

@ -31,7 +31,7 @@ type DB struct {
func (db *DB) Begin(ctx context.Context, writable bool) (txn kvs.TX, err error) { func (db *DB) Begin(ctx context.Context, writable bool) (txn kvs.TX, err error) {
var pntr *sql.Tx var pntr *sql.Tx
if pntr, err = db.pntr.BeginTx(ctx, db.opt(writable)); err != nil { if pntr, err = db.pntr.BeginTx(ctx, &sql.TxOptions{}); err != nil {
log.WithPrefix("kvs").Errorln(err) log.WithPrefix("kvs").Errorln(err)
err = &kvs.DBError{Err: err} err = &kvs.DBError{Err: err}
return return
@ -50,9 +50,3 @@ func (db *DB) Export(w io.Writer) (err error) {
func (db *DB) Close() (err error) { func (db *DB) Close() (err error) {
return db.pntr.Close() return db.pntr.Close()
} }
func (db *DB) opt(writable bool) *sql.TxOptions {
return &sql.TxOptions{
ReadOnly: !writable,
}
}