Skip to content

Commit

Permalink
executor: load data statement shoule not be prepared (pingcap#21188) (p…
Browse files Browse the repository at this point in the history
…ingcap#21199)

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
ti-srebot authored and jackysp committed Nov 25, 2020
1 parent abc2543 commit ccca0f6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,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 = 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])
ErrUnsupportedPs = terror.ClassExecutor.New(mysql.ErrUnsupportedPs, mysql.MySQLErrName[mysql.ErrUnsupportedPs])

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 @@ -5514,6 +5514,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 ccca0f6

Please sign in to comment.