Skip to content

Commit

Permalink
cherry pick pingcap#21188 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
7yyo authored and ti-srebot committed Nov 23, 2020
1 parent 3cfa1d4 commit 0b0ce1e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,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
11 changes: 11 additions & 0 deletions executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,24 @@ import (

// Error instances.
var (
<<<<<<< HEAD
ErrGetStartTS = terror.ClassExecutor.New(mysql.ErrGetStartTS, mysql.MySQLErrName[mysql.ErrGetStartTS])
ErrUnknownPlan = terror.ClassExecutor.New(mysql.ErrUnknownPlan, mysql.MySQLErrName[mysql.ErrUnknownPlan])
ErrPrepareMulti = terror.ClassExecutor.New(mysql.ErrPrepareMulti, mysql.MySQLErrName[mysql.ErrPrepareMulti])
ErrPrepareDDL = terror.ClassExecutor.New(mysql.ErrPrepareDDL, mysql.MySQLErrName[mysql.ErrPrepareDDL])
ErrResultIsEmpty = terror.ClassExecutor.New(mysql.ErrResultIsEmpty, mysql.MySQLErrName[mysql.ErrResultIsEmpty])
ErrBuildExecutor = terror.ClassExecutor.New(mysql.ErrBuildExecutor, mysql.MySQLErrName[mysql.ErrBuildExecutor])
ErrBatchInsertFail = terror.ClassExecutor.New(mysql.ErrBatchInsertFail, mysql.MySQLErrName[mysql.ErrBatchInsertFail])
=======
ErrGetStartTS = dbterror.ClassExecutor.NewStd(mysql.ErrGetStartTS)
ErrUnknownPlan = dbterror.ClassExecutor.NewStd(mysql.ErrUnknownPlan)
ErrPrepareMulti = dbterror.ClassExecutor.NewStd(mysql.ErrPrepareMulti)
ErrPrepareDDL = dbterror.ClassExecutor.NewStd(mysql.ErrPrepareDDL)
ErrResultIsEmpty = dbterror.ClassExecutor.NewStd(mysql.ErrResultIsEmpty)
ErrBuildExecutor = dbterror.ClassExecutor.NewStd(mysql.ErrBuildExecutor)
ErrBatchInsertFail = dbterror.ClassExecutor.NewStd(mysql.ErrBatchInsertFail)
ErrUnsupportedPs = dbterror.ClassExecutor.NewStd(mysql.ErrUnsupportedPs)
>>>>>>> 6910eae2a... executor: load data statement shoule not be prepared (#21188)

ErrCantCreateUserWithGrant = terror.ClassExecutor.New(mysql.ErrCantCreateUserWithGrant, mysql.MySQLErrName[mysql.ErrCantCreateUserWithGrant])
ErrPasswordNoMatch = terror.ClassExecutor.New(mysql.ErrPasswordNoMatch, mysql.MySQLErrName[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 @@ -5620,6 +5620,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, 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

0 comments on commit 0b0ce1e

Please sign in to comment.