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: fix error PushDownNot for contiguous NOT #16108

Merged
merged 15 commits into from
Apr 15, 2020

Conversation

XuHuaiyu
Copy link
Contributor

@XuHuaiyu XuHuaiyu commented Apr 7, 2020

What problem does this PR solve?

Issue Number: close #15725

Problem Summary:
The issue exposes 2 problems:

  1. double negation is handled wrongly in PushDownNot. This problem only appears in release-3.0 and release-3.1 because of problem 2.

  2. If not appears even number of times in an expression tree, the not can not be eliminated successfully. (not not not not a) can be optimized to (not not a) here.

tidb> desc select * from t where (not not not not a)=a;
+-------------------------+---------+-----------+---------------+--------------------------------------------+
| id                      | estRows | task      | access object | operator info                              |
+-------------------------+---------+-----------+---------------+--------------------------------------------+
| TableReader_7           | 0.80    | root      |               | data:Selection_6                           |
| └─Selection_6           | 0.80    | cop[tikv] |               | eq(not(not(not(not(test.t.a)))), test.t.a) |
|   └─TableFullScan_5     | 1.00    | cop[tikv] | table:t       | keep order:false, stats:pseudo             |
+-------------------------+---------+-----------+---------------+--------------------------------------------+
3 rows in set (0.00 sec)

What is changed and how it works?

Proposal: xxx

What's Changed:
Do not eliminate the innermost NOT.

How it Works:

Related changes

N/A
I'll push specified PR to release branch.

Check List

Tests

  • Unit test
  • Integration test

Side effects

N/A

Release note

@XuHuaiyu XuHuaiyu requested review from winoros and lzmhhh123 April 7, 2020 08:34
@XuHuaiyu XuHuaiyu requested a review from a team as a code owner April 7, 2020 08:34
@ghost ghost requested review from SunRunAway and removed request for a team April 7, 2020 08:34
@codecov
Copy link

codecov bot commented Apr 7, 2020

Codecov Report

Merging #16108 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #16108   +/-   ##
===========================================
  Coverage   80.3807%   80.3807%           
===========================================
  Files           506        506           
  Lines        136514     136514           
===========================================
  Hits         109731     109731           
  Misses        18223      18223           
  Partials       8560       8560           

@XuHuaiyu
Copy link
Contributor Author

XuHuaiyu commented Apr 7, 2020

#16094 is the same bug-fix on release-3.0

Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

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

lgtm

expression/util.go Outdated Show resolved Hide resolved
@XuHuaiyu XuHuaiyu requested a review from a team as a code owner April 15, 2020 07:20
@ghost ghost removed their request for review April 15, 2020 07:21
@XuHuaiyu XuHuaiyu added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 15, 2020
expression/util.go Show resolved Hide resolved
expression/expression.go Show resolved Hide resolved
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
Copy link
Contributor

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 15, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Apr 15, 2020

/run-all-tests

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 15, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Apr 15, 2020

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Apr 15, 2020

@XuHuaiyu merge failed.

@XuHuaiyu
Copy link
Contributor Author

/run-all-tests

@XuHuaiyu
Copy link
Contributor Author

/run-integration-common-test
/run-common-test

@XuHuaiyu
Copy link
Contributor Author

/run-unit-test

@XuHuaiyu
Copy link
Contributor Author

unit-test fail because of #15979

@XuHuaiyu XuHuaiyu merged commit d26875d into pingcap:master Apr 15, 2020
@XuHuaiyu XuHuaiyu deleted the issue15725 branch April 15, 2020 09:52
sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 15, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Apr 15, 2020

cherry pick to release-4.0 in PR #16417

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression 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.

Double negation causes incorrect result
5 participants