planner: the recursive cte will make UPDATE's result wrong (#49400)

close pingcap/tidb#48969
This commit is contained in:
Yiding Cui
2023-12-13 21:16:49 +08:00
committed by GitHub
parent 09091124dd
commit 421aee147d
3 changed files with 40 additions and 0 deletions

View File

@ -7731,6 +7731,10 @@ func (b *PlanBuilder) buildRecursiveCTE(ctx context.Context, cte ast.ResultSetNo
// Build seed part plan.
saveSelect := x.SelectList.Selects
x.SelectList.Selects = x.SelectList.Selects[:i]
// We're rebuilding the seed part, so we pop the result we built previously.
for _i := 0; _i < i; _i++ {
b.handleHelper.popMap()
}
p, err = b.buildSetOpr(ctx, x)
if err != nil {
return err