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
Merged

Conversation

zz-jason
Copy link
Member

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 zz-jason added type/bugfix This PR fixes a bug. sig/execution SIG execution labels Sep 27, 2018
@zz-jason
Copy link
Member Author

@XuHuaiyu @coocood PTAL

@zz-jason
Copy link
Member Author

/run-all-tests

@coocood
Copy link
Member

coocood 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

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 27, 2018
@coocood
Copy link
Member

coocood commented Sep 27, 2018

LGTM

@coocood
Copy link
Member

coocood commented Sep 27, 2018

/run-all-tests

@XuHuaiyu XuHuaiyu added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 27, 2018
@zz-jason zz-jason merged commit 86416be into pingcap:master Sep 27, 2018
@zz-jason zz-jason deleted the dev/fix-pointget branch September 27, 2018 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution 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.

4 participants