Skip to content

Commit e48937b

Browse files
authored
disabling read-committed (#2733)
1 parent 2bf2c60 commit e48937b

File tree

2 files changed

+11
-28
lines changed

2 files changed

+11
-28
lines changed

engine.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -747,18 +747,19 @@ func (e *Engine) CloseSession(connID uint32) {
747747
}
748748

749749
func (e *Engine) beginTransaction(ctx *sql.Context) error {
750-
beginNewTransaction := ctx.GetTransaction() == nil || plan.ReadCommitted(ctx)
751-
if beginNewTransaction {
752-
ctx.GetLogger().Tracef("beginning new transaction")
753-
ts, ok := ctx.Session.(sql.TransactionSession)
754-
if ok {
755-
tx, err := ts.StartTransaction(ctx, sql.ReadWrite)
756-
if err != nil {
757-
return err
758-
}
750+
if ctx.GetTransaction() != nil {
751+
return nil
752+
}
759753

760-
ctx.SetTransaction(tx)
754+
ctx.GetLogger().Tracef("beginning new transaction")
755+
ts, ok := ctx.Session.(sql.TransactionSession)
756+
if ok {
757+
tx, err := ts.StartTransaction(ctx, sql.ReadWrite)
758+
if err != nil {
759+
return err
761760
}
761+
762+
ctx.SetTransaction(tx)
762763
}
763764

764765
return nil

sql/plan/transaction_committing_iter.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,9 @@ import (
2121
// IsSessionAutocommit returns true if the current session is using implicit transaction management
2222
// through autocommit.
2323
func IsSessionAutocommit(ctx *sql.Context) (bool, error) {
24-
if ReadCommitted(ctx) {
25-
return true, nil
26-
}
27-
2824
autoCommitSessionVar, err := ctx.GetSessionVariable(ctx, sql.AutoCommitSessionVar)
2925
if err != nil {
3026
return false, err
3127
}
3228
return sql.ConvertToBool(ctx, autoCommitSessionVar)
3329
}
34-
35-
func ReadCommitted(ctx *sql.Context) bool {
36-
val, err := ctx.GetSessionVariable(ctx, "transaction_isolation")
37-
if err != nil {
38-
return false
39-
}
40-
41-
valStr, ok := val.(string)
42-
if !ok {
43-
return false
44-
}
45-
46-
return valStr == "READ-COMMITTED"
47-
}

0 commit comments

Comments
 (0)