diff --git a/executor/seqtest/prepared_test.go b/executor/seqtest/prepared_test.go index 11dae5e570767..2aee215d0f230 100644 --- a/executor/seqtest/prepared_test.go +++ b/executor/seqtest/prepared_test.go @@ -767,3 +767,22 @@ func TestPreparedIssue17419(t *testing.T) { // _, ok := tk1.Session().ShowProcess().Plan.(*plannercore.Execute) // require.True(t, ok) } + +func TestIssue38323(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") + tk.MustExec("drop table if exists t") + tk.MustExec("create table t(id int, k int);") + + tk.MustExec("prepare stmt from 'explain select * from t where id = ? and k = ? group by id, k';") + tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 skip plan-cache: not a SELECT/UPDATE/INSERT/DELETE/SET statement")) + tk.MustExec("set @a = 1;") + tk.MustExec("execute stmt using @a, @a") + tk.MustQuery("execute stmt using @a, @a").Check(tk.MustQuery("explain select * from t where id = 1 and k = 1 group by id, k").Rows()) + + tk.MustExec("prepare stmt from 'explain select * from t where ? = id and ? = k group by id, k';") + tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 skip plan-cache: not a SELECT/UPDATE/INSERT/DELETE/SET statement")) + tk.MustExec("set @a = 1;") + tk.MustQuery("execute stmt using @a, @a").Check(tk.MustQuery("explain select * from t where 1 = id and 1 = k group by id, k").Rows()) +} diff --git a/planner/core/point_get_plan.go b/planner/core/point_get_plan.go index de69438257f4e..48a35029a51b3 100644 --- a/planner/core/point_get_plan.go +++ b/planner/core/point_get_plan.go @@ -1354,7 +1354,7 @@ func getNameValuePairs(ctx sessionctx.Context, tbl *model.TableInfo, tblName mod case *driver.ValueExpr: d = x.Datum case *driver.ParamMarkerExpr: - con, err = expression.ParamMarkerExpression(ctx, x, true) + con, err = expression.ParamMarkerExpression(ctx, x, false) if err != nil { return nil, false } @@ -1368,7 +1368,7 @@ func getNameValuePairs(ctx sessionctx.Context, tbl *model.TableInfo, tblName mod case *driver.ValueExpr: d = x.Datum case *driver.ParamMarkerExpr: - con, err = expression.ParamMarkerExpression(ctx, x, true) + con, err = expression.ParamMarkerExpression(ctx, x, false) if err != nil { return nil, false }