diff --git a/planner/core/common_plans.go b/planner/core/common_plans.go index 6419f4a04c19f..3cf7338b6940b 100644 --- a/planner/core/common_plans.go +++ b/planner/core/common_plans.go @@ -484,7 +484,7 @@ func (e *Execute) getPhysicalPlan(ctx context.Context, sctx sessionctx.Context, } REBUILD: - stmt := TryAddExtraLimit(sctx, prepared.Stmt) + stmt := prepared.Stmt p, names, err := OptimizeAstNode(ctx, sctx, stmt, is) if err != nil { return err diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 730e74e3a0372..351a20ba4c552 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -4759,6 +4759,15 @@ func (s *testIntegrationSuite) TestIssue27949(c *C) { " └─Limit 10.00 cop[tikv] offset:0, count:100", " └─Selection 10.00 cop[tikv] eq(test.t27949.b, 1)", " └─TableFullScan 10000.00 cop[tikv] table:t27949 keep order:false, stats:pseudo")) + + tk.MustExec("drop table if exists t") + tk.MustExec("create table t(a int, index idx_a(a));") + tk.MustExec("create binding for select * from t using select * from t use index(idx_a);") + tk.MustExec("select * from t;") + tk.MustQuery("select @@last_plan_from_binding;").Check(testkit.Rows("1")) + tk.MustExec("prepare stmt from 'select * from t';") + tk.MustExec("execute stmt;") + tk.MustQuery("select @@last_plan_from_binding;").Check(testkit.Rows("1")) } func (s *testIntegrationSuite) TestIssue28154(c *C) {