Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: load data statement shoule not be prepared #21188

Merged
merged 6 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ error = '''
Deadlock found when trying to get lock; try restarting transaction
'''

["executor:1295"]
error = '''
This command is not supported in the prepared statement protocol yet
'''

["executor:1317"]
error = '''
Query execution was interrupted
Expand Down
1 change: 1 addition & 0 deletions executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
ErrResultIsEmpty = dbterror.ClassExecutor.NewStd(mysql.ErrResultIsEmpty)
ErrBuildExecutor = dbterror.ClassExecutor.NewStd(mysql.ErrBuildExecutor)
ErrBatchInsertFail = dbterror.ClassExecutor.NewStd(mysql.ErrBatchInsertFail)
ErrUnsupportedPs = dbterror.ClassExecutor.NewStd(mysql.ErrUnsupportedPs)

ErrCantCreateUserWithGrant = dbterror.ClassExecutor.NewStd(mysql.ErrCantCreateUserWithGrant)
ErrPasswordNoMatch = dbterror.ClassExecutor.NewStd(mysql.ErrPasswordNoMatch)
Expand Down
5 changes: 5 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5933,6 +5933,11 @@ func (s *testClusterTableSuite) TearDownSuite(c *C) {
s.testSuiteWithCliBase.TearDownSuite(c)
}

func (s *testSuiteP1) TestPrepareLoadData(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustGetErrCode(`prepare stmt from "load data local infile '/tmp/load_data_test.csv' into table test";`, mysql.ErrUnsupportedPs)
}

func (s *testClusterTableSuite) TestSlowQuery(c *C) {
writeFile := func(file string, data string) {
f, err := os.OpenFile(file, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
Expand Down
4 changes: 4 additions & 0 deletions executor/prepared.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ func (e *PrepareExec) Next(ctx context.Context, req *chunk.Chunk) error {
return ErrPrepareDDL
}

if _, ok := stmt.(*ast.LoadDataStmt); ok {
return ErrUnsupportedPs
}

// Prepare parameters should NOT over 2 bytes(MaxUint16)
// https://dev.mysql.com/doc/internals/en/com-stmt-prepare-response.html#packet-COM_STMT_PREPARE_OK.
if len(extractor.markers) > math.MaxUint16 {
Expand Down