github.com/vescale/zgraph@v0.0.0-20230410094002-959c02d50f95/stmtctx/txn.go (about)

     1  package stmtctx
     2  
     3  import "github.com/vescale/zgraph/storage/kv"
     4  
     5  type (
     6  	txnStatus byte
     7  
     8  	LazyTxn struct {
     9  		sc         *Context
    10  		status     txnStatus
    11  		autocommit bool
    12  		txn        kv.Transaction
    13  	}
    14  )
    15  
    16  const (
    17  	txnStatusPending txnStatus = iota
    18  )
    19  
    20  // Txn returns the transaction object.
    21  func (sc *Context) Txn() *LazyTxn {
    22  	sc.mu.Lock()
    23  	defer sc.mu.Unlock()
    24  	if sc.mu.txn == nil {
    25  		sc.mu.txn = &LazyTxn{
    26  			sc: sc,
    27  		}
    28  	}
    29  	return sc.mu.txn
    30  }
    31  
    32  func (txn *LazyTxn) validOrPending() bool {
    33  	return false
    34  }