Skip to content

Commit

Permalink
sql-statements: use EBNF to render syntax diagrams - third batch (pin…
Browse files Browse the repository at this point in the history
  • Loading branch information
CharLotteiu authored Apr 26, 2021
1 parent 3e454f1 commit 4839002
Show file tree
Hide file tree
Showing 22 changed files with 330 additions and 261 deletions.
7 changes: 4 additions & 3 deletions sql-statements/sql-statement-execute.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-execute/','/docs-cn/dev/ref

## 语法图

**ExecuteStmt:**

![ExecuteStmt](/media/sqlgram/ExecuteStmt.png)
```ebnf+diagram
ExecuteStmt ::=
'EXECUTE' Identifier ( 'USING' UserVariable ( ',' UserVariable )* )?
```

## 示例

Expand Down
30 changes: 18 additions & 12 deletions sql-statements/sql-statement-explain-analyze.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-explain-analyze/','/docs-cn
## 语法图

**ExplainSym:**

![ExplainSym](/media/sqlgram/ExplainSym.png)

**ExplainStmt:**

![ExplainStmt](/media/sqlgram/ExplainStmt.png)

**ExplainableStmt:**

![ExplainableStmt](/media/sqlgram/ExplainableStmt.png)
```ebnf+diagram
ExplainSym ::=
'EXPLAIN'
| 'DESCRIBE'
| 'DESC'
ExplainStmt ::=
ExplainSym ( TableName ColumnName? | 'ANALYZE'? ExplainableStmt | 'FOR' 'CONNECTION' NUM | 'FORMAT' '=' ( stringLit | ExplainFormatType ) ( 'FOR' 'CONNECTION' NUM | ExplainableStmt ) )
ExplainableStmt ::=
SelectStmt
| DeleteFromStmt
| UpdateStmt
| InsertIntoStmt
| ReplaceIntoStmt
| UnionStmt
```

## EXPLAIN ANALYZE 输出格式

Expand Down Expand Up @@ -181,7 +187,7 @@ inner:{total:4.297515932s, concurrency:5, task:17, construct:97.96291ms, fetch:4
`IndexHashJoin` 算子包含以下执行信息:

```sql
inner:{total:4.429220003s, concurrency:5, task:17, construct:96.207725ms, fetch:4.239324006s, build:24.567801ms, join:93.607362ms}
inner:{total:4.429220003s, concurrency:5, task:17, construct:96.207725ms, fetch:4.239324006s, build:24.567801ms, join:93.607362ms}
```

- `inner`:inner worker 的执行信息,具体如下:
Expand Down
30 changes: 18 additions & 12 deletions sql-statements/sql-statement-explain.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ TiDB 支持 `EXPLAIN [options] FOR CONNECTION connection_id`,但与 MySQL 的

## 语法图

**ExplainSym:**

![ExplainSym](/media/sqlgram/ExplainSym.png)

**ExplainStmt:**

![ExplainStmt](/media/sqlgram/ExplainStmt.png)

**ExplainableStmt:**

![ExplainableStmt](/media/sqlgram/ExplainableStmt.png)
```ebnf+diagram
ExplainSym ::=
'EXPLAIN'
| 'DESCRIBE'
| 'DESC'
ExplainStmt ::=
ExplainSym ( TableName ColumnName? | 'ANALYZE'? ExplainableStmt | 'FOR' 'CONNECTION' NUM | 'FORMAT' '=' ( stringLit | ExplainFormatType ) ( 'FOR' 'CONNECTION' NUM | ExplainableStmt ) )
ExplainableStmt ::=
SelectStmt
| DeleteFromStmt
| UpdateStmt
| InsertIntoStmt
| ReplaceIntoStmt
| UnionStmt
```

## EXPLAIN 输出格式

Expand Down Expand Up @@ -192,7 +198,7 @@ desc format = "dot" select A.a, B.b from t A join t B on A.a > B.b where A.a < 1
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| dot contents |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
digraph Projection_8 {
subgraph cluster8{
node [style=filled, color=lightgrey]
Expand Down
17 changes: 8 additions & 9 deletions sql-statements/sql-statement-flashback-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@ FLASHBACK TABLE table_name [TO other_table_name]

### 语法图

**FlashbackTableStmt:**
```ebnf+diagram
FlashbackTableStmt ::=
'FLASHBACK' 'TABLE' TableName FlashbackToNewName
![FlashbackTableStmt](/media/sqlgram/FlashbackTableStmt.png)
TableName ::=
Identifier ( '.' Identifier )?
**TableName:**

![TableName](/media/sqlgram/TableName.png)

**FlashbackToNewName:**

![FlashbackToNewName](/media/sqlgram/FlashbackToNewName.png)
FlashbackToNewName ::=
( 'TO' Identifier )?
```

## 注意事项

Expand Down
26 changes: 15 additions & 11 deletions sql-statements/sql-statement-flush-privileges.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-flush-privileges/','/docs-c

## 语法图

**FlushStmt:**

![FlushStmt](/media/sqlgram/FlushStmt.png)

**NoWriteToBinLogAliasOpt:**

![NoWriteToBinLogAliasOpt](/media/sqlgram/NoWriteToBinLogAliasOpt.png)

**FlushOption:**

![FlushOption](/media/sqlgram/FlushOption.png)
```ebnf+diagram
FlushStmt ::=
'FLUSH' NoWriteToBinLogAliasOpt FlushOption
NoWriteToBinLogAliasOpt ::=
( 'NO_WRITE_TO_BINLOG' | 'LOCAL' )?
FlushOption ::=
'PRIVILEGES'
| 'STATUS'
| 'TIDB' 'PLUGINS' PluginNameList
| 'HOSTS'
| LogTypeOpt 'LOGS'
| TableOrTables TableNameListOpt WithReadLockOpt
```

## 示例

Expand Down
26 changes: 15 additions & 11 deletions sql-statements/sql-statement-flush-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-flush-status/','/docs-cn/de

## 语法图

**FlushStmt:**

![FlushStmt](/media/sqlgram/FlushStmt.png)

**NoWriteToBinLogAliasOpt:**

![NoWriteToBinLogAliasOpt](/media/sqlgram/NoWriteToBinLogAliasOpt.png)

**FlushOption:**

![FlushOption](/media/sqlgram/FlushOption.png)
```ebnf+diagram
FlushStmt ::=
'FLUSH' NoWriteToBinLogAliasOpt FlushOption
NoWriteToBinLogAliasOpt ::=
( 'NO_WRITE_TO_BINLOG' | 'LOCAL' )?
FlushOption ::=
'PRIVILEGES'
| 'STATUS'
| 'TIDB' 'PLUGINS' PluginNameList
| 'HOSTS'
| LogTypeOpt 'LOGS'
| TableOrTables TableNameListOpt WithReadLockOpt
```

## 示例

Expand Down
43 changes: 22 additions & 21 deletions sql-statements/sql-statement-flush-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,34 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-flush-tables/','/docs-cn/de

## 语法图

**FlushStmt:**
```ebnf+diagram
FlushStmt ::=
'FLUSH' NoWriteToBinLogAliasOpt FlushOption
![FlushStmt](/media/sqlgram/FlushStmt.png)
NoWriteToBinLogAliasOpt ::=
( 'NO_WRITE_TO_BINLOG' | 'LOCAL' )?
**NoWriteToBinLogAliasOpt:**
FlushOption ::=
'PRIVILEGES'
| 'STATUS'
| 'TIDB' 'PLUGINS' PluginNameList
| 'HOSTS'
| LogTypeOpt 'LOGS'
| TableOrTables TableNameListOpt WithReadLockOpt
![NoWriteToBinLogAliasOpt](/media/sqlgram/NoWriteToBinLogAliasOpt.png)
LogTypeOpt ::=
( 'BINARY' | 'ENGINE' | 'ERROR' | 'GENERAL' | 'SLOW' )?
**FlushOption:**
TableOrTables ::=
'TABLE'
| 'TABLES'
![FlushOption](/media/sqlgram/FlushOption.png)
TableNameListOpt ::=
TableNameList?
**LogTypeOpt:**

![LogTypeOpt](/media/sqlgram/LogTypeOpt.png)

**TableOrTables:**

![TableOrTables](/media/sqlgram/TableOrTables.png)

**TableNameListOpt:**

![TableNameListOpt](/media/sqlgram/TableNameListOpt.png)

**WithReadLockOpt:**

![WithReadLockOpt](/media/sqlgram/WithReadLockOpt.png)
WithReadLockOpt ::=
( 'WITH' 'READ' 'LOCK' )?
```

## 示例

Expand Down
73 changes: 46 additions & 27 deletions sql-statements/sql-statement-grant-privileges.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,52 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-grant-privileges/','/docs-c

## 语法图

**GrantStmt:**

![GrantStmt](/media/sqlgram/GrantStmt.png)

**PrivElemList:**

![PrivElemList](/media/sqlgram/PrivElemList.png)

**PrivElem:**

![PrivElem](/media/sqlgram/PrivElem.png)

**PrivType:**

![PrivType](/media/sqlgram/PrivType.png)

**ObjectType:**

![ObjectType](/media/sqlgram/ObjectType.png)

**PrivLevel:**

![PrivLevel](/media/sqlgram/PrivLevel.png)

**UserSpecList:**

![UserSpecList](/media/sqlgram/UserSpecList.png)
```ebnf+diagram
GrantStmt ::=
'GRANT' PrivElemList 'ON' ObjectType PrivLevel 'TO' UserSpecList RequireClauseOpt WithGrantOptionOpt
PrivElemList ::=
PrivElem ( ',' PrivElem )*
PrivElem ::=
PrivType ( '(' ColumnNameList ')' )?
PrivType ::=
'ALL' 'PRIVILEGES'?
| 'ALTER' 'ROUTINE'?
| 'CREATE' ( 'USER' | 'TEMPORARY' 'TABLES' | 'VIEW' | 'ROLE' | 'ROUTINE' )?
| 'TRIGGER'
| 'DELETE'
| 'DROP' 'ROLE'?
| 'PROCESS'
| 'EXECUTE'
| 'INDEX'
| 'INSERT'
| 'SELECT'
| 'SUPER'
| 'SHOW' ( 'DATABASES' | 'VIEW' )
| 'UPDATE'
| 'GRANT' 'OPTION'
| 'REFERENCES'
| 'REPLICATION' ( 'SLAVE' | 'CLIENT' )
| 'USAGE'
| 'RELOAD'
| 'FILE'
| 'CONFIG'
| 'LOCK' 'TABLES'
| 'EVENT'
| 'SHUTDOWN'
ObjectType ::=
'TABLE'?
PrivLevel ::=
'*' ( '.' '*' )?
| Identifier ( '.' ( '*' | Identifier ) )?
UserSpecList ::=
UserSpec ( ',' UserSpec )*
```

## 示例

Expand Down
17 changes: 8 additions & 9 deletions sql-statements/sql-statement-grant-role.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ summary: TiDB 数据库中 GRANT <role> 的使用概况。

## 语法图

**GrantRoleStmt:**
```ebnf+diagram
GrantRoleStmt ::=
'GRANT' RolenameList 'TO' UsernameList
![GrantRoleStmt](/media/sqlgram/GrantRoleStmt.png)
RolenameList ::=
Rolename ( ',' Rolename )*
**RolenameList:**

![RolenameList](/media/sqlgram/RolenameList.png)

**UsernameList:**

![UsernameList](/media/sqlgram/UsernameList.png)
UsernameList ::=
Username ( ',' Username )*
```

## 示例

Expand Down
Loading

0 comments on commit 4839002

Please sign in to comment.