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

planner: fix TiDB server panic when uses indexMerge with the virtual generated column (#17065) #17126

Merged
merged 4 commits into from
May 14, 2020
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
10 changes: 10 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6352,3 +6352,13 @@ func (s *testIntegrationSuite) TestIssue16505(c *C) {
tk.MustQuery("select /*+ IGNORE_INDEX(t, idx) */* from t where c;").Sort().Check(testkit.Rows("0.0001deadsfeww", "1", "123e456"))
tk.MustExec("drop table t;")
}

func (s *testIntegrationSuite) TestIssue17045(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int,b varchar(20),c datetime,d double,e int,f int as(a+b),key(a),key(b),key(c),key(d),key(e),key(f));")
tk.MustExec("insert into t(a,b,e) values(null,\"5\",null);")
tk.MustExec("insert into t(a,b,e) values(\"5\",null,null);")
tk.MustQuery("select /*+ use_index_merge(t)*/ * from t where t.e=5 or t.a=5;").Check(testkit.Rows("5 <nil> <nil> <nil> <nil> <nil>"))
}
1 change: 1 addition & 0 deletions planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ func (ds *DataSource) buildIndexMergeTableScan(prop *property.PhysicalProperty,
physicalTableID: ds.physicalTableID,
}.Init(ds.ctx, ds.blockOffset)
ts.SetSchema(ds.schema.Clone())
ts.Columns = ExpandVirtualColumn(ts.Columns, ts.schema, ts.Table.Columns)
if ts.Table.PKIsHandle {
if pkColInfo := ts.Table.GetPkColInfo(); pkColInfo != nil {
if ds.statisticTable.Columns[pkColInfo.ID] != nil {
Expand Down
4 changes: 4 additions & 0 deletions planner/core/resolve_indices.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ func (p *PhysicalIndexLookUpReader) ResolveIndices() (err error) {

// ResolveIndices implements Plan interface.
func (p *PhysicalIndexMergeReader) ResolveIndices() (err error) {
err = resolveIndicesForVirtualColumn(p.tablePlan.Schema().Columns, p.schema)
if err != nil {
return err
}
if p.tablePlan != nil {
err = p.tablePlan.ResolveIndices()
if err != nil {
Expand Down