bindInfo: fix datarace on bindings (#40846)

close pingcap/tidb#40843
This commit is contained in:
Song Gao
2023-01-30 19:59:55 +08:00
committed by GitHub
parent 11839ac39e
commit 86a6694de0
3 changed files with 15 additions and 3 deletions

View File

@ -115,6 +115,17 @@ type BindRecord struct {
Bindings []Binding
}
// Copy get the copy of bindRecord
func (br *BindRecord) Copy() *BindRecord {
nbr := &BindRecord{
OriginalSQL: br.OriginalSQL,
Db: br.Db,
}
nbr.Bindings = make([]Binding, len(br.Bindings))
copy(nbr.Bindings, br.Bindings)
return nbr
}
// HasEnabledBinding checks if there are any enabled bindings in bind record.
func (br *BindRecord) HasEnabledBinding() bool {
for _, binding := range br.Bindings {