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

planner: fix row compare logic for ast.LE and ast.GE #8248

Merged
merged 3 commits into from
Nov 12, 2018
Merged

planner: fix row compare logic for ast.LE and ast.GE #8248

merged 3 commits into from
Nov 12, 2018

Conversation

imtbkcat
Copy link

@imtbkcat imtbkcat commented Nov 9, 2018

What problem does this PR solve?

Row compare logic fixed before in #8241 did not cover some case like <= and >=.
For example, in TiDB:

mysql> SELECT (1,2,3) <= (1+1,  NULL, 3);
+----------------------------+
| (1,2,3) <= (1+1,  NULL, 3) |
+----------------------------+
|                       NULL |
+----------------------------+

MySQL:

mysql> SELECT (1,2,3) <= (1+1,  NULL, 3);
+----------------------------+
| (1,2,3) <= (1+1,  NULL, 3) |
+----------------------------+
|                          1 |
+----------------------------+
1 row in set (0.00 sec)

What is changed and how it works?

Replace old compare logic of <= and >= operator with new compare logic.

Check List

Tests

  • Unit test
  • Manual test

Side effects

  • Possible performance regression

Related changes

  • Need to cherry-pick to the release branch

@imtbkcat imtbkcat added type/bugfix This PR fixes a bug. sig/planner SIG: Planner component/expression labels Nov 9, 2018
@imtbkcat imtbkcat requested review from zz-jason and XuHuaiyu November 9, 2018 07:04
@zz-jason
Copy link
Member

zz-jason commented Nov 9, 2018

LGTM

@zz-jason zz-jason added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 9, 2018
@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Nov 9, 2018

/run-all-tests tidb-test=pr/646

@winoros
Copy link
Member

winoros commented Nov 9, 2018

CI failed

@imtbkcat
Copy link
Author

imtbkcat commented Nov 9, 2018

/run-all-tests tidb-test=pr/646

expr1 = expression.NewFunctionInternal(er.ctx, ast.EQ, types.NewFieldType(mysql.TypeTiny), expr1, expression.Zero)
expr2 = expression.Zero
} else if op == ast.LT || op == ast.GT {
if op == ast.LT || op == ast.GT || op == ast.LE || op == ast.GE {
Copy link
Contributor

Choose a reason for hiding this comment

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

This check can be removed?

Copy link
Author

Choose a reason for hiding this comment

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

Is there any other operator?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not really sure about this.
But expr1 and expr2 will be used out of this check block,
if there are other operators, it may cause unexpected errors.
You may be better to confirm it.

Copy link
Author

Choose a reason for hiding this comment

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

ok

Copy link
Author

Choose a reason for hiding this comment

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

@XuHuaiyu addressed

@imtbkcat
Copy link
Author

imtbkcat commented Nov 9, 2018

/run-all-tests

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@XuHuaiyu
Copy link
Contributor

PTAL @zz-jason

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@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 Nov 12, 2018
@imtbkcat imtbkcat merged commit 011cdce into pingcap:master Nov 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression sig/planner SIG: Planner 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