Skip to content

Commit

Permalink
planner: skip fast-point-get for select-into-outfile statements (#53364
Browse files Browse the repository at this point in the history
…) (#53414)

close #42093
  • Loading branch information
ti-chi-bot authored May 21, 2024
1 parent 2c0e47b commit e20465b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/executor/select_into_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions pkg/planner/core/point_get_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,9 @@ func TryFastPlan(ctx sessionctx.Context, node ast.Node) (p 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 {
Expand Down

0 comments on commit e20465b

Please sign in to comment.