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

plan: return table dual when filter is false/null #7756

Merged
merged 7 commits into from Sep 25, 2018

Conversation

@eurekaka
Copy link
Contributor

commented Sep 20, 2018

What problem does this PR solve?

Fix #7728

What is changed and how it works?

Add false/null check after constant propagation

Check List

Tests

  • Unit test
eurekaka added 4 commits Sep 9, 2018
Impose this check after constant propagation
@eurekaka

This comment has been minimized.

Copy link
Contributor Author

commented Sep 20, 2018

/run-all-tests

Copy link
Member

left a comment

lgtm

@winoros winoros added the status/LGT1 label Sep 21, 2018
@@ -34,6 +34,12 @@ func addSelection(p LogicalPlan, child LogicalPlan, conditions []expression.Expr
return
}
conditions = expression.PropagateConstant(p.context(), conditions)
// Return table dual when filter is constant false or null

This comment has been minimized.

Copy link
@XuHuaiyu

XuHuaiyu Sep 21, 2018

Contributor

add a . at the end of this comment.

@@ -55,6 +61,11 @@ func (p *LogicalSelection) PredicatePushDown(predicates []expression.Expression)
retConditions, child := p.children[0].PredicatePushDown(append(p.Conditions, predicates...))
if len(retConditions) > 0 {
p.Conditions = expression.PropagateConstant(p.ctx, retConditions)
// Return table dual when filter is constant false or null

This comment has been minimized.

Copy link
@XuHuaiyu

XuHuaiyu Sep 21, 2018

Contributor

ditto

@@ -375,3 +392,21 @@ func deriveOtherConditions(p *LogicalJoin, deriveLeft bool, deriveRight bool) (l
}
return
}

// conds2TableDual build a LogicalTableDual if cond is constant false or null

This comment has been minimized.

Copy link
@XuHuaiyu

XuHuaiyu Sep 21, 2018

Contributor

s/ build/ builds

return nil
}
sc := p.context().GetSessionVars().StmtCtx
if isTrue, err := con.Value.ToBool(sc); (err == nil && isTrue == 0) || con.Value.IsNull() {

This comment has been minimized.

Copy link
@XuHuaiyu

XuHuaiyu Sep 21, 2018

Contributor

Will it be possible that err != nil && con.Value.IsNull()

This comment has been minimized.

Copy link
@zz-jason

zz-jason Sep 24, 2018

Member

It is possible, but the constant is a NULL value, the err should be ignored.

Copy link
Member

left a comment

LGTM

@eurekaka eurekaka merged commit 0001d2a into pingcap:master Sep 25, 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
@eurekaka eurekaka deleted the eurekaka:join_2_dual branch Sep 25, 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.