From a0bb84a29e94135fa57d3cdef32c240826b30d71 Mon Sep 17 00:00:00 2001 From: lyzx2001 Date: Tue, 26 Jul 2022 20:58:03 +0800 Subject: [PATCH 1/4] Add new syntax 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' close https://github.com/pingcap/docs/issues/9698 Add syntax 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n', which can retrieve DDL commands' content within a certain range (n+1, n+m). --- .../sql-statement-admin-show-ddl.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/sql-statements/sql-statement-admin-show-ddl.md b/sql-statements/sql-statement-admin-show-ddl.md index 9ee2518c61e27..a2cb916ec45cb 100644 --- a/sql-statements/sql-statement-admin-show-ddl.md +++ b/sql-statements/sql-statement-admin-show-ddl.md @@ -113,6 +113,56 @@ mysql> ADMIN SHOW DDL JOB QUERIES 51; You can only search the running DDL job corresponding to `job_id` within the last ten results in the DDL history job queue. +### `ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n` + + To view the original SQL statements of the DDL job within a specified range `(n+1, n+m)` corresponding to `job_id`, use `ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n`: + + {{< copyable "sql" >}} + + ```sql + ADMIN SHOW DDL JOB QUERIES LIMIT 3; # Retrieve first 3 rows + ADMIN SHOW DDL JOB QUERIES LIMIT 2, 3; # Retrieve rows 3-5 + ADMIN SHOW DDL JOB QUERIES LIMIT 3 OFFSET 2; # Retrieve rows 3-5 + ``` + + ```sql + 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) + ``` + + ```sql + 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) + ``` + + ```sql + 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) + ``` + + You can search the running DDL job corresponding to `job_id` within a arbitrarily specified range of results in the DDL history job queue. This syntax does not have the limitation of the last ten results of `ADMIN SHOW DDL JOB QUERIES`. + ## MySQL compatibility This statement is a TiDB extension to MySQL syntax. From 63dfe7cdbed6e5b8ef775d021b85b40f7905ce90 Mon Sep 17 00:00:00 2001 From: lyzx2001 Date: Wed, 27 Jul 2022 12:15:54 +0800 Subject: [PATCH 2/4] Update sql-statement-admin-show-ddl.md --- .../sql-statement-admin-show-ddl.md | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/sql-statements/sql-statement-admin-show-ddl.md b/sql-statements/sql-statement-admin-show-ddl.md index a2cb916ec45cb..6d4b22fb94647 100644 --- a/sql-statements/sql-statement-admin-show-ddl.md +++ b/sql-statements/sql-statement-admin-show-ddl.md @@ -11,7 +11,7 @@ The `ADMIN SHOW DDL [JOBS|JOB QUERIES]` statement shows information about runnin ```ebnf+diagram AdminStmt ::= - 'ADMIN' ( 'SHOW' ( 'DDL' ( 'JOBS' Int64Num? WhereClauseOptional | 'JOB' 'QUERIES' NumList )? | TableName 'NEXT_ROW_ID' | 'SLOW' AdminShowSlow ) | 'CHECK' ( 'TABLE' TableNameList | 'INDEX' TableName Identifier ( HandleRange ( ',' HandleRange )* )? ) | 'RECOVER' 'INDEX' TableName Identifier | 'CLEANUP' ( 'INDEX' TableName Identifier | 'TABLE' 'LOCK' TableNameList ) | 'CHECKSUM' 'TABLE' TableNameList | 'CANCEL' 'DDL' 'JOBS' NumList | 'RELOAD' ( 'EXPR_PUSHDOWN_BLACKLIST' | 'OPT_RULE_BLACKLIST' | 'BINDINGS' ) | 'PLUGINS' ( 'ENABLE' | 'DISABLE' ) PluginNameList | 'REPAIR' 'TABLE' TableName CreateTableStmt | ( 'FLUSH' | 'CAPTURE' | 'EVOLVE' ) 'BINDINGS' ) + 'ADMIN' ( 'SHOW' ( 'DDL' ( 'JOBS' Int64Num? WhereClauseOptional | 'JOB' 'QUERIES' NumList | 'JOB' 'QUERIES' 'LIMIT' m 'OFFSET' n )? | TableName 'NEXT_ROW_ID' | 'SLOW' AdminShowSlow ) | 'CHECK' ( 'TABLE' TableNameList | 'INDEX' TableName Identifier ( HandleRange ( ',' HandleRange )* )? ) | 'RECOVER' 'INDEX' TableName Identifier | 'CLEANUP' ( 'INDEX' TableName Identifier | 'TABLE' 'LOCK' TableNameList ) | 'CHECKSUM' 'TABLE' TableNameList | 'CANCEL' 'DDL' 'JOBS' NumList | 'RELOAD' ( 'EXPR_PUSHDOWN_BLACKLIST' | 'OPT_RULE_BLACKLIST' | 'BINDINGS' ) | 'PLUGINS' ( 'ENABLE' | 'DISABLE' ) PluginNameList | 'REPAIR' 'TABLE' TableName CreateTableStmt | ( 'FLUSH' | 'CAPTURE' | 'EVOLVE' ) 'BINDINGS' ) NumList ::= Int64Num ( ',' Int64Num )* @@ -115,22 +115,23 @@ You can only search the running DDL job corresponding to `job_id` within the las ### `ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n` - To view the original SQL statements of the DDL job within a specified range `(n+1, n+m)` corresponding to `job_id`, use `ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n`: + To view the original SQL statements of the DDL job within a specified range `[n+1, n+m]` corresponding to `job_id`, use `ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n`: {{< copyable "sql" >}} - ```sql - ADMIN SHOW DDL JOB QUERIES LIMIT 3; # Retrieve first 3 rows - ADMIN SHOW DDL JOB QUERIES LIMIT 2, 3; # Retrieve rows 3-5 - ADMIN SHOW DDL JOB QUERIES LIMIT 3 OFFSET 2; # Retrieve rows 3-5 +```sql + ADMIN SHOW DDL JOB QUERIES LIMIT m; # Retrieve first m rows + ADMIN SHOW DDL JOB QUERIES LIMIT n, m; # Retrieve rows [n+1, n+m] + ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n; # Retrieve rows [n+1, n+m] ``` + where n and m are integers greater or equal to 0. ```sql ADMIN SHOW DDL JOB QUERIES LIMIT 3; # Retrieve first 3 rows +--------+--------------------------------------------------------------+ | JOB_ID | QUERY | +--------+--------------------------------------------------------------+ - | 59 | ALTER TABLE t1 ADD INDEX index1 (col1) | + | 59 | ALTER TABLE t1 ADD INDEX index2 (col2) | | 60 | ALTER TABLE t2 ADD INDEX index1 (col1) | | 58 | CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY auto_increment) | +--------+--------------------------------------------------------------+ @@ -138,26 +139,25 @@ You can only search the running DDL job corresponding to `job_id` within the las ``` ```sql - 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 | - +--------+--------------------------------------------------------------+ + ADMIN SHOW DDL JOB QUERIES LIMIT 6, 2; # Retrieve rows 7-8 + +--------+----------------------------------------------------------------------------+ + | JOB_ID | QUERY | + +--------+----------------------------------------------------------------------------+ + | 52 | ALTER TABLE t1 ADD INDEX index1 (col1) | + | 51 | CREATE TABLE IF NOT EXISTS t1 (id INT NOT NULL PRIMARY KEY auto_increment) | + +--------+----------------------------------------------------------------------------+ 3 rows in set (0.00 sec) ``` ```sql - 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 | - +--------+--------------------------------------------------------------+ + ADMIN SHOW DDL JOB QUERIES LIMIT 3 OFFSET 4; # Retrieve rows 5-7 + +--------+----------------------------------------+ + | JOB_ID | QUERY | + +--------+----------------------------------------+ + | 54 | DROP TABLE IF EXISTS t3 | + | 53 | ALTER TABLE t1 DROP INDEX index1 | + | 52 | ALTER TABLE t1 ADD INDEX index1 (col1) | + +--------+----------------------------------------+ 3 rows in set (0.00 sec) ``` From 13253ae40e063328c0b36470c9a97876f4ae4e72 Mon Sep 17 00:00:00 2001 From: lyzx2001 Date: Wed, 27 Jul 2022 13:03:32 +0800 Subject: [PATCH 3/4] Update sql-statement-admin-show-ddl.md --- sql-statements/sql-statement-admin-show-ddl.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sql-statements/sql-statement-admin-show-ddl.md b/sql-statements/sql-statement-admin-show-ddl.md index 6d4b22fb94647..d927b1d296078 100644 --- a/sql-statements/sql-statement-admin-show-ddl.md +++ b/sql-statements/sql-statement-admin-show-ddl.md @@ -124,6 +124,7 @@ You can only search the running DDL job corresponding to `job_id` within the las ADMIN SHOW DDL JOB QUERIES LIMIT n, m; # Retrieve rows [n+1, n+m] ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n; # Retrieve rows [n+1, n+m] ``` + where n and m are integers greater or equal to 0. ```sql From 5f2e7241a601ec4aef22dd93fc355957d4f3eede Mon Sep 17 00:00:00 2001 From: shichun-0415 <89768198+shichun-0415@users.noreply.github.com> Date: Thu, 16 Feb 2023 20:05:56 +0800 Subject: [PATCH 4/4] Apply suggestions from code review --- sql-statements/sql-statement-admin-show-ddl.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-admin-show-ddl.md b/sql-statements/sql-statement-admin-show-ddl.md index d927b1d296078..ac0ed77c28abf 100644 --- a/sql-statements/sql-statement-admin-show-ddl.md +++ b/sql-statements/sql-statement-admin-show-ddl.md @@ -125,7 +125,7 @@ You can only search the running DDL job corresponding to `job_id` within the las ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n; # Retrieve rows [n+1, n+m] ``` - where n and m are integers greater or equal to 0. + where `n` and `m` are integers greater or equal to 0. ```sql ADMIN SHOW DDL JOB QUERIES LIMIT 3; # Retrieve first 3 rows @@ -162,7 +162,7 @@ You can only search the running DDL job corresponding to `job_id` within the las 3 rows in set (0.00 sec) ``` - You can search the running DDL job corresponding to `job_id` within a arbitrarily specified range of results in the DDL history job queue. This syntax does not have the limitation of the last ten results of `ADMIN SHOW DDL JOB QUERIES`. + You can search the running DDL job corresponding to `job_id` within an arbitrarily specified range of results in the DDL history job queue. This syntax does not have the limitation of the last ten results of `ADMIN SHOW DDL JOB QUERIES`. ## MySQL compatibility