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 error when select view_name.col_name from view_name(#14314) #15573

Merged
merged 2 commits into from
Mar 24, 2020

Conversation

XuHuaiyu
Copy link
Contributor

cherry-pick #14314

What problem does this PR solve?

Before this commit:

tidb> create table t(a int);
Query OK, 0 rows affected (0.01 sec)
tidb> create view v as select * from t;
Query OK, 0 rows affected (0.01 sec)
tidb> desc select v.a from v;
ERROR 1054 (42S22): Unknown column 'v.a' in 'field list'

What is changed and how it works?

We build a projection upon the underlying select when execute select from a view.
The output name of the built projection should be view_name.col_name instead of underlying_table_name.col_name.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

N/A

Related changes

  • Need to cherry-pick to the release branch
    release-3.0, release-3.1

Release note

Fix an error when executing SQL like select view_name.col_name from view_name.

@XuHuaiyu XuHuaiyu added type/bugfix This PR fixes a bug. sig/planner SIG: Planner labels Mar 23, 2020
@XuHuaiyu XuHuaiyu requested review from winoros and eurekaka March 23, 2020 06:21
Copy link
Member

@francis0407 francis0407 left a comment

Choose a reason for hiding this comment

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

LGTM

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/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. labels Mar 24, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Mar 24, 2020

/run-all-tests

@sre-bot sre-bot merged commit f3de03d into pingcap:release-3.1 Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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/bugfix This PR fixes a bug. type/3.1-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants