diff --git a/executor/executor_test.go b/executor/executor_test.go index 85d0dad290bb0..422956d045abe 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -2114,6 +2114,8 @@ func TestIncorrectLimitArg(t *testing.T) { tk.MustGetErrMsg(`execute stmt1 using @a;`, `[planner:1210]Incorrect arguments to LIMIT`) tk.MustGetErrMsg(`execute stmt2 using @b, @a;`, `[planner:1210]Incorrect arguments to LIMIT`) + tk.MustGetErrMsg(`execute stmt2 using @a, @b;`, `[planner:1210]Incorrect arguments to LIMIT`) + tk.MustGetErrMsg(`execute stmt2 using @a, @a;`, `[planner:1210]Incorrect arguments to LIMIT`) } func TestExecutorLimit(t *testing.T) { diff --git a/executor/seqtest/prepared_test.go b/executor/seqtest/prepared_test.go index 5811a386f137d..3c0f180e54f22 100644 --- a/executor/seqtest/prepared_test.go +++ b/executor/seqtest/prepared_test.go @@ -826,6 +826,12 @@ func TestSetPlanCacheLimitSwitch(t *testing.T) { tk.MustExec("set @@global.tidb_enable_plan_cache_for_param_limit = ON;") tk.MustQuery("select @@global.tidb_enable_plan_cache_for_param_limit").Check(testkit.Rows("1")) + + tk.MustGetErrMsg("set @@global.tidb_enable_plan_cache_for_param_limit = '';", "[variable:1231]Variable 'tidb_enable_plan_cache_for_param_limit' can't be set to the value of ''") + tk.MustGetErrMsg("set @@global.tidb_enable_plan_cache_for_param_limit = 11;", "[variable:1231]Variable 'tidb_enable_plan_cache_for_param_limit' can't be set to the value of '11'") + tk.MustGetErrMsg("set @@global.tidb_enable_plan_cache_for_param_limit = enabled;", "[variable:1231]Variable 'tidb_enable_plan_cache_for_param_limit' can't be set to the value of 'enabled'") + tk.MustGetErrMsg("set @@global.tidb_enable_plan_cache_for_param_limit = disabled;", "[variable:1231]Variable 'tidb_enable_plan_cache_for_param_limit' can't be set to the value of 'disabled'") + tk.MustGetErrMsg("set @@global.tidb_enable_plan_cache_for_param_limit = open;", "[variable:1231]Variable 'tidb_enable_plan_cache_for_param_limit' can't be set to the value of 'open'") } func TestPlanCacheLimitSwitchEffective(t *testing.T) { diff --git a/planner/core/plan_cache_test.go b/planner/core/plan_cache_test.go index 9f8ff161fd658..e3a0d276e9815 100644 --- a/planner/core/plan_cache_test.go +++ b/planner/core/plan_cache_test.go @@ -469,6 +469,8 @@ func TestPlanCacheWithLimit(t *testing.T) { params []int }{ {"prepare stmt from 'select * from t limit ?'", []int{1}}, + {"prepare stmt from 'select * from t limit 1, ?'", []int{1}}, + {"prepare stmt from 'select * from t limit ?, 1'", []int{1}}, {"prepare stmt from 'select * from t limit ?, ?'", []int{1, 2}}, {"prepare stmt from 'delete from t order by a limit ?'", []int{1}}, {"prepare stmt from 'insert into t select * from t order by a desc limit ?'", []int{1}}, @@ -491,7 +493,8 @@ func TestPlanCacheWithLimit(t *testing.T) { tk.MustExec("execute stmt using " + strings.Join(using, ", ")) tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1")) - if idx < 6 { + if idx < 9 { + // none point get plan tk.MustExec("set @a0 = 6") tk.MustExec("execute stmt using " + strings.Join(using, ", ")) tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))