diff --git a/pkg/executor/select_into_test.go b/pkg/executor/select_into_test.go index 0737683fe1b44..0587c13d9711f 100644 --- a/pkg/executor/select_into_test.go +++ b/pkg/executor/select_into_test.go @@ -55,6 +55,18 @@ func TestSelectIntoFileExists(t *testing.T) { require.True(t, strings.Contains(err.Error(), outfile)) } +func TestSelectIntoOutfilePointGet(t *testing.T) { + outfile := randomSelectFilePath("TestSelectIntoOutfilePointGet") + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") + + tk.MustExec(`create table t (id int not null, primary key (id) /*T![clustered_index] CLUSTERED */ );`) + tk.MustExec(`insert into t values(1);`) + tk.MustExec(fmt.Sprintf("select * from t where id = 1 into outfile %q", outfile)) + cmpAndRm("1\n", outfile, t) +} + func TestSelectIntoOutfileTypes(t *testing.T) { outfile := randomSelectFilePath("TestSelectIntoOutfileTypes") store := testkit.CreateMockStore(t) diff --git a/pkg/planner/core/point_get_plan.go b/pkg/planner/core/point_get_plan.go index 26c71c3e0a2ef..6218296f08bc1 100644 --- a/pkg/planner/core/point_get_plan.go +++ b/pkg/planner/core/point_get_plan.go @@ -873,6 +873,9 @@ func TryFastPlan(ctx base.PlanContext, node ast.Node) (p base.Plan) { ctx.GetSessionVars().PlanColumnID.Store(0) switch x := node.(type) { case *ast.SelectStmt: + if x.SelectIntoOpt != nil { + return nil + } defer func() { vars := ctx.GetSessionVars() if vars.SelectLimit != math2.MaxUint64 && p != nil {