diff --git a/engine.go b/engine.go index 97eb28772a..3317c4cb46 100644 --- a/engine.go +++ b/engine.go @@ -747,18 +747,19 @@ func (e *Engine) CloseSession(connID uint32) { } func (e *Engine) beginTransaction(ctx *sql.Context) error { - beginNewTransaction := ctx.GetTransaction() == nil || plan.ReadCommitted(ctx) - if beginNewTransaction { - ctx.GetLogger().Tracef("beginning new transaction") - ts, ok := ctx.Session.(sql.TransactionSession) - if ok { - tx, err := ts.StartTransaction(ctx, sql.ReadWrite) - if err != nil { - return err - } + if ctx.GetTransaction() != nil { + return nil + } - ctx.SetTransaction(tx) + ctx.GetLogger().Tracef("beginning new transaction") + ts, ok := ctx.Session.(sql.TransactionSession) + if ok { + tx, err := ts.StartTransaction(ctx, sql.ReadWrite) + if err != nil { + return err } + + ctx.SetTransaction(tx) } return nil diff --git a/sql/plan/transaction_committing_iter.go b/sql/plan/transaction_committing_iter.go index 6e540b80a0..0ac2cf9818 100644 --- a/sql/plan/transaction_committing_iter.go +++ b/sql/plan/transaction_committing_iter.go @@ -21,27 +21,9 @@ import ( // IsSessionAutocommit returns true if the current session is using implicit transaction management // through autocommit. func IsSessionAutocommit(ctx *sql.Context) (bool, error) { - if ReadCommitted(ctx) { - return true, nil - } - autoCommitSessionVar, err := ctx.GetSessionVariable(ctx, sql.AutoCommitSessionVar) if err != nil { return false, err } return sql.ConvertToBool(ctx, autoCommitSessionVar) } - -func ReadCommitted(ctx *sql.Context) bool { - val, err := ctx.GetSessionVariable(ctx, "transaction_isolation") - if err != nil { - return false - } - - valStr, ok := val.(string) - if !ok { - return false - } - - return valStr == "READ-COMMITTED" -}