Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions sql/plan/transaction_committing_iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}