github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/sqlbase/locking.pb.go (about) 1 // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 // source: sql/sqlbase/locking.proto 3 4 package sqlbase 5 6 import proto "github.com/gogo/protobuf/proto" 7 import fmt "fmt" 8 import math "math" 9 10 // Reference imports to suppress errors if they are not otherwise used. 11 var _ = proto.Marshal 12 var _ = fmt.Errorf 13 var _ = math.Inf 14 15 // This is a compile-time assertion to ensure that this generated file 16 // is compatible with the proto package it is being compiled against. 17 // A compilation error at this line likely means your copy of the 18 // proto package needs to be updated. 19 const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package 20 21 // ScanLockingStrength controls the row-level locking mode used by scans. 22 // 23 // Typically, SQL scans read sequential keys from the key-value layer without 24 // acquiring any locks. This means that two scans by different transactions will 25 // not conflict and cause one of the two transactions to block the other. This 26 // is usually desirable, as it increases concurrency between readers. 27 // 28 // However, there are cases where a SQL scan would like to acquire locks on each 29 // of the keys that it reads to more carefully control concurrent access to the 30 // data that it reads. The prototypical example of this is a scan that is used 31 // to fetch the initial value of a row that its transction intends to later 32 // update. In this case, it would be beneficial to acquire a lock on the row 33 // during the initial scan instead of waiting until the mutation to acquire a 34 // lock. This prevents the row from being modified between the scan and the 35 // mutation. It also prevents situations that can lead to deadlocks. 36 // 37 // Locking modes have differing levels of strength, growing from "weakest" to 38 // "strongest" in the order that the variants are presented in the enumeration. 39 // The "stronger" a locking mode, the more protection it provides for the lock 40 // holder but the more restrictive it is to concurrent transactions attempting 41 // to access the same keys. 42 // 43 // The following matrix presents the compatibility of locking strengths with one 44 // another. 45 // 46 // +-------------------+---------------+-----------+-------------------+------------+ 47 // | | FOR_KEY_SHARE | FOR_SHARE | FOR_NO_KEY_UPDATE | FOR_UPDATE | 48 // +-------------------+---------------+-----------+-------------------+------------+ 49 // | FOR_KEY_SHARE | | | | X | 50 // +-------------------+---------------+-----------+-------------------+------------+ 51 // | FOR_SHARE | | | X | X | 52 // +-------------------+---------------+-----------+-------------------+------------+ 53 // | FOR_NO_KEY_UPDATE | | X | X | X | 54 // +-------------------+---------------+-----------+-------------------+------------+ 55 // | FOR_UPDATE | X | X | X | X | 56 // +-------------------+---------------+-----------+-------------------+------------+ 57 // 58 // A transaction can hold conflicting locks on the same row, but two different 59 // transactions can never hold conflicting locks on the same row. Once acquired, 60 // a lock is held until the end of the transaction. 61 type ScanLockingStrength int32 62 63 const ( 64 // FOR_NONE represents the default - no row-level locking. 65 ScanLockingStrength_FOR_NONE ScanLockingStrength = 0 66 // FOR_KEY_SHARE represents the FOR KEY SHARE row-level locking mode. 67 // 68 // The mode behaves similarly to FOR SHARE, except that the lock is weaker: 69 // SELECT FOR UPDATE is blocked, but not SELECT FOR NO KEY UPDATE. A 70 // key-shared lock blocks other transactions from performing DELETE or any 71 // UPDATE that changes the key values, but not other UPDATE, and neither does 72 // it prevent SELECT FOR NO KEY UPDATE, SELECT FOR SHARE, or SELECT FOR KEY 73 // SHARE. 74 // 75 // The locking mode was introduced into Postgres as an alternative to FOR 76 // SHARE to improve concurrency between foreign key validation scans, which 77 // acquire FOR KEY SHARE locks, and UPDATEs to existing rows, which acquire 78 // FOR NO KEY UPDATE locks. 79 // 80 // NOTE: FOR_KEY_SHARE is currently ignored. No locks are acquired. 81 ScanLockingStrength_FOR_KEY_SHARE ScanLockingStrength = 1 82 // FOR_SHARE represents the FOR SHARE row-level locking mode. 83 // 84 // The mode behaves similarly to FOR NO KEY UPDATE, except that it acquires a 85 // shared lock rather than exclusive lock on each retrieved row. A shared lock 86 // blocks other transactions from performing UPDATE, DELETE, SELECT FOR UPDATE 87 // or SELECT FOR NO KEY UPDATE on these rows, but it does not prevent them 88 // from performing SELECT FOR SHARE or SELECT FOR KEY SHARE. 89 // 90 // NOTE: FOR_SHARE is currently ignored. No locks are acquired. 91 ScanLockingStrength_FOR_SHARE ScanLockingStrength = 2 92 // FOR_NO_KEY_UPDATE represents the FOR NO KEY UPDATE row-level locking mode. 93 // 94 // The mode behaves similarly to FOR UPDATE, except that the lock acquired is 95 // weaker: this lock will not block SELECT FOR KEY SHARE commands that attempt 96 // to acquire a lock on the same rows. This lock mode is also acquired by any 97 // UPDATE that does not acquire a FOR UPDATE lock. 98 // 99 // The locking mode was introduced into Postgres as an alternative to FOR 100 // UDPATE to improve concurrency between foreign key validation scans, which 101 // acquire FOR KEY SHARE locks, and UPDATEs to existing rows, which acquire 102 // FOR NO KEY UPDATE locks. 103 // 104 // NOTE: FOR_NO_KEY_UPDATE is currently promoted to FOR_UPDATE. 105 ScanLockingStrength_FOR_NO_KEY_UPDATE ScanLockingStrength = 3 106 // FOR_UPDATE represents the FOR UPDATE row-level locking mode. 107 // 108 // The mode causes the rows retrieved by the scan to be locked as though for 109 // update. This prevents them from being locked, modified or deleted by other 110 // transactions until the current transaction ends. That is, other 111 // transactions that attempt UPDATE, DELETE, SELECT FOR UPDATE, SELECT FOR NO 112 // KEY UPDATE, SELECT FOR SHARE or SELECT FOR KEY SHARE of these rows will be 113 // blocked until the current transaction ends. Conversely, SELECT FOR UPDATE 114 // will wait for a concurrent transaction that has run any of those commands 115 // on the same row, and will then lock and return the updated row (or no row, 116 // if the row was deleted). 117 // 118 // NOTE: FOR_UPDATE is currently implemented by acquiring lock.Exclusive locks 119 // on each key scanned. 120 ScanLockingStrength_FOR_UPDATE ScanLockingStrength = 4 121 ) 122 123 var ScanLockingStrength_name = map[int32]string{ 124 0: "FOR_NONE", 125 1: "FOR_KEY_SHARE", 126 2: "FOR_SHARE", 127 3: "FOR_NO_KEY_UPDATE", 128 4: "FOR_UPDATE", 129 } 130 var ScanLockingStrength_value = map[string]int32{ 131 "FOR_NONE": 0, 132 "FOR_KEY_SHARE": 1, 133 "FOR_SHARE": 2, 134 "FOR_NO_KEY_UPDATE": 3, 135 "FOR_UPDATE": 4, 136 } 137 138 func (x ScanLockingStrength) Enum() *ScanLockingStrength { 139 p := new(ScanLockingStrength) 140 *p = x 141 return p 142 } 143 func (x ScanLockingStrength) String() string { 144 return proto.EnumName(ScanLockingStrength_name, int32(x)) 145 } 146 func (x *ScanLockingStrength) UnmarshalJSON(data []byte) error { 147 value, err := proto.UnmarshalJSONEnum(ScanLockingStrength_value, data, "ScanLockingStrength") 148 if err != nil { 149 return err 150 } 151 *x = ScanLockingStrength(value) 152 return nil 153 } 154 func (ScanLockingStrength) EnumDescriptor() ([]byte, []int) { 155 return fileDescriptor_locking_a0143576c841d13a, []int{0} 156 } 157 158 // ScanLockingWaitPolicy controls the policy used by scans for dealing with rows 159 // being locked by FOR UPDATE/SHARE clauses. 160 type ScanLockingWaitPolicy int32 161 162 const ( 163 // BLOCK represents the default - wait for the lock to become available. 164 ScanLockingWaitPolicy_BLOCK ScanLockingWaitPolicy = 0 165 // SKIP represents SKIP LOCKED - skip rows that can't be locked. 166 // 167 // NOTE: SKIP is not currently implemented and does not make it out of the SQL 168 // optimizer without throwing an error. 169 ScanLockingWaitPolicy_SKIP ScanLockingWaitPolicy = 1 170 // ERROR represents NOWAIT - raise an error if a row cannot be locked. 171 // 172 // NOTE: ERROR is not currently implemented and does not make it out of the 173 // SQL optimizer without throwing an error. 174 ScanLockingWaitPolicy_ERROR ScanLockingWaitPolicy = 2 175 ) 176 177 var ScanLockingWaitPolicy_name = map[int32]string{ 178 0: "BLOCK", 179 1: "SKIP", 180 2: "ERROR", 181 } 182 var ScanLockingWaitPolicy_value = map[string]int32{ 183 "BLOCK": 0, 184 "SKIP": 1, 185 "ERROR": 2, 186 } 187 188 func (x ScanLockingWaitPolicy) Enum() *ScanLockingWaitPolicy { 189 p := new(ScanLockingWaitPolicy) 190 *p = x 191 return p 192 } 193 func (x ScanLockingWaitPolicy) String() string { 194 return proto.EnumName(ScanLockingWaitPolicy_name, int32(x)) 195 } 196 func (x *ScanLockingWaitPolicy) UnmarshalJSON(data []byte) error { 197 value, err := proto.UnmarshalJSONEnum(ScanLockingWaitPolicy_value, data, "ScanLockingWaitPolicy") 198 if err != nil { 199 return err 200 } 201 *x = ScanLockingWaitPolicy(value) 202 return nil 203 } 204 func (ScanLockingWaitPolicy) EnumDescriptor() ([]byte, []int) { 205 return fileDescriptor_locking_a0143576c841d13a, []int{1} 206 } 207 208 func init() { 209 proto.RegisterEnum("cockroach.sql.sqlbase.ScanLockingStrength", ScanLockingStrength_name, ScanLockingStrength_value) 210 proto.RegisterEnum("cockroach.sql.sqlbase.ScanLockingWaitPolicy", ScanLockingWaitPolicy_name, ScanLockingWaitPolicy_value) 211 } 212 213 func init() { proto.RegisterFile("sql/sqlbase/locking.proto", fileDescriptor_locking_a0143576c841d13a) } 214 215 var fileDescriptor_locking_a0143576c841d13a = []byte{ 216 // 238 bytes of a gzipped FileDescriptorProto 217 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x2e, 0xcc, 0xd1, 218 0x2f, 0x2e, 0xcc, 0x49, 0x4a, 0x2c, 0x4e, 0xd5, 0xcf, 0xc9, 0x4f, 0xce, 0xce, 0xcc, 0x4b, 0xd7, 219 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x4d, 0xce, 0x4f, 0xce, 0x2e, 0xca, 0x4f, 0x4c, 0xce, 220 0xd0, 0x2b, 0x2e, 0xcc, 0xd1, 0x83, 0x2a, 0xd2, 0xca, 0xe1, 0x12, 0x0e, 0x4e, 0x4e, 0xcc, 0xf3, 221 0x81, 0xa8, 0x0d, 0x2e, 0x29, 0x4a, 0xcd, 0x4b, 0x2f, 0xc9, 0x10, 0xe2, 0xe1, 0xe2, 0x70, 0xf3, 222 0x0f, 0x8a, 0xf7, 0xf3, 0xf7, 0x73, 0x15, 0x60, 0x10, 0x12, 0xe4, 0xe2, 0x05, 0xf1, 0xbc, 0x5d, 223 0x23, 0xe3, 0x83, 0x3d, 0x1c, 0x83, 0x5c, 0x05, 0x18, 0x85, 0x78, 0xb9, 0x38, 0x41, 0x42, 0x10, 224 0x2e, 0x93, 0x90, 0x28, 0x97, 0x20, 0x44, 0x3d, 0x58, 0x51, 0x68, 0x80, 0x8b, 0x63, 0x88, 0xab, 225 0x00, 0xb3, 0x10, 0x1f, 0x17, 0x17, 0x48, 0x18, 0xca, 0x67, 0xd1, 0x32, 0xe7, 0x12, 0x45, 0xb2, 226 0x2d, 0x3c, 0x31, 0xb3, 0x24, 0x20, 0x3f, 0x27, 0x33, 0xb9, 0x52, 0x88, 0x93, 0x8b, 0xd5, 0xc9, 227 0xc7, 0xdf, 0xd9, 0x5b, 0x80, 0x41, 0x88, 0x83, 0x8b, 0x25, 0xd8, 0xdb, 0x33, 0x40, 0x80, 0x11, 228 0x24, 0xe8, 0x1a, 0x14, 0xe4, 0x1f, 0x24, 0xc0, 0xe4, 0xa4, 0x79, 0xe2, 0xa1, 0x1c, 0xc3, 0x89, 229 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0xde, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 230 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xc5, 0x0e, 0xf5, 231 0x11, 0x20, 0x00, 0x00, 0xff, 0xff, 0x5c, 0xc5, 0xee, 0xb0, 0x04, 0x01, 0x00, 0x00, 232 }