From 6d7a32064159ab6924ef0d0d095933e80293b478 Mon Sep 17 00:00:00 2001 From: Chengpeng Yan <41809508+Reminiscent@users.noreply.github.com> Date: Mon, 29 Nov 2021 11:07:14 +0800 Subject: [PATCH] planner: do not add extra limit when handle the execute stmt (#30152) --- planner/core/common_plans.go | 2 +- planner/core/integration_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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) {