Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 committed Dec 12, 2023
1 parent 16e3bd3 commit dce7f57
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/planner/core/plan_cache_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ func GeneratePlanCacheStmtWithAST(ctx context.Context, sctx sessionctx.Context,
return nil, nil, 0, ErrPrepareDDL
}

switch paramStmt.(type) {
switch stmt := paramStmt.(type) {
case *ast.ImportIntoStmt, *ast.LoadDataStmt, *ast.PrepareStmt, *ast.ExecuteStmt, *ast.DeallocateStmt, *ast.NonTransactionalDMLStmt:
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 pkg/planner/core/plan_cacheable_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,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
1 change: 1 addition & 0 deletions text
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1

0 comments on commit dce7f57

Please sign in to comment.