Skip to content

Commit

Permalink
translate 8 EBNF related PRs (pingcap#17216) (pingcap#17256)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Apr 29, 2024
1 parent d309d19 commit cdb43eb
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 156 deletions.
15 changes: 15 additions & 0 deletions sql-statements/sql-statement-savepoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ RELEASE SAVEPOINT identifier
当事务提交或者回滚后,事务中所有保存点都会被删除。
## 语法图
```ebnf+diagram
SavepointStmt ::=
"SAVEPOINT" Identifier
RollbackToStmt ::=
"ROLLBACK" "TO" "SAVEPOINT"? Identifier
ReleaseSavepointStmt ::=
"RELEASE" "SAVEPOINT" Identifier
```

## 示例

创建表 `t1`
Expand Down Expand Up @@ -140,6 +153,8 @@ SELECT * FROM t1;

使用 `ROLLBACK TO SAVEPOINT` 语句将事物回滚到指定保存点时,MySQL 会释放该保存点之后才持有的锁,但在 TiDB 悲观事务中,不会立即释放该保存点之后才持有的锁,而是等到事务提交或者回滚时,才释放全部持有的锁。

TiDB 不支持 MySQL 中的 `ROLLBACK WORK TO SAVEPOINT ...` 语法。

## 另请参阅

* [COMMIT](/sql-statements/sql-statement-commit.md)
Expand Down
41 changes: 4 additions & 37 deletions sql-statements/sql-statement-set-names.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,13 @@ summary: TiDB 数据库中 SET [NAMES|CHARACTER SET] 的使用概况。

## 语法图

**SetNamesStmt:**

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

**VariableAssignmentList:**

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

**VariableAssignment:**

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

**CharsetName:**

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

**StringName:**

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

**CharsetKw:**

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

**CharsetNameOrDefault:**

![CharsetNameOrDefault](/media/sqlgram/CharsetNameOrDefault.png)
```ebnf+diagram
SetNamesStmt ::=
"SET" ("NAMES" ("DEFAULT" | CharsetName ("COLLATE" ("DEFAULT" | CollationName))?) | ("CHARSET" | ("CHAR" | "CHARACTER") "SET") ("DEFAULT" | CharsetName))
```

## 示例

{{< copyable "sql" >}}

```sql
SHOW VARIABLES LIKE 'character_set%';
```
Expand All @@ -61,8 +36,6 @@ SHOW VARIABLES LIKE 'character_set%';
8 rows in set (0.01 sec)
```

{{< copyable "sql" >}}

```sql
SET NAMES utf8;
```
Expand All @@ -71,8 +44,6 @@ SET NAMES utf8;
Query OK, 0 rows affected (0.00 sec)
```

{{< copyable "sql" >}}

```sql
SHOW VARIABLES LIKE 'character_set%';
```
Expand All @@ -93,8 +64,6 @@ SHOW VARIABLES LIKE 'character_set%';
8 rows in set (0.00 sec)
```

{{< copyable "sql" >}}

```sql
SET CHARACTER SET utf8mb4;
```
Expand All @@ -103,8 +72,6 @@ SET CHARACTER SET utf8mb4;
Query OK, 0 rows affected (0.00 sec)
```

{{< copyable "sql" >}}

```sql
SHOW VARIABLES LIKE 'character_set%';
```
Expand Down
78 changes: 17 additions & 61 deletions sql-statements/sql-statement-show-columns-from.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,30 @@ summary: TiDB 数据库中 SHOW [FULL] COLUMNS FROM 的使用概况。
## 语法图

**ShowStmt:**
```ebnf+diagram
ShowColumnsFromStmt ::=
"SHOW" "FULL"? ("COLUMNS" | "FIELDS") ("FROM" | "IN") TableName ( ("FROM" | "IN") SchemaName)? ShowLikeOrWhere?
![ShowStmt](/media/sqlgram/ShowStmt.png)
TableName ::=
(Identifier ".")? Identifier
**ShowColumnsFilterable:**

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

**OptFull:**

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

**FieldsOrColumns:**

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

**ShowTableAliasOpt:**

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

**FromOrIn:**

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

**TableName:**

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

**ShowDatabaseNameOpt:**

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

**DBName:**

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

**ShowLikeOrWhereOpt:**

![ShowLikeOrWhereOpt](/media/sqlgram/ShowLikeOrWhereOpt.png)
ShowLikeOrWhere ::=
"LIKE" SimpleExpr
| "WHERE" Expression
```

## 示例

{{< copyable "sql" >}}

```sql
create view v1 as select 1;
CREATE VIEW v1 AS SELECT 1;
```

```
Query OK, 0 rows affected (0.11 sec)
```

{{< copyable "sql" >}}

```sql
show columns from v1;
SHOW COLUMNS FROM v1;
```

```
Expand All @@ -82,10 +50,8 @@ show columns from v1;
1 row in set (0.00 sec)
```

{{< copyable "sql" >}}

```sql
desc v1;
DESC v1;
```

```
Expand All @@ -97,10 +63,8 @@ desc v1;
1 row in set (0.00 sec)
```

{{< copyable "sql" >}}

```sql
describe v1;
DESCRIBE v1;
```

```
Expand All @@ -112,10 +76,8 @@ describe v1;
1 row in set (0.00 sec)
```

{{< copyable "sql" >}}

```sql
explain v1;
EXPLAIN v1;
```

```
Expand All @@ -127,10 +89,8 @@ explain v1;
1 row in set (0.00 sec)
```

{{< copyable "sql" >}}

```sql
show fields from v1;
SHOW FIELDS FROM v1;
```

```
Expand All @@ -142,10 +102,8 @@ show fields from v1;
1 row in set (0.00 sec)
```

{{< copyable "sql" >}}

```sql
show full columns from v1;
SHOW FULL COLUMNS FROM v1
```

```
Expand All @@ -157,10 +115,8 @@ show full columns from v1;
1 row in set (0.00 sec)
```

{{< copyable "sql" >}}

```sql
show full columns from mysql.user;
SHOW FULL COLUMNS FROM mysql.user;
```

```
Expand Down
13 changes: 5 additions & 8 deletions sql-statements/sql-statement-show-create-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ summary: TiDB 数据库中 SHOW CREATE USER 的使用概况。

## 语法图

**ShowCreateUserStmt:**

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

**Username:**

![Username](/media/sqlgram/Username.png)
```ebnf+diagram
ShowCreateUserStmt ::=
"SHOW" "CREATE" "USER" (Username ("@" Hostname)? | "CURRENT_USER" ( "(" ")" )? )
```

## 示例

Expand Down Expand Up @@ -44,7 +41,7 @@ mysql> SHOW GRANTS FOR 'root';

## MySQL 兼容性

* `SHOW CREATE USER` 的输出结果旨在匹配 MySQL,但 TiDB 尚不支持若干 `CREATE` 选项。尚未支持的选项在语句执行过程中会被解析但会被跳过执行。详情可参阅 [security compatibility]
* `SHOW CREATE USER` 的输出结果旨在匹配 MySQL,但 TiDB 尚不支持若干 `CREATE` 选项。尚未支持的选项在语句执行过程中会被解析但会被跳过执行。详情可参阅[与 MySQL 安全特性差异](/security-compatibility-with-mysql.md)

## 另请参阅

Expand Down
36 changes: 9 additions & 27 deletions sql-statements/sql-statement-show-grants.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,20 @@ summary: TiDB 数据库中 SHOW GRANTS 的使用概况。

## 语法图

**ShowGrantsStmt:**
```ebnf+diagram
ShowGrantsStmt ::=
"SHOW" "GRANTS" ("FOR" Username ("USING" RolenameList)?)?
![ShowGrantsStmt](/media/sqlgram/ShowGrantsStmt.png)
Username ::=
"CURRENT_USER" ( "(" ")" )?
| Username ("@" Hostname)?
**Username:**

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

**UsingRoles:**

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

**RolenameList:**

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

**Rolename:**

![Rolename](/media/sqlgram/Rolename.png)
RolenameList ::=
Rolename ("@" Hostname)? ("," Rolename ("@" Hostname)? )*
```

## 示例

{{< copyable "sql" >}}

```sql
SHOW GRANTS;
```
Expand All @@ -46,8 +36,6 @@ SHOW GRANTS;
1 row in set (0.00 sec)
```

{{< copyable "sql" >}}

```sql
SHOW GRANTS FOR 'u1';
```
Expand All @@ -56,8 +44,6 @@ SHOW GRANTS FOR 'u1';
ERROR 1141 (42000): There is no such grant defined for user 'u1' on host '%'
```

{{< copyable "sql" >}}

```sql
CREATE USER u1;
```
Expand All @@ -66,8 +52,6 @@ CREATE USER u1;
Query OK, 1 row affected (0.04 sec)
```

{{< copyable "sql" >}}

```sql
GRANT SELECT ON test.* TO u1;
```
Expand All @@ -76,8 +60,6 @@ GRANT SELECT ON test.* TO u1;
Query OK, 0 rows affected (0.04 sec)
```

{{< copyable "sql" >}}

```sql
SHOW GRANTS FOR u1;
```
Expand Down
11 changes: 7 additions & 4 deletions sql-statements/sql-statement-show-profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ summary: TiDB 数据库中 SHOW PROFILES 的使用概况。

## 语法图

**ShowStmt:**
```ebnf+diagram
ShowProfilesStmt ::=
"SHOW" "PROFILES" ShowLikeOrWhere?
![ShowStmt](/media/sqlgram/ShowStmt.png)
ShowLikeOrWhere ::=
"LIKE" SimpleExpr
| "WHERE" Expression
```

## 示例

{{< copyable "sql" >}}

```sql
SHOW PROFILES
```
Expand Down
Loading

0 comments on commit cdb43eb

Please sign in to comment.