Skip to content

executor: add syntax 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' to retrieve DDL commands within a certain range#36480

Merged
ti-chi-bot merged 12 commits into
pingcap:masterfrom
lyzx2001:issue36198-main
Jul 25, 2022
Merged

executor: add syntax 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' to retrieve DDL commands within a certain range#36480
ti-chi-bot merged 12 commits into
pingcap:masterfrom
lyzx2001:issue36198-main

Conversation

@lyzx2001
Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #36198

Problem Summary:
https://docs.pingcap.com/tidb/stable/sql-statement-admin-show-ddl#examples
Now the 'ADMIN SHOW DDL JOB QUERIES JOB_ID' command can only use JOB_ID to retrieve the last ten rows of DDL commands' content. Just like described in the website: 'You can only search the running DDL job corresponding to job_id within the last ten results in the DDL history job queue.'

Now I am adding a feature that the users can use commands like 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' to retrieve DDL commands' content within a certain range (n+1, n+m) that the users can assign themselves instead of only the last ten results.

What is changed and how it works?

Now the function can support 3 types of SQL commands, and the result examples can refer to:

mysql> ADMIN SHOW DDL JOB QUERIES LIMIT 3;  # Retrieve first 3 rows
+--------+------------------------------------------------------------------+
| JOB_ID | QUERY                                                            | 
+--------+------------------------------------------------------------------+
|     59 | ALTER TABLE t1 ADD INDEX index1 (col1)                           | 
|     60 | ALTER TABLE t2 ADD INDEX index1 (col1)                           | 
|     58 | CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY auto_increment)     | 
+--------+------------------------------------------------------------------+
3 rows in set (0.00 sec)
mysql> ADMIN SHOW DDL JOB QUERIES LIMIT 2, 3;  # Retrieve rows 3-5
+--------+------------------------------------------------------------------+
| JOB_ID | QUERY                                                            | 
+--------+------------------------------------------------------------------+
|     58 | CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY auto_increment)     | 
|     56 | CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY auto_increment)     | 
|     54 | DROP TABLE IF EXISTS t3                                          | 
+--------+------------------------------------------------------------------+
3 rows in set (0.00 sec)
mysql> ADMIN SHOW DDL JOB QUERIES LIMIT 3 OFFSET 2;  # Retrieve rows 3-5
+--------+------------------------------------------------------------------+
| JOB_ID | QUERY                                                            | 
+--------+------------------------------------------------------------------+
|     58 | CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY auto_increment)     | 
|     56 | CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY auto_increment)     | 
|     54 | DROP TABLE IF EXISTS t3                                          | 
+--------+------------------------------------------------------------------+
3 rows in set (0.00 sec)

The syntax strictly conforms to the SELECT statement in MySQL:
https://dev.mysql.com/doc/refman/8.0/en/select.html

The first step of solving this issue #36198 is to transfer SQL commands to AST, which has been proposed in another PR #36285, and has been merged into master.

This PR contains changes about using AST to build plan and executor. I constructed a new struct ShowDDLJobQueriesWithRange to store limit and offset, then use the function buildShowDDLJobQueriesWithRange() to pass these information into the executor ShowDDLJobQueriesWithRangeExec. Then I implemented the Open() and Next() function for ShowDDLJobQueriesWithRangeExec.

Unit tests for these syntax are also added.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Add syntax 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' to retrieve DDL commands' content within a certain range (n+1, n+m).

@ti-chi-bot
Copy link
Copy Markdown
Member

ti-chi-bot commented Jul 22, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Defined2014
  • xhebox

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Details

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 22, 2022
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 22, 2022
@lance6716
Copy link
Copy Markdown
Contributor

/cc @Defined2014 @xhebox

@ti-chi-bot ti-chi-bot requested review from Defined2014 and xhebox July 22, 2022 09:47
@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Jul 22, 2022

Copy link
Copy Markdown
Contributor

@Defined2014 Defined2014 left a comment

Choose a reason for hiding this comment

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

LGTM. The behavior is not the same as before,

You can only search the running DDL job corresponding to job_id within the last ten results in the DDL history job queue.

So, don't forget update docs.
https://docs.pingcap.com/zh/tidb/stable/sql-statement-admin-show-ddl

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 25, 2022
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 25, 2022
@xhebox
Copy link
Copy Markdown
Contributor

xhebox commented Jul 25, 2022

/merge

@ti-chi-bot
Copy link
Copy Markdown
Member

This pull request has been accepted and is ready to merge.

DetailsCommit hash: 5ae000f

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 25, 2022
@lyzx2001
Copy link
Copy Markdown
Contributor Author

LGTM. The behavior is not the same as before,

You can only search the running DDL job corresponding to job_id within the last ten results in the DDL history job queue.

So, don't forget update docs. https://docs.pingcap.com/zh/tidb/stable/sql-statement-admin-show-ddl

Copy that.

@ti-chi-bot ti-chi-bot merged commit c4c0665 into pingcap:master Jul 25, 2022
@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Jul 25, 2022

TiDB MergeCI notify

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-common-test 🟢 all 11 tests passed 47 min Existing passed
idc-jenkins-ci/integration-cdc-test 🟢 all 36 tests passed 36 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 12 tests passed 17 min Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 7 min 16 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 5 min 33 sec Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 5 min 24 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 4 min 34 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 13 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 2 min 43 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' to retrieve DDL commands' content within a certain range (n+1, n+m)

7 participants