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 incorrect table name in explain information #11780

Merged
merged 2 commits into from
Aug 20, 2019

Conversation

foreyes
Copy link
Contributor

@foreyes foreyes commented Aug 19, 2019

What problem does this PR solve?

Fix #11782

What is changed and how it works?

Add necessary TableAsName field into PhysicalTableScan.
For case 1, add it in constructInnerIndexScanTask.
For case 2, add it in convertToIndexScan.

For case 3, this case happens because we set TableAsName after buildDataSource. In most cases it goes well, but when we need union scan, line 2348 will be triggered:

if txn.Valid() && !txn.IsReadOnly() && !isMemDB {
	us := LogicalUnionScan{handleCol: handleCol}.Init(b.ctx)
	us.SetChildren(ds)
	result = us
}

The return value is LogicalUnionScan instead of DataSource, so TableAsName will not be set in these lines of buildResultSetNode:

if v, ok := p.(*DataSource); ok {
	v.TableAsName = &x.AsName
}

So we can pass &x.AsName into buildDataSource, and set TableAsName in it.

Check List

Tests

  • Unit test
  • Explain test

Side effects

  • Change explain information in some cases.

@foreyes foreyes added type/enhancement The issue or PR belongs to an enhancement. status/WIP sig/planner SIG: Planner labels Aug 19, 2019
@codecov
Copy link

codecov bot commented Aug 19, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@2f95fae). Click here to learn what that means.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11780   +/-   ##
===========================================
  Coverage          ?   81.4916%           
===========================================
  Files             ?        434           
  Lines             ?      93644           
  Branches          ?          0           
===========================================
  Hits              ?      76312           
  Misses            ?      11872           
  Partials          ?       5460

@foreyes
Copy link
Contributor Author

foreyes commented Aug 19, 2019

/run-all-tests

@foreyes
Copy link
Contributor Author

foreyes commented Aug 19, 2019

/run-unit-test

@foreyes foreyes changed the title [WIP] planner: fix code & explain test planner: fix incorrect table name in explain information Aug 19, 2019
@foreyes
Copy link
Contributor Author

foreyes commented Aug 19, 2019

/run-all-tests

@foreyes foreyes self-assigned this Aug 19, 2019
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

@winoros winoros added status/all tests passed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 19, 2019
Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM.

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

sre-bot commented Aug 20, 2019

/run-all-tests

@sre-bot sre-bot merged commit bd33771 into pingcap:master Aug 20, 2019
@foreyes foreyes deleted the dev/fix_table_alias branch August 20, 2019 02:32
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/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table name is not correct when explaining execution plan
4 participants