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

expression: resize the result for IfXXSig #37417

Merged
merged 9 commits into from
Aug 29, 2022

Conversation

XuHuaiyu
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #37414

Problem Summary:
The IfXXSig.fallbackEvalXX forgets to resize the result, thus trigger the index out of range error.

What is changed and how it works?

Check List

Tests

  • Unit test

Side effects

N/A

Documentation

N/A

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@XuHuaiyu XuHuaiyu added type/bugfix This PR fixes a bug. sig/execution SIG execution needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. labels Aug 27, 2022
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 27, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • qw4990
  • wshwsh12

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-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 27, 2022
Copy link
Contributor

@fixdb fixdb left a comment

Choose a reason for hiding this comment

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

Will other expressions like case when have the same issue?

@fixdb
Copy link
Contributor

fixdb commented Aug 27, 2022

I am not able to reproduce the issue with case when though:

insert into foo select case when b>0 then  
  case when a/b>1 then  1 else  a/b end 
 else null end 
from bar;

I am not sure whether it doesn't have the issue or it just can't expose the issue.

tk.MustExec("create table foo(a decimal(65,0));")
tk.MustExec("create table bar(a decimal(65,0), b decimal(65,0));")
tk.MustExec("insert into bar values(0,0),(1,1),(2,2);")
tk.MustExec("insert into foo select if(b>0, if(a/b>1, 1, 2), null) from bar;")
Copy link
Contributor

Choose a reason for hiding this comment

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

How about adding ifNULL and CaseWhen cases?

@gengliqi
Copy link
Contributor

I am not able to reproduce the issue with case when though:

insert into foo select case when b>0 then  
  case when a/b>1 then  1 else  a/b end 
 else null end 
from bar;

I am not sure whether it doesn't have the issue or it just can't expose the issue.

case when doesn't have this issue. See line 67 in the below code.

func (b *builtinCaseWhen{{ .TypeName }}Sig) fallbackEval{{ .TypeName }}(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
{{- if .Fixed }}
result.Resize{{ .TypeNameInColumn }}(n, false)
x := result.{{ .TypeNameInColumn }}s()
for i := 0; i < n; i++ {

@XuHuaiyu
Copy link
Contributor Author

XuHuaiyu commented Aug 29, 2022

IfNull does not have this problem, neither.
result will be resized in line 271 when evaluating arg[0].VecEval.

func (b *builtinIfNull{{ .TypeName }}Sig) vecEval{{ .TypeName }}(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
{{- if .Fixed }}
if err := b.args[0].VecEval{{ .TypeName }}(b.ctx, input, result); err != nil {
return err
}
buf1, err := b.bufAllocator.get()
if err != nil {
return err
}

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 29, 2022
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 29, 2022
@wshwsh12
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: af1047f

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 29, 2022
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #37425

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 29, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.1 in PR #37426

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 29, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.2 in PR #37427

@ti-srebot
Copy link
Contributor

cherry pick to release-5.3 in PR #37428

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 29, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 29, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.4 in PR #37429

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 29, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-6.0 in PR #37430

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 29, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-6.1 in PR #37431

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 29, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-6.2 in PR #37432

@sre-bot
Copy link
Contributor

sre-bot commented Aug 29, 2022

TiDB MergeCI notify

🔴 Bad News! New failing [1] after this pr merged.
These new failed integration tests seem to be caused by the current PR, please try to fix these new failed integration tests, thanks!

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-ddl-test 🟥 failed 1, success 5, total 6 5 min 39 sec New failing
idc-jenkins-ci-tidb/common-test 🔴 failed 2, success 9, total 11 13 min Existing failure
idc-jenkins-ci-tidb/integration-common-test 🔴 failed 2, success 15, total 17 11 min Existing failure
idc-jenkins-ci/integration-cdc-test 🟢 all 36 tests passed 28 min Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 6 min 24 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 5 min 8 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 4 min 31 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 3 min 8 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 7 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.0 needs-cherry-pick-release-5.1 needs-cherry-pick-release-5.2 needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. release-note-none Denotes a PR that doesn't merit a release note. sig/execution SIG execution size/S Denotes a PR that changes 10-29 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Runtime error: index out of range [0] with length 0
9 participants