github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/iface/txnif/consts.go (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package txnif 16 17 import "github.com/matrixorigin/matrixone/pkg/container/types" 18 19 var UncommitTS types.TS 20 21 func init() { 22 UncommitTS = types.MaxTs() 23 } 24 25 type TxnState int32 26 27 const ( 28 TxnStateActive TxnState = iota 29 TxnStatePreparing 30 //TxnStatePrepared only for 2PC 31 TxnStatePrepared 32 //TxnStateCommittingFinished only for 2PC txn runs on coordinator 33 TxnStateCommittingFinished 34 TxnStateRollbacking 35 //TxnStateCommitted , TxnStateRollbacked, and TxnStateUnknown are final states. 36 TxnStateCommitted 37 TxnStateRollbacked 38 TxnStateUnknown 39 ) 40 41 type TxnStatus int32 42 43 const ( 44 // TxnStatusActive TxnStatus = iota 45 // TxnStatusPrepared 46 // TxnStatusCommittingFinished 47 // TxnStatusCommitted 48 // TxnStatusRollbacked 49 ) 50 51 func TxnStrState(state TxnState) string { 52 switch state { 53 case TxnStateActive: 54 return "Active" 55 case TxnStatePreparing: 56 return "Preparing" 57 case TxnStatePrepared: 58 return "Prepared" 59 case TxnStateCommittingFinished: 60 return "CommittingFinished" 61 case TxnStateRollbacking: 62 return "Rollbacking" 63 case TxnStateCommitted: 64 return "Committed" 65 case TxnStateRollbacked: 66 return "Rollbacked" 67 case TxnStateUnknown: 68 return "Unknown" 69 } 70 panic("state not support") 71 }