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: support PointGet plan when table has alias name #11270

Merged
merged 2 commits into from
Aug 7, 2019
Merged

planner: support PointGet plan when table has alias name #11270

merged 2 commits into from
Aug 7, 2019

Conversation

sduzh
Copy link
Contributor

@sduzh sduzh commented Jul 16, 2019

What problem does this PR solve?

fix #11149

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Side effects

  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to update the tidb-ansible repository
  • Need to be included in the release note

manual tests

mysql> create table t (a int not null, b int not null, c char(50) not null, primary key(a, b));
Query OK, 0 rows affected (0.01 sec)
mysql> explain select * from t where a = 1 and b = 1;
+-------------+-------+------+--------------------+
| id | count | task | operator info |
+-------------+-------+------+--------------------+
| Point_Get_1 | 1.00 | root | table:t, index:a b |
+-------------+-------+------+--------------------+
1 row in set (0.00 sec)
mysql> explain select * from t tmp where a = 1 and b = 1;
+-------------+-------+------+--------------------+
| id | count | task | operator info |
+-------------+-------+------+--------------------+
| Point_Get_1 | 1.00 | root | table:t, index:a b |
+-------------+-------+------+--------------------+
1 row in set (0.00 sec)
mysql> select tmp.a, tmp.b, tmp.c from t tmp where t.a = 1 and t.b = 1;
ERROR 1054 (42S22): Unknown column 't.a' in 'where clause'
mysql> select tmp.a, tmp.b, tmp.c from t tmp where tmp.a = 1 and tmp.b = 1;
Empty set (0.01 sec)

@codecov
Copy link

codecov bot commented Jul 16, 2019

Codecov Report

Merging #11270 into master will decrease coverage by 0.1285%.
The diff coverage is n/a.

@@               Coverage Diff                @@
##             master     #11270        +/-   ##
================================================
- Coverage   81.7927%   81.6642%   -0.1286%     
================================================
  Files           426        426                
  Lines         94380      93473       -907     
================================================
- Hits          77196      76334       -862     
- Misses        11785      11786         +1     
+ Partials       5399       5353        -46

@shenli shenli added the contribution This PR is from a community contributor. label Jul 16, 2019
@lzmhhh123 lzmhhh123 added sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement. labels Jul 16, 2019
@XuHuaiyu XuHuaiyu changed the title palnner: support PointGet plan when table has alias name (#11149) planner: support PointGet plan when table has alias name Jul 17, 2019
planner/core/point_get_plan.go Show resolved Hide resolved
executor/point_get_test.go Show resolved Hide resolved
executor/point_get_test.go Outdated Show resolved Hide resolved
executor/point_get_test.go Outdated Show resolved Hide resolved
@winoros
Copy link
Member

winoros commented Jul 17, 2019

@sduzh It should be planner instead of palnner.

planner/core/point_get_plan.go Outdated Show resolved Hide resolved
planner/core/point_get_plan.go Outdated Show resolved Hide resolved
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

@sre-bot
Copy link
Contributor

sre-bot commented Aug 3, 2019

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@zz-jason zz-jason added status/LGT1 Indicates that a PR has LGTM 1. status/PTAL labels Aug 3, 2019
@zz-jason zz-jason requested review from eurekaka and qw4990 August 3, 2019 07:54
@@ -334,36 +340,40 @@ func buildSchemaFromFields(ctx sessionctx.Context, dbName model.CIStr, tbl *mode
return schema
}

func getSingleTableName(tableRefs *ast.TableRefsClause) *ast.TableName {
// return the ast node of queried table name and the alias string.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please follow the comment convention, for example: comment starting with function name / variable name; capitalize first character of beginning word and add . in the end of sentences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

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

eurekaka commented Aug 7, 2019

/run-all-tests

@zz-jason zz-jason added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. status/PTAL labels Aug 7, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Aug 7, 2019

/run-all-tests

@sre-bot sre-bot merged commit 700bf2f into pingcap:master Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support PointGet plan when table has alias name
9 participants