File tree Expand file tree Collapse file tree 2 files changed +11
-28
lines changed Expand file tree Collapse file tree 2 files changed +11
-28
lines changed Original file line number Diff line number Diff line change @@ -747,18 +747,19 @@ func (e *Engine) CloseSession(connID uint32) {
747747}
748748
749749func (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
Original file line number Diff line number Diff line change @@ -21,27 +21,9 @@ import (
2121// IsSessionAutocommit returns true if the current session is using implicit transaction management
2222// through autocommit.
2323func 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- }
You can’t perform that action at this time.
0 commit comments