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: check schema when build table reader executor (#50425) #50561

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3466,6 +3466,10 @@
failpoint.Return(nil)
}
})
// https://github.com/pingcap/tidb/issues/50358
if len(v.Schema().Columns) == 0 && len(v.GetTablePlan().Schema().Columns) > 0 {
v.SetSchema(v.GetTablePlan().Schema())
}

Check warning on line 3472 in executor/builder.go

View check run for this annotation

Codecov / codecov/patch

executor/builder.go#L3471-L3472

Added lines #L3471 - L3472 were not covered by tests
if useMPPExecution(b.ctx, v) {
return b.buildMPPGather(v)
}
Expand Down
29 changes: 29 additions & 0 deletions executor/tiflashtest/tiflash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1348,3 +1348,32 @@ func TestMPPMemoryTracker(t *testing.T) {
require.NotNil(t, err)
require.True(t, strings.Contains(err.Error(), memory.PanicMemoryExceedWarnMsg+memory.WarnMsgSuffixForSingleQuery))
}

func TestIssue50358(t *testing.T) {
store := testkit.CreateMockStore(t, withMockTiFlash(1))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int not null primary key, b int not null)")
tk.MustExec("alter table t set tiflash replica 1")
tb := external.GetTableByName(t, tk, "test", "t")
err := domain.GetDomain(tk.Session()).DDL().UpdateTableReplicaInfo(tk.Session(), tb.Meta().ID, true)
require.NoError(t, err)
tk.MustExec("insert into t values(1,0)")
tk.MustExec("insert into t values(2,0)")

tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1(c int not null primary key)")
tk.MustExec("alter table t1 set tiflash replica 1")
tb = external.GetTableByName(t, tk, "test", "t1")
err = domain.GetDomain(tk.Session()).DDL().UpdateTableReplicaInfo(tk.Session(), tb.Meta().ID, true)
require.NoError(t, err)
tk.MustExec("insert into t1 values(3)")

tk.MustExec("set @@session.tidb_isolation_read_engines=\"tiflash\"")
tk.MustExec("set @@session.tidb_allow_mpp=ON")
for i := 0; i < 20; i++ {
// test if it is stable.
tk.MustQuery("select 8 from t join t1").Check(testkit.Rows("8", "8"))
}
}
Loading