Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: fix panic during update stmt #36230

Merged
merged 47 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5b0d1a2
fix and test
Yisaer Jul 15, 2022
dcec178
revise test
Yisaer Jul 15, 2022
dad8b64
address the comment
Yisaer Jul 20, 2022
43ac17d
Merge remote-tracking branch 'upstream/master' into fix_32311
Yisaer Jul 20, 2022
344fca1
address the comment
Yisaer Jul 20, 2022
040b3f4
revise test
Yisaer Jul 21, 2022
6b31c20
revise test
Yisaer Jul 21, 2022
b1370cd
revise test
Yisaer Jul 21, 2022
e424de1
Merge branch 'master' into fix_32311
Yisaer Jul 21, 2022
ca32ccd
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
7c5f9c1
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
057b0e3
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
5408a0c
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
e4d198e
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
69506ad
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
66cf21f
Merge branch 'master' into fix_32311
Yisaer Jul 21, 2022
093c21a
Merge branch 'master' into fix_32311
Yisaer Jul 21, 2022
b9725ae
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
0d3f445
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
42cad8b
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
bb55b9f
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
0ba0a94
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
e0f28df
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
abf148c
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
0e95485
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
21b7dea
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
f213c5e
Merge branch 'master' into fix_32311
ti-chi-bot Jul 21, 2022
8b7b8e8
Merge branch 'master' into fix_32311
ti-chi-bot Jul 22, 2022
331d5f9
Merge branch 'master' into fix_32311
Yisaer Jul 22, 2022
5f9784c
Merge branch 'master' into fix_32311
Yisaer Jul 22, 2022
87ad451
Merge branch 'master' into fix_32311
ti-chi-bot Jul 22, 2022
eb9060a
Merge branch 'master' into fix_32311
ti-chi-bot Jul 22, 2022
6d3f191
Merge branch 'master' into fix_32311
ti-chi-bot Jul 22, 2022
24b1203
Merge branch 'master' into fix_32311
ti-chi-bot Jul 22, 2022
5494c16
Merge branch 'master' into fix_32311
ti-chi-bot Jul 22, 2022
b4321f5
Merge branch 'master' into fix_32311
ti-chi-bot Jul 22, 2022
2a8ee3f
Merge branch 'master' into fix_32311
ti-chi-bot Jul 23, 2022
618e3ca
Merge branch 'master' into fix_32311
ti-chi-bot Jul 24, 2022
f73f53a
Merge branch 'master' into fix_32311
ti-chi-bot Jul 25, 2022
cf1c354
Merge branch 'master' into fix_32311
ti-chi-bot Jul 25, 2022
e652f6c
Merge branch 'master' into fix_32311
ti-chi-bot Jul 25, 2022
78653b3
Merge branch 'master' into fix_32311
ti-chi-bot Jul 25, 2022
469bec4
Merge branch 'master' into fix_32311
ti-chi-bot Jul 25, 2022
cd4d2d4
Merge branch 'master' into fix_32311
ti-chi-bot Jul 25, 2022
6dbcbe7
Merge branch 'master' into fix_32311
ti-chi-bot Jul 25, 2022
064670b
fix test
Yisaer Jul 25, 2022
cf4b60a
Merge branch 'master' into fix_32311
ti-chi-bot Jul 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,7 @@ func (b *executorBuilder) buildUpdate(v *plannercore.Update) Executor {
b.inUpdateStmt = true
tblID2table := make(map[int64]table.Table, len(v.TblColPosInfos))
multiUpdateOnSameTable := make(map[int64]bool)
failpoint.Inject("injectAlterTable", func() {})
for _, info := range v.TblColPosInfos {
tbl, _ := b.is.TableByID(info.TblID)
if _, ok := tblID2table[info.TblID]; ok {
Expand Down
25 changes: 25 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import (
"runtime"
"strconv"
"strings"
"sync"
"testing"
"time"

"github.com/golang/protobuf/proto"
"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/domain"
Expand Down Expand Up @@ -6071,3 +6073,26 @@ func TestIsFastPlan(t *testing.T) {
require.Equal(t, ca.isFastPlan, ok)
}
}

func TestUpdateStmtWhileSchemaChanged(t *testing.T) {
store, _, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int)")
tk.MustExec("insert into t(a,b) values(1,1), (3,3), (7,7)")
failpoint.Enable("github.com/pingcap/tidb/executor/injectAlterTable", `pause`)
wg := sync.WaitGroup{}
Yisaer marked this conversation as resolved.
Show resolved Hide resolved
go func() {
wg.Add(1)
tk2 := testkit.NewTestKit(t, store)
tk2.MustExec("use test")
tk2.MustExec("update t set a = 2 where b = 1;")
wg.Done()
}()
tk.MustExec("alter table t add column c int NOT NULL")
failpoint.Disable("github.com/pingcap/tidb/executor/injectAlterTable")
wg.Wait()
tk.MustQuery("select a,c from t where b = 1").Check(testkit.Rows("2 0"))
}
3 changes: 3 additions & 0 deletions planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5179,6 +5179,9 @@ func CheckUpdateList(assignFlags []int, updt *Update, newTblID2Table map[int64]t
}

for i, col := range tbl.WritableCols() {
if i >= len(flags) {
continue
}
if flags[i] < 0 {
continue
}
Expand Down