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

Resolve Undefined Flags Issue in slp diff Command #12

Merged
merged 2 commits into from
Dec 4, 2023

Conversation

shima004
Copy link
Contributor

@shima004 shima004 commented Nov 21, 2023

Overview

The slp diff command was throwing an error due to the undefined flags.

Description

go run ./cmd/slp/main.go diff ./example/slp-dump-1.yaml ./example/slp-dump-2.yaml
2023/11/21 19:49:16 flag accessed but not defined: sort
exit status 1
go run ./cmd/slp/main.go diff --help
Show the difference between the two profile results

Usage:
  slp diff <from> <to> [flags]

Flags:
  -h, --help   help for diff

Global Flags:
      --config string   The configuration file

Solution

  • Referencing 'cmd/slp/cmd/mysql.go', added flag definitions to 'cmd/slp/cmd/diff.go'.
  • Added simple tests to 'cmd/slp/cmd/diff_test.go'.

Result

 go run ./cmd/slp/main.go diff ./example/slp-dump-1.yaml ./example/slp-dump-2.yaml
+--------+---------------------------------+-------------------+-------------------+-------------------+-------------------+
| COUNT  |              QUERY              |  MIN(QUERYTIME)   |  MAX(QUERYTIME)   |  SUM(QUERYTIME)   |  AVG(QUERYTIME)   |
+--------+---------------------------------+-------------------+-------------------+-------------------+-------------------+
| 1      | DELETE FROM `t2` WHERE 'S'      | 0.369618          | 0.369618          | 0.369618          | 0.369618          |
|        | < `c1_date` OR `c2` NOT IN      |                   |                   |                   |                   |
|        | (SELECT `c3` FROM `t3`)         |                   |                   |                   |                   |
| 1      | DELETE FROM `t4` WHERE `c4`     | 3.148949 (-4.000) | 3.148949 (-4.000) | 3.148949 (-4.000) | 3.148949 (-4.000) |
|        | NOT IN (SELECT `c1` FROM `t1`)  |                   |                   |                   |                   |
| 1 (-1) | UPDATE `t1` SET                 | 6.504247 (+5.076) | 6.504247 (+3.000) | 6.504247 (+1.571) | 6.504247 (+4.038) |
|        | `c1_count`=(SELECT COUNT(N) AS  |                   |                   |                   |                   |
|        | `cnt` FROM `t2` WHERE `c3_id`   |                   |                   |                   |                   |
|        | = `t3`.`id`)                    |                   |                   |                   |                   |
| 1      | INSERT INTO `t2`                | 0.010498          | 0.010498          | 0.010498          | 0.010498          |
|        | (`c2_id`,`c2_string`,`c2_date`) |                   |                   |                   |                   |
|        | VALUES (N,'S','S')              |                   |                   |                   |                   |
| 1      | INSERT INTO `t2`                | 0.010498          | 0.010498          | 0.010498          | 0.010498          |
|        | (`c2_id`,`c2_string`,`c2_date`) |                   |                   |                   |                   |
|        | VALUES (N,'S','S'),(N,'S','S')  |                   |                   |                   |                   |
| 1      | SELECT * FROM `t5` WHERE        | 0.010753          | 0.010753          | 0.010753          | 0.010753          |
|        | `c5_id` IN ('S','S','S')        |                   |                   |                   |                   |
| 1      | SELECT `t1`.`id` FROM `t1`      | 0.020219          | 0.020219          | 0.020219          | 0.020219          |
|        | JOIN `t2` ON `t2`.`t1_id` =     |                   |                   |                   |                   |
|        | `t1`.`id` WHERE `t2`.`t1_id` =  |                   |                   |                   |                   |
|        | 'S' ORDER BY `t2`.`t1_id`       |                   |                   |                   |                   |
+--------+---------------------------------+-------------------+-------------------+-------------------+-------------------+
go run ./cmd/slp/main.go diff --help
Show the difference between the two profile results

Usage:
  slp diff <from> <to> [flags]

Flags:
      --format string            The output format (table, markdown, tsv, csv, html) (default "table")
      --sort string              Output the results in sorted order (default "count")
  -r, --reverse                  Sort results in reverse order
      --noheaders                Output no header line at all (only --format=tsv, csv)
      --show-footers             Output footer line at all (only --format=table, markdown)
      --limit int                The maximum number of results to display (default 5000)
  -o, --output string            Specifies the results to display, separated by commas (default "simple")
  -m, --matching-groups string   Specifies Query matching groups separated by commas
  -f, --filters string           Only the logs are profiled that match the conditions
      --percentiles string       Specifies the percentiles separated by commas
      --page int                 Number of pages of pagination (default 100)
      --bundle-where-in          Bundle WHERE IN conditions
      --bundle-values            Bundle VALUES of INSERT statement
  -a, --noabstract               Do not abstract all numbers to N and strings to 'S'
  -h, --help                     help for diff

Global Flags:
      --config string   The configuration file

Note to Reviewers

I haven't submitted many pull requests, so if there are any areas that need improvement or if I overlooked something, your feedback would be greatly appreciated. Thank you!

@tkuchiki
Copy link
Owner

tkuchiki commented Dec 4, 2023

@shima004 Thank you for fixing the issue, and I'm sorry for the late response.
LGTM, but I will check it on my local env, just in case.
So, just a moment, please.

Copy link
Owner

@tkuchiki tkuchiki left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@tkuchiki tkuchiki merged commit a743ab8 into tkuchiki:main Dec 4, 2023
1 check passed
@tkuchiki
Copy link
Owner

tkuchiki commented Dec 4, 2023

Released https://github.com/tkuchiki/slp/releases/tag/v0.2.1 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants