Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#49357
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
qw4990 authored and ti-chi-bot committed Dec 12, 2023
1 parent 266d8f7 commit 41ff7b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions planner/core/plan_cache_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,18 @@ func GeneratePlanCacheStmtWithAST(ctx context.Context, sctx sessionctx.Context,
return nil, nil, 0, ErrPrepareDDL
}

<<<<<<< HEAD:planner/core/plan_cache_utils.go
switch paramStmt.(type) {
case *ast.LoadDataStmt, *ast.PrepareStmt, *ast.ExecuteStmt, *ast.DeallocateStmt, *ast.NonTransactionalDMLStmt:
=======
switch stmt := paramStmt.(type) {
case *ast.ImportIntoStmt, *ast.LoadDataStmt, *ast.PrepareStmt, *ast.ExecuteStmt, *ast.DeallocateStmt, *ast.NonTransactionalDMLStmt:
>>>>>>> cf23666766d (planner: return an error when using prepared protocol with select-into statement (#49357)):pkg/planner/core/plan_cache_utils.go
return nil, nil, 0, ErrUnsupportedPs
case *ast.SelectStmt:
if stmt.SelectIntoOpt != nil {
return nil, nil, 0, ErrUnsupportedPs
}
}

// Prepare parameters should NOT over 2 bytes(MaxUint16)
Expand Down
8 changes: 8 additions & 0 deletions planner/core/plan_cacheable_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ func TestCacheable(t *testing.T) {
require.True(t, core.Cacheable(stmt, is))
}

func TestIssue49166(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`create table t (c int)`)
tk.MustContainErrMsg(`prepare stmt from "select c from t limit 1 into outfile 'text'"`, "This command is not supported in the prepared statement protocol yet")
}

func TestNonPreparedPlanCacheable(t *testing.T) {
store := testkit.CreateMockStore(t)

Expand Down

0 comments on commit 41ff7b5

Please sign in to comment.