Skip to content

Commit

Permalink
refactor: multiupdate relation
Browse files Browse the repository at this point in the history
  • Loading branch information
huby2358 committed Feb 10, 2025
1 parent 0cf6f0d commit bb1fc7a
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions pkg/sql/colexec/multi_update/multi_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,22 @@ func (update *MultiUpdate) Prepare(proc *process.Process) error {

for _, updateCtx := range update.MultiUpdateCtx {
info := update.ctr.updateCtxInfos[updateCtx.TableDef.Name]
info.Sources = nil
if update.Action != UpdateWriteS3 {
rel, err := colexec.GetRelAndPartitionRelsByObjRef(proc.Ctx, proc, update.Engine, updateCtx.ObjRef)
if err != nil {
return err
if len(info.Sources) == 0 {
info.Sources = nil
rel, err := colexec.GetRelAndPartitionRelsByObjRef(proc.Ctx, proc, update.Engine, updateCtx.ObjRef)
if err != nil {
return err
}
info.Sources = append(info.Sources, rel)
} else {
for _, rel := range info.Sources {
err := rel.Reset(proc.GetTxnOperator())
if err != nil {
return err
}
}
}
info.Sources = append(info.Sources, rel)
}
}

Expand Down Expand Up @@ -377,13 +386,13 @@ func (update *MultiUpdate) resetMultiUpdateCtxs() {
func (update *MultiUpdate) resetMultiSources(proc *process.Process) error {
for _, updateCtx := range update.MultiUpdateCtx {
info := update.ctr.updateCtxInfos[updateCtx.TableDef.Name]
info.Sources = nil
if update.Action != UpdateWriteS3 {
rel, err := colexec.GetRelAndPartitionRelsByObjRef(proc.Ctx, proc, update.Engine, updateCtx.ObjRef)
if err != nil {
return err
for _, rel := range info.Sources {
err := rel.Reset(proc.GetTxnOperator())
if err != nil {
return err
}
}
info.Sources = append(info.Sources, rel)
}
}
return nil
Expand Down

0 comments on commit bb1fc7a

Please sign in to comment.