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
close #42093
  • Loading branch information
qw4990 authored May 17, 2024
1 parent 2037a2f commit 2ef3ac9
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 @@ -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 {
Expand Down

0 comments on commit 2ef3ac9

Please sign in to comment.