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

Update EBNF for admin statements and add checksum details #17617

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
6 changes: 2 additions & 4 deletions sql-statements/sql-statement-admin-cancel-ddl.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ The `ADMIN CANCEL DDL` statement also allows you to cancel a DDL job that is com
## Synopsis

```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' )
AdminCancelDDLStmt ::=
'ADMIN' 'CANCEL' 'DDL' 'JOBS' NumList

NumList ::=
Int64Num ( ',' Int64Num )*
Expand All @@ -24,8 +24,6 @@ NumList ::=

To cancel the currently running DDL jobs and return whether the corresponding jobs are successfully cancelled, use `ADMIN CANCEL DDL JOBS`:

{{< copyable "sql" >}}

```sql
ADMIN CANCEL DDL JOBS job_id [, job_id] ...;
```
Expand Down
10 changes: 2 additions & 8 deletions sql-statements/sql-statement-admin-check-table-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ If you use the `ADMIN CHECK INDEX` statement, it only checks the specified index
## Synopsis

```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' )
AdminCheckStmt ::=
'ADMIN' 'CHECK' ( 'TABLE' TableNameList | 'INDEX' TableName Identifier ( HandleRange ( ',' HandleRange )* )? )
dveeden marked this conversation as resolved.
Show resolved Hide resolved

TableNameList ::=
TableName ( ',' TableName )*
Expand All @@ -39,24 +39,18 @@ TableNameList ::=

To check the consistency of all the data and corresponding indexes in the `tbl_name` table, use `ADMIN CHECK TABLE`:

{{< copyable "sql" >}}

```sql
ADMIN CHECK TABLE tbl_name [, tbl_name] ...;
```

If the consistency check is passed, an empty result is returned. Otherwise, an error message is returned indicating that the data is inconsistent.

{{< copyable "sql" >}}

```sql
ADMIN CHECK INDEX tbl_name idx_name;
```

The above statement is used to check the consistency of the column data and index data corresponding to the `idx_name` index in the `tbl_name` table. If the consistency check is passed, an empty result is returned; otherwise, an error message is returned indicating that the data is inconsistent.

{{< copyable "sql" >}}

```sql
ADMIN CHECK INDEX tbl_name idx_name (lower_val, upper_val) [, (lower_val, upper_val)] ...;
```
Expand Down
6 changes: 4 additions & 2 deletions sql-statements/sql-statement-admin-checksum-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ category: reference

The `ADMIN CHECKSUM TABLE` statement calculates a CRC64 checksum for the data and indexes of a table. This statement is used by programs such as TiDB Lightning to ensure that import operations have completed successfully.

The checksum will likely be different between different servers and if the table is re-created.

## Synopsis

```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' )
AdminChecksumTableStmt ::=
'ADMIN' 'CHECKSUM' 'TABLE' TableNameList

TableNameList ::=
TableName ( ',' TableName )*
Expand Down
4 changes: 2 additions & 2 deletions sql-statements/sql-statement-admin-pause-ddl.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ You can use this statement to pause a DDL job that is issued but not yet complet
## Synopsis

```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 | 'PAUSE' 'DDL' 'JOBS' NumList | 'RESUME' 'DDL' 'JOBS' NumList | 'RELOAD' ( 'EXPR_PUSHDOWN_BLACKLIST' | 'OPT_RULE_BLACKLIST' | 'BINDINGS' ) | 'PLUGINS' ( 'ENABLE' | 'DISABLE' ) PluginNameList | 'REPAIR' 'TABLE' TableName CreateTableStmt | ( 'FLUSH' | 'CAPTURE' | 'EVOLVE' ) 'BINDINGS' )
AdminPauseDDLStmt ::=
'ADMIN' 'PAUSE' 'DDL' 'JOBS' NumList

NumList ::=
Int64Num ( ',' Int64Num )*
Expand Down
4 changes: 2 additions & 2 deletions sql-statements/sql-statement-admin-resume-ddl.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ You can use this statement to resume a paused DDL job. After the resume is compl
## Synopsis

```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 | 'PAUSE' 'DDL' 'JOBS' NumList | 'RESUME' 'DDL' 'JOBS' NumList | 'RELOAD' ( 'EXPR_PUSHDOWN_BLACKLIST' | 'OPT_RULE_BLACKLIST' | 'BINDINGS' ) | 'PLUGINS' ( 'ENABLE' | 'DISABLE' ) PluginNameList | 'REPAIR' 'TABLE' TableName CreateTableStmt | ( 'FLUSH' | 'CAPTURE' | 'EVOLVE' ) 'BINDINGS' )
AdminResumeDDLStmt ::=
'ADMIN' 'RESUME' 'DDL' 'JOBS' NumList

NumList ::=
Int64Num ( ',' Int64Num )*
Expand Down
2 changes: 1 addition & 1 deletion sql-statements/sql-statement-admin-show-ddl.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The `ADMIN SHOW DDL [JOBS|JOB QUERIES]` statement shows information about runnin
## Synopsis

```ebnf+diagram
AdminStmt ::=
AdminShowDDLStmt ::=
'ADMIN' 'SHOW' 'DDL'
(
'JOBS' Int64Num? WhereClauseOptional
Expand Down
7 changes: 2 additions & 5 deletions sql-statements/sql-statement-admin-show-telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ The `ADMIN SHOW TELEMETRY` statement shows the information that will be reported
## Synopsis

```ebnf+diagram
AdminStmt ::=
'ADMIN' ( 'SHOW' ( 'DDL' ( 'JOBS' Int64Num? WhereClauseOptional | 'JOB' 'QUERIES' NumList )? | TableName 'NEXT_ROW_ID' | 'SLOW' AdminShowSlow | 'TELEMETRY' ) | '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' )

AdminShowTelemetryStmt ::=
'ADMIN' 'SHOW' 'TELEMETRY'
```

## Examples

{{< copyable "sql" >}}

```sql
ADMIN SHOW TELEMETRY\G
```
Expand Down
47 changes: 26 additions & 21 deletions sql-statements/sql-statement-admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@ This statement is a TiDB extension syntax, used to view the status of TiDB and c

## `ADMIN RELOAD` statement

{{< copyable "sql" >}}

```sql
ADMIN RELOAD expr_pushdown_blacklist;
```

The above statement is used to reload the blocklist pushed down by the expression.

{{< copyable "sql" >}}

```sql
ADMIN RELOAD opt_rule_blacklist;
```
Expand All @@ -80,32 +76,24 @@ The above statement is used to disable the `plugin_name` plugin.

## `ADMIN BINDINGS` related statement

{{< copyable "sql" >}}

```sql
ADMIN FLUSH BINDINGS;
```

The above statement is used to persist SQL Plan binding information.

{{< copyable "sql" >}}

```sql
ADMIN CAPTURE BINDINGS;
```

The above statement can generate the binding of SQL Plan from the `SELECT` statement that occurs more than once.

{{< copyable "sql" >}}

```sql
ADMIN EVOLVE BINDINGS;
```

After the automatic binding feature is enabled, the evolution of SQL Plan binding information is triggered every `bind-info-leave` (the default value is `3s`). The above statement is used to proactively trigger this evolution.

{{< copyable "sql" >}}

```sql
ADMIN RELOAD BINDINGS;
```
Expand All @@ -124,8 +112,6 @@ The above statement is used to reload SQL Plan binding information.

To overwrite the metadata of the stored table in an untrusted way in extreme cases, use `ADMIN REPAIR TABLE`:

{{< copyable "sql" >}}

```sql
ADMIN REPAIR TABLE tbl_name CREATE TABLE STATEMENT;
```
Expand Down Expand Up @@ -168,15 +154,38 @@ For details, refer to [`ADMIN SHOW SLOW` command](/identify-slow-queries.md#admi

```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
)?
| 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' )
dveeden marked this conversation as resolved.
Show resolved Hide resolved
```

## Examples

Run the following command to view the last 10 completed DDL jobs in the currently running DDL job queue. When `NUM` is not specified, only the last 10 completed DDL jobs is presented by default.

{{< copyable "sql" >}}

```sql
ADMIN SHOW DDL JOBS;
```
Expand All @@ -201,8 +210,6 @@ ADMIN SHOW DDL JOBS;

Run the following command to view the last 5 completed DDL jobs in the currently running DDL job queue:

{{< copyable "sql" >}}

```sql
ADMIN SHOW DDL JOBS 5;
```
Expand Down Expand Up @@ -238,8 +245,6 @@ ADMIN SHOW t NEXT_ROW_ID;

Run the following command to view the uncompleted DDL jobs in the test database. The results include the DDL jobs that are running and the last 5 DDL jobs that are completed but failed.

{{< copyable "sql" >}}

```sql
ADMIN SHOW DDL JOBS 5 WHERE state != 'synced' AND db_name = 'test';
```
Expand Down
Loading