github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/parsers/tree/select_lock.go (about) 1 // Copyright 2023 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 tree 16 17 // SelectLockType is the lock type for SelectStmt. 18 type SelectLockType int 19 20 // Select lock types. 21 const ( 22 SelectLockNone SelectLockType = iota 23 SelectLockForUpdate 24 SelectLockForShare 25 SelectLockForUpdateNoWait 26 SelectLockForUpdateWaitN 27 SelectLockForShareNoWait 28 SelectLockForUpdateSkipLocked 29 SelectLockForShareSkipLocked 30 ) 31 32 // String implements fmt.Stringer. 33 func (n SelectLockType) String() string { 34 switch n { 35 case SelectLockNone: 36 return "none" 37 case SelectLockForUpdate: 38 return "for update" 39 case SelectLockForShare: 40 return "for share" 41 case SelectLockForUpdateNoWait: 42 return "for update nowait" 43 case SelectLockForUpdateWaitN: 44 return "for update wait" 45 case SelectLockForShareNoWait: 46 return "for share nowait" 47 case SelectLockForUpdateSkipLocked: 48 return "for update skip locked" 49 case SelectLockForShareSkipLocked: 50 return "for share skip locked" 51 } 52 return "unsupported select lock type" 53 } 54 55 type SelectLockInfo struct { 56 LockType SelectLockType 57 WaitSec uint64 58 Tables []*TableName 59 } 60 61 func (node *SelectLockInfo) Format(ctx *FmtCtx) { 62 ctx.WriteString(node.LockType.String()) 63 }