From 2943ca430db1383c2b65f7d9ffc4087c02abd59a Mon Sep 17 00:00:00 2001 From: lyzx2001 Date: Tue, 26 Jul 2022 20:35:24 +0800 Subject: [PATCH 1/5] 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 d968702f79d2..1689556a8567 100644 --- a/sql-statements/sql-statement-admin-show-ddl.md +++ b/sql-statements/sql-statement-admin-show-ddl.md @@ -113,6 +113,56 @@ ADMIN SHOW DDL JOB QUERIES 51; 只能在 DDL 历史作业队列中最近十条结果中搜索与 `job_id` 对应的正在运行中的 DDL 作业。 +### `ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n` + +`ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n` 语句用于查看指定范围 `(n+1, n+m)` 的 `job_id` 对应的 DDL 任务的原始 SQL 语句: + +{{< 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) +``` + +可以在 DDL 历史作业队列任意指定范围中搜索与 `job_id` 对应的正在运行中的 DDL 作业,没有 `ADMIN SHOW DDL JOB QUERIES` 语句的最近十条结果限制。 + ## MySQL 兼容性 `ADMIN SHOW DDL [JOBS|JOB QUERIES]` 语句是 TiDB 对 MySQL 语法的扩展。 From 722d60ec7ee8cbf39dad59b46e895646c4cad062 Mon Sep 17 00:00:00 2001 From: lyzx2001 Date: Wed, 27 Jul 2022 12:09:52 +0800 Subject: [PATCH 2/5] Update sql-statement-admin-show-ddl.md --- .../sql-statement-admin-show-ddl.md | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/sql-statements/sql-statement-admin-show-ddl.md b/sql-statements/sql-statement-admin-show-ddl.md index 1689556a8567..8148f3b0ec7f 100644 --- a/sql-statements/sql-statement-admin-show-ddl.md +++ b/sql-statements/sql-statement-admin-show-ddl.md @@ -11,7 +11,7 @@ summary: TiDB 数据库中 ADMIN SHOW DDL [JOBS|JOB QUERIES] 的使用概况。 ```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 )* @@ -120,17 +120,18 @@ ADMIN SHOW DDL JOB QUERIES 51; {{< 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 +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 @@ ADMIN SHOW DDL JOB QUERIES LIMIT 3; # Retrieve first 3 rows ``` ```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 25b3c8ee46213cc00d78cc0c599c4385938214a3 Mon Sep 17 00:00:00 2001 From: lyzx2001 Date: Wed, 27 Jul 2022 12:11:30 +0800 Subject: [PATCH 3/5] Update sql-statement-admin-show-ddl.md --- sql-statements/sql-statement-admin-show-ddl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-admin-show-ddl.md b/sql-statements/sql-statement-admin-show-ddl.md index 8148f3b0ec7f..4bd5822f1a63 100644 --- a/sql-statements/sql-statement-admin-show-ddl.md +++ b/sql-statements/sql-statement-admin-show-ddl.md @@ -115,7 +115,7 @@ ADMIN SHOW DDL JOB QUERIES 51; ### `ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n` -`ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n` 语句用于查看指定范围 `(n+1, n+m)` 的 `job_id` 对应的 DDL 任务的原始 SQL 语句: +`ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n` 语句用于查看指定范围 `[n+1, n+m]` 的 `job_id` 对应的 DDL 任务的原始 SQL 语句: {{< copyable "sql" >}} From 2b38304c115b8ea54409a467ba8257b56d287194 Mon Sep 17 00:00:00 2001 From: lyzx2001 Date: Wed, 27 Jul 2022 12:58:19 +0800 Subject: [PATCH 4/5] Update sql-statement-admin-show-ddl.md --- sql-statements/sql-statement-admin-show-ddl.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-admin-show-ddl.md b/sql-statements/sql-statement-admin-show-ddl.md index 4bd5822f1a63..ff37121dad2d 100644 --- a/sql-statements/sql-statement-admin-show-ddl.md +++ b/sql-statements/sql-statement-admin-show-ddl.md @@ -124,7 +124,8 @@ 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. + +这里 n 和 m 都是非负整数。 ```sql ADMIN SHOW DDL JOB QUERIES LIMIT 3; # Retrieve first 3 rows From d33ad7fc133a93fa0df62bd0062da0b4c9b78d40 Mon Sep 17 00:00:00 2001 From: lyzx2001 Date: Thu, 28 Jul 2022 15:28:15 +0800 Subject: [PATCH 5/5] Update sql-statement-admin-show-ddl.md --- sql-statements/sql-statement-admin-show-ddl.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sql-statements/sql-statement-admin-show-ddl.md b/sql-statements/sql-statement-admin-show-ddl.md index ff37121dad2d..d4aaa4193a1e 100644 --- a/sql-statements/sql-statement-admin-show-ddl.md +++ b/sql-statements/sql-statement-admin-show-ddl.md @@ -120,12 +120,12 @@ ADMIN SHOW DDL JOB QUERIES 51; {{< copyable "sql" >}} ```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] +ADMIN SHOW DDL JOB QUERIES LIMIT m; # -- 取出前 m 行 +ADMIN SHOW DDL JOB QUERIES LIMIT n, m; # -- 取出第 n+1 到 n+m 行 +ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n; # -- 取出第 n+1 到 n+m 行 ``` -这里 n 和 m 都是非负整数。 +以上语法中 `n` 和 `m` 都是非负整数。语法的具体示例如下: ```sql ADMIN SHOW DDL JOB QUERIES LIMIT 3; # Retrieve first 3 rows @@ -162,7 +162,7 @@ ADMIN SHOW DDL JOB QUERIES LIMIT 3 OFFSET 4; # Retrieve rows 5-7 3 rows in set (0.00 sec) ``` -可以在 DDL 历史作业队列任意指定范围中搜索与 `job_id` 对应的正在运行中的 DDL 作业,没有 `ADMIN SHOW DDL JOB QUERIES` 语句的最近十条结果限制。 +该语句可以在 DDL 历史作业队列任意指定范围中搜索与 `job_id` 对应的正在运行中的 DDL 作业,没有 `ADMIN SHOW DDL JOB QUERIES` 语句的最近 10 条结果的限制。 ## MySQL 兼容性