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: Error message is inconsistent with MySQL when execute insert into operationn #24938

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions executor/insert_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ func (e *InsertValues) getRow(ctx context.Context, vals []types.Datum) ([]types.
hasValue := make([]bool, len(e.Table.Cols()))
for i := 0; i < e.rowLen; i++ {
casted, err := table.CastValue(e.ctx, vals[i], e.insertColumns[i].ToInfo(), false, false)
if e.handleErr(nil, &vals[i], 0, err) != nil {
return nil, err
if er := e.handleErr(nil, &vals[i], 0, err); er != nil {
return nil, er
Comment on lines +521 to +522
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if er := e.handleErr(nil, &vals[i], 0, err); er != nil {
return nil, er
if err := e.handleErr(nil, &vals[i], 0, err); err != nil {
return nil, err

Is this PR ready for review?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tisonkun, Thanks for your attention, this problem is quite minor and bearable currently. so in the near future, i will pay no attention on it and it's still in draft.

}

offset := e.insertColumns[i].Offset
Expand Down
7 changes: 7 additions & 0 deletions executor/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ func (s *testSuite) TestInsert(c *C) {
tk.MustExec("insert into t(name, b) values(\"测试\", 3)")
_, err = tk.Exec("insert into t(name, b) values(\"测试\", 3)")
c.Assert(err.Error(), Equals, "[kv:1062]Duplicate entry '测试' for key 'PRIMARY'")

// issue 24927
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(c int)")
_, err = tk.Exec("insert into t select '1111111111111111111111111111'")
c.Assert(err, NotNil)
c.Assert(types.ErrWarnDataOutOfRange.Equal(err), IsTrue)
}

func (s *testSuiteP2) TestMultiBatch(c *C) {
Expand Down