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

*: support `EXPLAIN FOR CONNECTION` #10030

Merged
merged 20 commits into from Apr 9, 2019

Conversation

Projects
None yet
5 participants
@erjiaqing
Copy link
Contributor

erjiaqing commented Apr 3, 2019

What problem does this PR solve?

Impl. #4351

What is changed and how it works?

  1. Add field Plan to ProcessInfo
  2. Add GetProcessInfo(uint64) (ProcessInfo, bool) to SessionManager
  3. Add buildExplainFor to PlanBuilder

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

EXPLAIN <format> FOR CONNECTION <connection id> is supported.

Differences with MySQL EXPLAIN FOR

  1. If one connection is sleeping, query for query plan for that connection will get nothing in MySQL. However, in this PR, query play for last query will be returned.
  2. Side effect of 1., EXPLAIN FOR CONNECTION <id of this connection> will get error in MySQL, but will get query plan of last query in this PR.
  3. If one without ProcessPriv queries plan for another user's connection, MySQL won't return error if that connection does not running any queries, however, in this PR, an error will always returns, even if that connection does not run any queries yet.
@zz-jason

This comment has been minimized.

Copy link
Member

zz-jason commented Apr 4, 2019

please remove session/test.txt from the patch

@codecov

This comment has been minimized.

Copy link

codecov bot commented Apr 4, 2019

Codecov Report

Merging #10030 into master will increase coverage by 0.0428%.
The diff coverage is 73.6842%.

@@               Coverage Diff                @@
##             master     #10030        +/-   ##
================================================
+ Coverage   78.0196%   78.0625%   +0.0428%     
================================================
  Files           404        404                
  Lines         81996      82024        +28     
================================================
+ Hits          63973      64030        +57     
+ Misses        13322      13301        -21     
+ Partials       4701       4693         -8
@zz-jason

This comment has been minimized.

Copy link
Member

zz-jason commented Apr 4, 2019

parser PR is merged, you can update to the latest paster version now.

@zz-jason zz-jason changed the title Support Explain Connection For Connection ID *: support `EXPLAIN FOR CONNECTION` Apr 4, 2019

Show resolved Hide resolved planner/core/planbuilder.go Outdated
Show resolved Hide resolved server/server.go Outdated

eurekaka and others added some commits Apr 4, 2019

Show resolved Hide resolved executor/explainfor_test.go Outdated

erjiaqing added some commits Apr 8, 2019

@eurekaka
Copy link
Contributor

eurekaka left a comment

LGTM

@eurekaka eurekaka added the status/LGT1 label Apr 8, 2019

@eurekaka eurekaka requested review from lamxTyler, zz-jason and winoros Apr 8, 2019

erjiaqing added some commits Apr 8, 2019

Show resolved Hide resolved planner/core/planbuilder.go Outdated
Show resolved Hide resolved planner/core/planbuilder.go
Show resolved Hide resolved planner/core/planbuilder.go Outdated
Show resolved Hide resolved planner/core/planbuilder.go Outdated
Show resolved Hide resolved planner/core/planbuilder.go Outdated
Show resolved Hide resolved server/server.go
Show resolved Hide resolved planner/core/planbuilder.go Outdated
@@ -136,6 +136,9 @@ var (
ErrWindowRangeBoundNotConstant = terror.ClassOptimizer.New(codeWindowRangeBoundNotConstant, mysql.MySQLErrName[mysql.ErrWindowRangeBoundNotConstant])
ErrWindowRowsIntervalUse = terror.ClassOptimizer.New(codeWindowRowsIntervalUse, mysql.MySQLErrName[mysql.ErrWindowRowsIntervalUse])
ErrWindowFunctionIgnoresFrame = terror.ClassOptimizer.New(codeWindowFunctionIgnoresFrame, mysql.MySQLErrName[mysql.ErrWindowFunctionIgnoresFrame])
ErrNoSuchThread = terror.ClassOptimizer.New(mysql.ErrNoSuchThread, mysql.MySQLErrName[mysql.ErrNoSuchThread])
// Since we cannot know if user loggined with a password, use message of ErrAccessDeniedNoPassword instead

This comment has been minimized.

Copy link
@winoros

winoros Apr 8, 2019

Member

It's not clear to understand. I think that put this comment to where the error is thrown will be better.

This comment has been minimized.

Copy link
@erjiaqing

erjiaqing Apr 8, 2019

Author Contributor

This comment explains why error code does not match error name, I think it will be more confusing if we put it to where it is thrown.

@zz-jason
Copy link
Member

zz-jason left a comment

LGTM

@zz-jason

This comment has been minimized.

Copy link
Member

zz-jason commented Apr 8, 2019

/run-all-tests

@zz-jason zz-jason merged commit 278c3e8 into pingcap:master Apr 9, 2019

6 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/code_coverage Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@erjiaqing erjiaqing deleted the erjiaqing:explain_connection branch Apr 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.