Skip to content

Commit

Permalink
planner: don't reset optFlag when build DataSource from View (#15547) (
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Mar 24, 2020
1 parent 31c7959 commit dbd6231
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,17 @@ func (s *testIntegrationSuite) TestTopNByConstFunc(c *C) {
"a",
))
}

func (s *testIntegrationSuite) TestIssue15546(c *C) {
tk := testkit.NewTestKit(c, s.store)

tk.MustExec("use test")
tk.MustExec("drop table if exists t, pt, vt")
tk.MustExec("create table t(a1 int, b1 int)")
tk.MustExec("insert into t values(1, 1)")
tk.MustExec("create table pt(a2 int primary key, b2 int) partition by range(a2) (" +
"PARTITION `p0` VALUES LESS THAN (10), PARTITION `p1` VALUES LESS THAN (20), PARTITION `p2` VALUES LESS THAN (30))")
tk.MustExec("insert into pt values(1, 1), (11, 11), (21, 21)")
tk.MustExec("create definer='root'@'localhost' view vt(a1, b1) as select a1, b1 from t")
tk.MustQuery("select * from pt, vt where a2 = a1").Check(testkit.Rows("1 1 1 1"))
}
2 changes: 1 addition & 1 deletion planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func NewPlanBuilder(sctx sessionctx.Context, is infoschema.InfoSchema, processor

// Build builds the ast node to a Plan.
func (b *PlanBuilder) Build(ctx context.Context, node ast.Node) (Plan, error) {
b.optFlag = flagPrunColumns
b.optFlag |= flagPrunColumns
switch x := node.(type) {
case *ast.AdminStmt:
return b.buildAdmin(ctx, x)
Expand Down

0 comments on commit dbd6231

Please sign in to comment.