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: add table info into context in fast plan case #11446

Merged
merged 4 commits into from
Jul 26, 2019

Conversation

sdojjy
Copy link
Member

@sdojjy sdojjy commented Jul 25, 2019

What problem does this PR solve?

We forgot to add table info into session context in fast-plan case, so the audit log plugin can know which tabled is affected by the user.

What is changed and how it works?

Add table info when building PointGetPlan

Check List

Tests

  • Manual test (add detailed scripts or steps below)

step1: build and run tidb with audit plugin enabled.
step2: config the audit plugin

insert into tidb_audit_table_access(user,db, tbl, access_type) values ("","","","");

step 4: run point get, point update, point delete query.
step 3: check if the audit log containers the table info

[2019/07/25 16:29:18.987 +08:00] [INFO] [logger.go:72] [ID="2019-07-25 16:29:18.987597 +0800 CST m=+77.675152289 0"] [TIMESTAMP=2019/07/25 16:29:18.987 +08:00] [EVENT_CLASS=TABLE_ACCESS] [EVENT_SUBCLASS=Delete] [STATUS_CODE=0] [COST_TIME=202.192] [HOST=127.0.0.1] [CLIENT_IP=127.0.0.1] [USER=root] [DATABASES="[test]"] [TABLES="[tidb]"] [SQL_TEXT="delete from tidb where variable_name = ?"] [ROWS=1] [CONNECTION_ID=1] [CLIENT_PORT=53306] [PID=38271] [COMMAND=Query] [SQL_STATEMENTS=Delete]
[2019/07/25 16:30:09.478 +08:00] [INFO] [logger.go:72] [ID="2019-07-25 16:30:09.478366 +0800 CST m=+128.166084074 0"] [TIMESTAMP=2019/07/25 16:30:09.478 +08:00] [EVENT_CLASS=TABLE_ACCESS] [EVENT_SUBCLASS=Update] [STATUS_CODE=0] [COST_TIME=176.159] [HOST=127.0.0.1] [CLIENT_IP=127.0.0.1] [USER=root] [DATABASES="[test]"] [TABLES="[tidb]"] [SQL_TEXT="update tidb set variable_value = ? where variable_name = ?"] [ROWS=0] [CONNECTION_ID=1] [CLIENT_PORT=53306] [PID=38271] [COMMAND=Query] [SQL_STATEMENTS=Update]
[2019/07/25 16:30:25.376 +08:00] [INFO] [logger.go:72] [ID="2019-07-25 16:30:25.376784 +0800 CST m=+144.064068460 0"] [TIMESTAMP=2019/07/25 16:30:25.376 +08:00] [EVENT_CLASS=TABLE_ACCESS] [EVENT_SUBCLASS=Select] [STATUS_CODE=0] [COST_TIME=181.647] [HOST=127.0.0.1] [CLIENT_IP=127.0.0.1] [USER=root] [DATABASES="[test]"] [TABLES="[tidb]"] [SQL_TEXT="select * from tidb where variable_name = ?"] [ROWS=0] [CONNECTION_ID=1] [CLIENT_PORT=53306] [PID=38271] [COMMAND=Query] [SQL_STATEMENTS=Select]

Code changes

  • Has exported function/method change
    no
  • Has exported variable/fields change
    no
  • Has interface methods change
    no
  • Has persistent data change
    no

Related changes

  • Need to cherry-pick to the release branch
    cherry-pick to release 2.1

@sdojjy sdojjy requested a review from lysu July 25, 2019 09:17
@codecov
Copy link

codecov bot commented Jul 25, 2019

Codecov Report

Merging #11446 into master will decrease coverage by 0.1341%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #11446        +/-   ##
================================================
- Coverage   81.4907%   81.3566%   -0.1342%     
================================================
  Files           424        424                
  Lines         92197      90815      -1382     
================================================
- Hits          75132      73884      -1248     
+ Misses        11743      11620       -123     
+ Partials       5322       5311        -11

@codecov
Copy link

codecov bot commented Jul 25, 2019

Codecov Report

Merging #11446 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11446   +/-   ##
===========================================
  Coverage   81.4095%   81.4095%           
===========================================
  Files           424        424           
  Lines         90923      90923           
===========================================
  Hits          74020      74020           
  Misses        11592      11592           
  Partials       5311       5311

@zz-jason
Copy link
Member

@sdojjy Please add a UT.

@zz-jason zz-jason added sig/planner SIG: Planner type/bugfix This PR fixes a bug. labels Jul 25, 2019
@zz-jason zz-jason requested a review from eurekaka July 25, 2019 10:44
@sdojjy
Copy link
Member Author

sdojjy commented Jul 25, 2019

@zz-jason OK, I will add a UT

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 the status/LGT1 Indicates that a PR has LGTM 1. label Jul 26, 2019
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
Copy link
Contributor

lysu commented Jul 26, 2019

/run-all-tests

@lysu lysu added status/LGT2 Indicates that a PR has LGTM 2. component/plugin and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 26, 2019
@zz-jason zz-jason merged commit 884371a into pingcap:master Jul 26, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Jul 26, 2019

cherry pick to release-2.1 in PR #11456

@sre-bot
Copy link
Contributor

sre-bot commented Jul 26, 2019

cherry pick to release-3.0 in PR #11457

sre-bot added a commit that referenced this pull request Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/plugin 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