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

parser: add support of 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' transferring to AST #36285

Merged
merged 12 commits into from
Jul 22, 2022

Conversation

lyzx2001
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #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.

This PR is the first step toward solving this issue. The details can refer to the following sections.

What is changed and how it works?

Now the function can support 3 types of SQL commands transferred to AST:

"admin show ddl job queries limit m" -> "ADMIN SHOW DDL JOB QUERIES LIMIT 0, m"
"admin show ddl job queries limit n, m" -> "ADMIN SHOW DDL JOB QUERIES LIMIT n, m"
"admin show ddl job queries limit m offset n" -> "ADMIN SHOW DDL JOB QUERIES LIMIT n, m"

where n and m are integers greater or equal to 0.

I wrote these syntaxes strictly according to MySQL's behavior, which can refer to https://dev.mysql.com/doc/refman/8.0/en/select.html

To support these three syntaxes, I constructed SelectStmtLimitSimple to implement corresponding restore functions. I also created a new struct LimitSimple to store Offset and Count (limit in SQL command).
SelectStmtLimitSimple and LimitSimple are just imitating SelectStmtLimit and Limit struct whose codes are right before them. The difference is I removed the forth option '"FETCH" FirstOrNext FetchFirstOpt RowOrRows "ONLY"' in SelectStmtLimitSimple, and changed the type LimitOption to Int64Num. I also initialized Offset to be 0, so that when an SQL command does not specify offset, the default output of offset would 0.
Then restore the commands to their corresponding forms. Pay attention to the order of offset and limit, which should conform to MySQL's syntax, and can be found in the link provided previously.

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

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 18, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bb7133
  • 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.

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-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 18, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jul 18, 2022

CLA assistant check
All committers have signed the CLA.

@sre-bot
Copy link
Contributor

sre-bot commented Jul 18, 2022

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what is changed

Or if the count of mainly changed packages are more than 3, use

  • *: what is changed

After you have format title, you can leave a comment /run-check_title to recheck it

@lyzx2001 lyzx2001 changed the title Add function that supports 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' transferred to AST parser: add support of 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' transferring to AST Jul 18, 2022
@lyzx2001
Copy link
Contributor Author

/run-check_title

@lance6716
Copy link
Contributor

/cc @bb7133

@ti-chi-bot ti-chi-bot requested a review from bb7133 July 19, 2022 04:03
Master was merged into branch issue36198, and issue36198 needs to be updated.
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 19, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jul 19, 2022

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

rest lgtm

parser/ast/misc.go Outdated Show resolved Hide resolved
parser/parser.y Outdated Show resolved Hide resolved
parser/ast/dml.go Outdated Show resolved Hide resolved
parser/parser.y Outdated Show resolved Hide resolved
parser/parser.y Outdated Show resolved Hide resolved
parser/ast/dml.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 19, 2022
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 21, 2022
Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@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 22, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2022
@lance6716
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 6fdb317

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 22, 2022
@ti-chi-bot ti-chi-bot merged commit eaead02 into pingcap:master Jul 22, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jul 22, 2022

TiDB MergeCI notify

🔴 Bad News! [1] CI still failing after this pr merged.
These failed integration tests don't seem to be introduced by the current PR.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-common-test 🔴 failed 1, success 10, total 11 1 hr 3 min Existing failure
idc-jenkins-ci/integration-cdc-test 🟢 all 36 tests passed 30 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 12 tests passed 19 min Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 7 min 53 sec Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 6 min 53 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 6 min 36 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 5 min 48 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 5 min 29 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 32 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

morgo added a commit to morgo/tidb that referenced this pull request Jul 22, 2022
…ip-init

* upstream/master: (125 commits)
  infoschema: fix PromQL for `tidb_distsql_copr_cache` (pingcap#36450)
  test: stabilize TestTopSQLCPUProfile (pingcap#36468)
  parser: add support of 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' transferring to AST (pingcap#36285)
  *: enable flaky test for all test (pingcap#36385)
  expression: fix return type of agg func `bit_or` when handling varbinary column (pingcap#36415)
  executor: fix aggregating enum zero value gets different results from mysql  (pingcap#36208)
  server: skip check tiflash version (pingcap#36451)
  *: Minor update to SECURITY.md to improved clarity (pingcap#36346)
  table partition: add telemetry for partition table (pingcap#36204)
  ddl: invalid multiple MAXVALUE partitions (pingcap#36329) (pingcap#36345)
  planner: Fixed `Merge` hint in nested CTE (pingcap#36432)
  metric: impove concurrency ddl metrics (pingcap#36405)
  planner: add more test cases for leading outer join (pingcap#36409)
  ddl: only set concurrent variable if no error (pingcap#36437)
  ddl: fix update panic in the middle of multi-schema change (pingcap#36421)
  session: Mising OptimizeWithPlanAndThenWarmUp in prepare-execute path (pingcap#36347)
  executor,metrics: add a metric for observing execution phases (pingcap#35906)
  br: unified docker image align with tidb (pingcap#36016)
  ddl: skip to close nil sessPool  (pingcap#36425)
  log-backup: remove the timezone from log-date (pingcap#36369)
  ...
morgo added a commit to morgo/tidb that referenced this pull request Jul 22, 2022
* upstream/master: (280 commits)
  infoschema: fix PromQL for `tidb_distsql_copr_cache` (pingcap#36450)
  test: stabilize TestTopSQLCPUProfile (pingcap#36468)
  parser: add support of 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' transferring to AST (pingcap#36285)
  *: enable flaky test for all test (pingcap#36385)
  expression: fix return type of agg func `bit_or` when handling varbinary column (pingcap#36415)
  executor: fix aggregating enum zero value gets different results from mysql  (pingcap#36208)
  server: skip check tiflash version (pingcap#36451)
  *: Minor update to SECURITY.md to improved clarity (pingcap#36346)
  table partition: add telemetry for partition table (pingcap#36204)
  ddl: invalid multiple MAXVALUE partitions (pingcap#36329) (pingcap#36345)
  planner: Fixed `Merge` hint in nested CTE (pingcap#36432)
  metric: impove concurrency ddl metrics (pingcap#36405)
  planner: add more test cases for leading outer join (pingcap#36409)
  ddl: only set concurrent variable if no error (pingcap#36437)
  ddl: fix update panic in the middle of multi-schema change (pingcap#36421)
  session: Mising OptimizeWithPlanAndThenWarmUp in prepare-execute path (pingcap#36347)
  executor,metrics: add a metric for observing execution phases (pingcap#35906)
  br: unified docker image align with tidb (pingcap#36016)
  ddl: skip to close nil sessPool  (pingcap#36425)
  log-backup: remove the timezone from log-date (pingcap#36369)
  ...
joycse06 added a commit to joycse06/tidb that referenced this pull request Jul 23, 2022
…rimary-key

* upstream/master: (104 commits)
  br: fix compatibility issue with concurrent ddl (pingcap#36474)
  infoschema: fix PromQL for `tidb_distsql_copr_cache` (pingcap#36450)
  test: stabilize TestTopSQLCPUProfile (pingcap#36468)
  parser: add support of 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' transferring to AST (pingcap#36285)
  *: enable flaky test for all test (pingcap#36385)
  expression: fix return type of agg func `bit_or` when handling varbinary column (pingcap#36415)
  executor: fix aggregating enum zero value gets different results from mysql  (pingcap#36208)
  server: skip check tiflash version (pingcap#36451)
  *: Minor update to SECURITY.md to improved clarity (pingcap#36346)
  table partition: add telemetry for partition table (pingcap#36204)
  ddl: invalid multiple MAXVALUE partitions (pingcap#36329) (pingcap#36345)
  planner: Fixed `Merge` hint in nested CTE (pingcap#36432)
  metric: impove concurrency ddl metrics (pingcap#36405)
  planner: add more test cases for leading outer join (pingcap#36409)
  ddl: only set concurrent variable if no error (pingcap#36437)
  ddl: fix update panic in the middle of multi-schema change (pingcap#36421)
  session: Mising OptimizeWithPlanAndThenWarmUp in prepare-execute path (pingcap#36347)
  executor,metrics: add a metric for observing execution phases (pingcap#35906)
  br: unified docker image align with tidb (pingcap#36016)
  ddl: skip to close nil sessPool  (pingcap#36425)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ 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.

8 participants