mirror of https://github.com/tikv/client-go.git
add a flag PreviousPresumeKNE (#581)
Signed-off-by: ekexium <eke@fastmail.com>
This commit is contained in:
parent
e425355a10
commit
f867f49845
|
|
@ -68,6 +68,15 @@ const (
|
||||||
// (a conflict check + a constraint check) in prewrite.
|
// (a conflict check + a constraint check) in prewrite.
|
||||||
flagNeedConstraintCheckInPrewrite
|
flagNeedConstraintCheckInPrewrite
|
||||||
|
|
||||||
|
// A PresumeKNE that should not be unset. It's used by lazy uniqueness checks. So that PresumeKNE flags in previous
|
||||||
|
// statement should not be mistakenly unset.
|
||||||
|
// It's only set when a stmt that sets PresumeKNE finishes.
|
||||||
|
// It's only read together with PresumeKNE
|
||||||
|
// It doesn't have to be persistent, since the only place where it is used is in statement retry where it helps set
|
||||||
|
// the correct assert_not_exist option. The life of the flag begins after stmt which sets the PresumeKNE flag, and
|
||||||
|
// ends when the lock is acquired.
|
||||||
|
flagPreviousPresumeKNE
|
||||||
|
|
||||||
persistentFlags = flagKeyLocked | flagKeyLockedValExist | flagNeedConstraintCheckInPrewrite
|
persistentFlags = flagKeyLocked | flagKeyLockedValExist | flagNeedConstraintCheckInPrewrite
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -93,7 +102,7 @@ func (f KeyFlags) HasAssertionFlags() bool {
|
||||||
|
|
||||||
// HasPresumeKeyNotExists returns whether the associated key use lazy check.
|
// HasPresumeKeyNotExists returns whether the associated key use lazy check.
|
||||||
func (f KeyFlags) HasPresumeKeyNotExists() bool {
|
func (f KeyFlags) HasPresumeKeyNotExists() bool {
|
||||||
return f&flagPresumeKNE != 0
|
return f&(flagPresumeKNE|flagPreviousPresumeKNE) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasLocked returns whether the associated key has acquired pessimistic lock.
|
// HasLocked returns whether the associated key has acquired pessimistic lock.
|
||||||
|
|
@ -194,6 +203,8 @@ func ApplyFlagsOps(origin KeyFlags, ops ...FlagsOp) KeyFlags {
|
||||||
origin |= flagNeedConstraintCheckInPrewrite
|
origin |= flagNeedConstraintCheckInPrewrite
|
||||||
case DelNeedConstraintCheckInPrewrite:
|
case DelNeedConstraintCheckInPrewrite:
|
||||||
origin &= ^flagNeedConstraintCheckInPrewrite
|
origin &= ^flagNeedConstraintCheckInPrewrite
|
||||||
|
case SetPreviousPresumeKNE:
|
||||||
|
origin |= flagPreviousPresumeKNE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return origin
|
return origin
|
||||||
|
|
@ -243,4 +254,6 @@ const (
|
||||||
// DelNeedConstraintCheckInPrewrite reverts SetNeedConstraintCheckInPrewrite. This is required when we decide to
|
// DelNeedConstraintCheckInPrewrite reverts SetNeedConstraintCheckInPrewrite. This is required when we decide to
|
||||||
// make up the pessimistic lock.
|
// make up the pessimistic lock.
|
||||||
DelNeedConstraintCheckInPrewrite
|
DelNeedConstraintCheckInPrewrite
|
||||||
|
// SetPreviousPresumeKNE sets flagPreviousPresumeKNE.
|
||||||
|
SetPreviousPresumeKNE
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue