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

plan: fix panic caused by empty schema of LogicalTableDual #7906

Merged
merged 8 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ func (b *PlanBuilder) buildDo(v *ast.DoStmt) (Plan, error) {
RetType: expr.GetType(),
})
}
//make dual schema if not
var _ = dual.Schema()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about directly set the schema of the dual operator, which eliminates the confusion:

dual.schema = expression.NewSchema()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks better

p.SetChildren(dual)
p.self = p
p.SetSchema(schema)
Expand Down
3 changes: 3 additions & 0 deletions planner/core/preprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ func (s *testValidatorSuite) TestValidator(c *C) {
{"select * from ( select 1 ) a, (select 2) b;", true, nil},
{"select * from (select * from ( select 1 ) a join (select 2) b) b join (select 3) a;", false, nil},
{"select * from (select 1 ) a , (select 2) b, (select * from (select 3) a join (select 4) b) c;", false, nil},

//issue 7833
{"drop view if exists v;", true, nil},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to add this test in TestColumnPruning.

Copy link
Contributor Author

@tianjiqx tianjiqx Oct 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I found that this test case can be passed here( planner/core/preprocess_test.go), and even without fixing the bug, I'm confused, maybe I don't fully understand the tidb test.

}

store, dom, err := newStoreWithBootstrap()
Expand Down