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: fix runtime error when use on uplicate key update #29207

Closed
wants to merge 12 commits into from
Closed

executor: fix runtime error when use on uplicate key update #29207

wants to merge 12 commits into from

Conversation

Orion7r
Copy link

@Orion7r Orion7r commented Oct 28, 2021

What problem does this PR solve?

Issue Number: close #28078

What is changed and how it works?

When select is used in combination with on duplicate key update, there will be a runtime error problem, that is, slice bounds out of range, which is simply fixed here.

Release note

fix 'runtime error: slice bounds out of range' bug while using on diplicate key.

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 28, 2021
@CLAassistant
Copy link

CLAassistant commented Oct 28, 2021

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot
Copy link
Member

Welcome @Orion7r!

It looks like this is your first PR to pingcap/tidb 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tidb. 😃

@Orion7r
Copy link
Author

Orion7r commented Nov 29, 2021

/cc @AilinKid @guo-shaoge

@@ -359,7 +359,7 @@ func (e *InsertExec) initEvalBuffer4Dup() {
evalBufferTypes = append(evalBufferTypes, &col.FieldType)
}
if extraLen > 0 {
evalBufferTypes = append(evalBufferTypes, e.SelectExec.base().retFieldTypes[numWritableCols:]...)
evalBufferTypes = append(evalBufferTypes, e.SelectExec.base().retFieldTypes[0:]...)
Copy link
Collaborator

@guo-shaoge guo-shaoge Nov 30, 2021

Choose a reason for hiding this comment

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

  1. 0 is not reasonable here. IMHO, we should use e.rowLen
  2. We also have some problem in line 371, you can reproduce by using the following case. The second insertStmt doesn't work.
drop table if exists t1;
drop table if exists t2;
create table t1(c1 int, c2 int, c3 varchar(100), unique key(c3));
create table t2(c1 int);
insert into t2 values(1);
insert into t1(c3) select "abc" from t2 on duplicate key update t1.c3 = t2.c1;
insert into t1(c3) select "abc" from t2 on duplicate key update t1.c3 = t2.c1;

Copy link
Author

Choose a reason for hiding this comment

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

yes, you're right, but it shouldn't be e.rowlen either.
I will think about how to solve this problem.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Excuse me, but do we have any update yet?

@sre-bot
Copy link
Contributor

sre-bot commented Dec 27, 2021

@dianqihanwangzi
Copy link
Contributor

/run-check_dev_2

1 similar comment
@dianqihanwangzi
Copy link
Contributor

/run-check_dev_2

@MyonKeminta
Copy link
Contributor

Ping, @Orion7r are you going to continue fixing this issue? If you don't have time, we may have to try to fix it by ourselves and close this PR, since this issue is currently blocking.

@Orion7r
Copy link
Author

Orion7r commented Jan 4, 2022

Ping, @Orion7r are you going to continue fixing this issue? If you don't have time, we may have to try to fix it by ourselves and close this PR, since this issue is currently blocking.

sry,I have no time to continue this issue,maybe you can try to fix it. thanks.

@MyonKeminta
Copy link
Contributor

Thanks for your help.
We are going to fix it by #31287

@MyonKeminta MyonKeminta closed this Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slice bounds out of range error caused by using duplicate key
7 participants