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 point get null values #7790

Merged
merged 5 commits into from Sep 27, 2018

Conversation

@zz-jason
Copy link
Member

commented Sep 27, 2018

What problem does this PR solve?

Fix the "index out of range" panic caused by point getting all null values.

Let's say we have the following table:

drop table if exists t;
create table t(a bigint primary key, b bigint, c bigint);
insert into t values(1, NULL, NULL);

In master branch, the following query can reach a panic:

select * from t where a = 1;

This PR fixes the above problem.

What is changed and how it works?

if the length of the returned column values is smaller than the column offset, that indicates the value of that column is null or should be covered by the default value.

Check List

Tests

  • Unit test
zz-jason added 2 commits Sep 27, 2018
@zz-jason

This comment has been minimized.

Copy link
Member Author

commented Sep 27, 2018

@zz-jason

This comment has been minimized.

Copy link
Member Author

commented Sep 27, 2018

/run-all-tests

@coocood

This comment has been minimized.

Copy link
Member

commented Sep 27, 2018

@zz-jason
I think the way in mocktikv is easier to understand.
https://github.com/pingcap/tidb/blob/master/store/mockstore/mocktikv/executor.go#L633

Another approach is more safe which is to modify CutRowNew to always return row with the same length as colIDs, then we don't need to make the slice on the caller side.

Copy link
Contributor

left a comment

LGTM

@coocood

This comment has been minimized.

Copy link
Member

commented Sep 27, 2018

LGTM

@coocood

This comment has been minimized.

Copy link
Member

commented Sep 27, 2018

/run-all-tests

@XuHuaiyu XuHuaiyu added status/LGT2 and removed status/LGT1 labels Sep 27, 2018
@zz-jason zz-jason merged commit 86416be into pingcap:master Sep 27, 2018
4 checks passed
4 checks passed
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
@zz-jason zz-jason deleted the zz-jason:dev/fix-pointget branch Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.