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 the multi-schema change DDL limitation #10457

Merged
merged 7 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mysql-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ MySQL 系统变量 `optimizer_switch` 在 TiDB 中是只读的,对查询计划

TiDB 中,所有支持的 DDL 变更操作都是在线执行的。与 MySQL 相比,TiDB 中的 DDL 存在以下限制:

* 不能在单条 `ALTER TABLE` 语句中完成多个操作。例如,不能在单个语句中添加多个列或索引,否则,可能会输出 `Unsupported multi schema change` 的错误。
* 使用 `ALTER TABLE` 语句进行多个模式更改时,不允许在多个更改中指定同一个模式对象。例如,执行 `MODIFY COLUMN c1 INT, DROP COLUMN c1` 会输出 "Unsupported operate same column/index" 的错误。
tangenta marked this conversation as resolved.
Show resolved Hide resolved
* `ALTER TABLE` 不支持少部分类型的变更。比如,TiDB 不支持从 `DECIMAL` 到 `DATE` 的变更。当遇到不支持的类型变更时,TiDB 将会报 `Unsupported modify column: type %d not match origin %d` 的错误。更多细节,请参考 [`ALTER TABLE`](/sql-statements/sql-statement-modify-column.md)。
* TiDB 中,`ALGORITHM={INSTANT,INPLACE,COPY}` 语法只作为一种指定,并不更改 `ALTER` 算法,详情参阅 [`ALTER TABLE`](/sql-statements/sql-statement-alter-table.md)。
* 不支持添加或删除 `CLUSTERED` 类型的主键。要了解关于 `CLUSTERED` 主键的详细信息,请参考[聚簇索引](/clustered-indexes.md)。
Expand Down
1 change: 0 additions & 1 deletion sql-statements/sql-statement-add-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ SELECT * FROM t1;

## MySQL 兼容性

* 不支持在一条语句中同时添加多列。
* 不支持将新添加的列设为 `PRIMARY KEY`。
* 不支持将新添加的列设为 `AUTO_INCREMENT`。
* 对添加生成列有局限性,具体可参考:[生成列局限性](/generated-columns.md#生成列的局限性)。
Expand Down
1 change: 0 additions & 1 deletion sql-statements/sql-statement-add-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ EXPLAIN SELECT * FROM t1 WHERE c1 = 3;

* 不支持 `FULLTEXT`,`HASH` 和 `SPATIAL` 索引。
* 不支持降序索引(类似于 MySQL 5.7)。
* 目前尚不支持在一条中同时添加多个索引。
* 无法向表中添加 `CLUSTERED` 类型的 `PRIMARY KEY`。要了解关于 `CLUSTERED` 主键的详细信息,请参考[聚簇索引](/clustered-indexes.md)。

## 另请参阅
Expand Down
2 changes: 1 addition & 1 deletion sql-statements/sql-statement-alter-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Query OK, 0 rows affected, 1 warning (0.25 sec)

TiDB 中的 `ALTER TABLE` 语法主要存在以下限制:

- 不支持在单个 `ALTER TABLE` 语句中进行多个更改
- 使用 `ALTER TABLE` 语句进行多个模式更改时,不允许在多个更改中指定同一个模式对象
tangenta marked this conversation as resolved.
Show resolved Hide resolved
tangenta marked this conversation as resolved.
Show resolved Hide resolved
- 不支持主键列上 [Reorg-Data](/sql-statements/sql-statement-modify-column.md#reorg-data-change) 类型的变更。
- 不支持分区表上的列类型变更。
- 不支持生成列上的列类型变更。
Expand Down
1 change: 0 additions & 1 deletion sql-statements/sql-statement-change-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ ERROR 8200 (HY000): Unsupported modify column: change from original type decimal

## MySQL 兼容性

* 不支持在单个 `ALTER TABLE` 语句中进行多个更改。
* 不支持主键列上 [Reorg-Data](/sql-statements/sql-statement-modify-column.md#Reorg-Data Change) 类型的变更。
* 不支持分区表上的列类型变更。
* 不支持生成列上的列类型变更。
Expand Down
1 change: 0 additions & 1 deletion sql-statements/sql-statement-drop-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ SELECT * FROM t1;

## MySQL 兼容性

* 目前不支持在一条语句中同时删除多个列。
* 目前不支持删除主键列或组合索引相关列。

## 另请参阅
Expand Down
7 changes: 0 additions & 7 deletions sql-statements/sql-statement-modify-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ CREATE TABLE `t1` (

## MySQL 兼容性

* 不支持使用单个 `ALTER TABLE` 语句修改多个列,例如:

```sql
ALTER TABLE t1 MODIFY col1 BIGINT, MODIFY id BIGINT NOT NULL;
ERROR 1105 (HY000): Unsupported multi schema change
```

* 不支持修改主键列上需要 Reorg-Data 的类型,但是支持修改 Meta-Only 的类型。例如:

```sql
Expand Down
15 changes: 0 additions & 15 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,21 +677,6 @@ MPP 是 TiFlash 引擎提供的分布式计算框架,允许节点之间的数
- 默认值:`OFF`
- 这个变量用于控制是否允许在创建生成列或者表达式索引时引用自增列。

### `tidb_enable_change_multi_schema`

> **警告:**
>
> TiDB 未来会支持更多种类的多模式对象变更,该系统变量将在后续版本中移除。

- 作用域:GLOBAL
- 是否持久化到集群:是
- 默认值:`OFF`
- 这个变量用于控制是否允许在一个 `ALTER TABLE` 语句中变更多个列或者索引。该变量值为 `ON` 时,仅支持以下多模式对象变更:
- 添加多列,例如 `ATLER TABLE t ADD COLUMN c1 INT, ADD COLUMN c2 INT;`。
- 删除多列,例如 `ATLER TABLE t DROP COLUMN c1, DROP COLUMN c2;`。
- 删除多个索引,例如 `ATLER TABLE t DROP INDEX i1, DROP INDEX i2;`。
- 删除被单列索引所覆盖的列,例如 `ALTER TABLE t DROP COLUMN c1`, 表结构中包含 `INDEX idx(c1)`。

### `tidb_enable_cascades_planner`

> **警告:**
Expand Down