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/core: fix a bug that check update privilege use wrong AsName and DBName #9003

Merged
merged 3 commits into from
Jan 10, 2019

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Fix issue #8911

What is changed and how it works?

The 'privilege check fail' comes from the wrong visitInfo which is collected from update tb_wehub_server a set a.active_count=a.active_count+1,a.used_count=a.used_count+1 where id=1

The correct visitInfo should be

{check=update, db=weperk, table=tb_wehub_server}
{check=select, db=weperk, table=tb_wehub_server}

but we get

{check=update, db=, table=tb_wehub_server}
{check=select, db=, table=a}
{check=select, db=weperk, table=a}
  • Check privilege should use table OrigName, instead of AsName
  • Some col.DBName is not set, it should be CurrentDB name

Check List

Tests

  • Unit test

Side effects

I find privilege check for OrigName is not a completely solved problem, some places may still use AsName.
I'll later go over the code and take a full check.

…` and DBName

* Fix issue 8911
* Check privilege should use table OrigName, instead of AsName
* Some col.DBName is not set,  it should be CurrentDB name
@codecov-io
Copy link

codecov-io commented Jan 10, 2019

Codecov Report

Merging #9003 into master will increase coverage by 0.01%.
The diff coverage is 90.9%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9003      +/-   ##
==========================================
+ Coverage   67.55%   67.57%   +0.01%     
==========================================
  Files         363      363              
  Lines       75338    75341       +3     
==========================================
+ Hits        50895    50911      +16     
+ Misses      19945    19939       -6     
+ Partials     4498     4491       -7
Impacted Files Coverage Δ
planner/core/logical_plan_builder.go 74.98% <90.9%> (+0.04%) ⬆️
expression/schema.go 94.11% <0%> (-0.85%) ⬇️
executor/distsql.go 72.53% <0%> (-0.47%) ⬇️
executor/join.go 78.7% <0%> (+0.4%) ⬆️
ddl/delete_range.go 78.85% <0%> (+4.57%) ⬆️
store/mockstore/mocktikv/pd.go 58.97% <0%> (+7.69%) ⬆️
util/systimemon/systime_mon.go 100% <0%> (+20%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 68ddb7f...b6226bd. Read the comment docs.

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 requested review from XuHuaiyu and alivxxx January 10, 2019 05:37
@zz-jason zz-jason added status/LGT1 Indicates that a PR has LGTM 1. type/bugfix This PR fixes a bug. sig/planner SIG: Planner labels Jan 10, 2019
@zz-jason
Copy link
Member

/run-all-tests

Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

LGTM

@lysu lysu added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 10, 2019
@ciscoxll
Copy link
Contributor

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/run-unit-test

@ngaut ngaut merged commit d6d9725 into pingcap:master Jan 10, 2019
@tiancaiamao tiancaiamao deleted the issue-8911 branch January 10, 2019 13:13
bb7133 added a commit to bb7133/tidb that referenced this pull request Apr 15, 2019
…` and DBName (pingcap#9003)

* Fix issue 8911
* Check privilege should use table OrigName, instead of AsName
zz-jason pushed a commit that referenced this pull request Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants