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

*: fix 'db' and 'Info' column of 'show processlist' #10985

Merged
merged 3 commits into from
Jul 1, 2019

Conversation

wshwsh12
Copy link
Contributor

What problem does this PR solve?

#10903
The Info column of show processlist should be NULL if it is not executing any statement.
The db column of show processlist should be NULL if it is not select one.

What is changed and how it works?

open 2 mysql client and run show processlist; both.

Before this pr:

mysql> show processlist;
+------+------+-----------+----+---------+------+-------+------------------+
| Id   | User | Host      | db | Command | Time | State | Info             |
+------+------+-----------+----+---------+------+-------+------------------+
|    2 | root | 127.0.0.1 |    | Query   |    0 | 2     | show processlist |
|    1 | root | 127.0.0.1 |    | Sleep   |   10 | 2     |                  |
+------+------+-----------+----+---------+------+-------+------------------+
2 rows in set (0.00 sec)

This pr:

mysql> show processlist;
+------+------+-----------+------+---------+------+-------+------------------+
| Id   | User | Host      | db   | Command | Time | State | Info             |
+------+------+-----------+------+---------+------+-------+------------------+
|    3 | root | 127.0.0.1 | NULL | Sleep   |    3 | 2     | NULL             |
|    4 | root | 127.0.0.1 | NULL | Query   |    0 | 2     | show processlist |
+------+------+-----------+------+---------+------+-------+------------------+
2 rows in set (0.01 sec)

Check List

Tests

  • Unit test
  • Manual test

Code changes

  • Has exported function/method change

Side effects

  • Increased code complexity

Related changes

@wshwsh12 wshwsh12 requested a review from XuHuaiyu June 28, 2019 11:29
@codecov
Copy link

codecov bot commented Jun 28, 2019

Codecov Report

Merging #10985 into master will decrease coverage by 0.0046%.
The diff coverage is 70%.

@@               Coverage Diff                @@
##             master     #10985        +/-   ##
================================================
- Coverage   80.9364%   80.9317%   -0.0047%     
================================================
  Files           418        418                
  Lines         89212      89227        +15     
================================================
+ Hits          72205      72213         +8     
- Misses        11777      11783         +6     
- Partials       5230       5231         +1

@codecov
Copy link

codecov bot commented Jun 28, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@1916eff). Click here to learn what that means.
The diff coverage is 70%.

@@             Coverage Diff             @@
##             master     #10985   +/-   ##
===========================================
  Coverage          ?   80.9615%           
===========================================
  Files             ?        418           
  Lines             ?      89256           
  Branches          ?          0           
===========================================
  Hits              ?      72263           
  Misses            ?      11756           
  Partials          ?       5237

@wshwsh12 wshwsh12 added the type/bugfix This PR fixes a bug. label Jun 30, 2019
@wshwsh12 wshwsh12 requested a review from zz-jason June 30, 2019 15:06
db = s.sessionVars.CurrentDB
}

var info interface{}
Copy link
Member

Choose a reason for hiding this comment

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

How about not changing the type of Info from string to interface{}. We can do it this way:

info := "NULL"
if len(sql) > 0 {
	info = sql
}

Copy link
Member

@zz-jason zz-jason Jul 1, 2019

Choose a reason for hiding this comment

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

Never mind. Could you add a test like:

select * from information_schema.processlist where db is null;
select * from information_schema.processlist where info is null;

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Jul 1, 2019

/run-all-tests

@wshwsh12 wshwsh12 added the sig/execution SIG execution label Jul 1, 2019
StmtCtx: tk.Se.GetSessionVars().StmtCtx,
}
tk.Se.SetSessionManager(sm)
tk.MustQuery("select * from information_schema.PROCESSLIST order by ID;").Sort().Check(
Copy link
Contributor

Choose a reason for hiding this comment

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

We've already used order by ID in the sql, thus the .Sort() is not needed.

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Jul 1, 2019

/run-all-tests

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Jul 1, 2019

/run-all-tests

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@XuHuaiyu XuHuaiyu added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 1, 2019
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 merged commit 1ddb317 into pingcap:master Jul 1, 2019
@zz-jason zz-jason added status/all tests passed status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 1, 2019
@zz-jason
Copy link
Member

zz-jason commented Jul 1, 2019

@wshwsh12 please cherry pick this commit to release-2.1 and release-3.0

@@ -26,12 +26,12 @@ type ProcessInfo struct {
ID uint64
User string
Host string
DB string
DB interface{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use interface{} here is a bad idea

Copy link
Member

Choose a reason for hiding this comment

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

Any better idea? @tiancaiamao

@wshwsh12 wshwsh12 deleted the myfeature branch April 21, 2020 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution 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.

5 participants