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 #9641

Merged
merged 5 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 @@ -104,7 +104,7 @@ See also: [TiDB SQL Grammar](https://pingcap.github.io/sqlgram/#functioncallkeyw

In TiDB, all supported DDL changes are performed online. Compared with DDL operations in MySQL, the DDL operations in TiDB have the following major restrictions:

* Multiple operations cannot be completed in a single `ALTER TABLE` statement. For example, it is not possible to add multiple columns or indexes in a single statement. Otherwise, the `Unsupported multi schema change` error might be output.
* It is not supported to alter the same column or index when altering multiple schemas in a single `ALTER TABLE` statement. For example, when you run the `ALTER TABLE t1 MODIFY COLUMN c1 INT, DROP COLUMN c1` command, a `Unsupported operate same column/index` error is output.
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved
* `ALTER TABLE` in TiDB does not support the changes of some data types. For example, TiDB does not support the change from the `DECIMAL` type to the `DATE` type. If a data type change is unsupported, TiDB reports the `Unsupported modify column: type %d not match origin %d` error. Refer to [`ALTER TABLE`](/sql-statements/sql-statement-modify-column.md) for more details.
* The `ALGORITHM={INSTANT,INPLACE,COPY}` syntax functions only as an assertion in TiDB, and does not modify the `ALTER` algorithm. See [`ALTER TABLE`](/sql-statements/sql-statement-alter-table.md) for further details.
* Adding/Dropping the primary key of the `CLUSTERED` type is unsupported. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/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 @@ -86,7 +86,6 @@ mysql> SELECT * FROM t1;

## MySQL compatibility

* Adding multiple columns at the same time in a statement is currently not supported.
* Adding a new column and setting it to the `PRIMARY KEY` is not supported.
* Adding a new column and setting it to `AUTO_INCREMENT` is not supported.
* There are limitations on adding generated columns, refer to: [generated column limitations](/generated-columns.md#limitations).
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 @@ -77,7 +77,6 @@ mysql> EXPLAIN SELECT * FROM t1 WHERE c1 = 3;

* `FULLTEXT`, `HASH` and `SPATIAL` indexes are not supported.
* Descending indexes are not supported (similar to MySQL 5.7).
* Adding multiple indexes at the same time is currently not supported.
* Adding the primary key of the `CLUSTERED` type to a table is not supported. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md).

## See also
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 @@ -157,7 +157,7 @@ Query OK, 0 rows affected, 1 warning (0.25 sec)

The following major restrictions apply to `ALTER TABLE` in TiDB:

- Making multiple changes in a single `ALTER TABLE` statement is currently not supported.
- Changes of the same column or index when altering multiple schemas in a single statement are not supported.
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

- Changes of the [Reorg-Data](/sql-statements/sql-statement-modify-column.md#reorg-data-change) types on primary key columns are not supported.

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 compatibility

* Making multiple changes in a single `ALTER TABLE` statement is currently not supported.
* Changes of [Reorg-Data](/sql-statements/sql-statement-modify-column.md#reorg-data-change) types on primary key columns are not supported.
* Changes of column types on partitioned tables are not supported.
* Changes of column types on generated columns are not supported.
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 @@ -75,7 +75,6 @@ mysql> SELECT * FROM t1;

## MySQL compatibility

* Dropping multiple columns in the same statement is not supported.
* Dropping primary key columns or columns covered by the composite index is not supported.

## See also
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 compatibility

* Does not support modifying multiple columns using a single `ALTER TABLE` statement. For example:

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

* Does not support modifying the Reorg-Data types on the primary key columns but supports modifying the Meta-Only types. For example:

```sql
Expand Down
16 changes: 0 additions & 16 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -826,22 +826,6 @@ Constraint checking is always performed in place for pessimistic transactions (d
- Default value: `OFF`
- This variable is used to determine whether to include the `AUTO_INCREMENT` columns when creating a generated column or an expression index.

### tidb_enable_change_multi_schema

> **Warning:**
>
> TiDB will support more types of multi-schema changes in the future. This system variable will be deleted in a future release of TiDB.

- Scope: GLOBAL
- Persists to cluster: Yes
- Type: Boolean
- Default value: `OFF`
- This variable is used to control whether multiple columns or indexes can be altered in one `ALTER TABLE` statement. When the value of this variable is `ON`, only the following multi-schema changes are supported:
- Add multiple columns. For example, `ATLER TABLE t ADD COLUMN c1 INT, ADD COLUMN c2 INT;`.
- Drop multiple columns. For example, `ATLER TABLE t DROP COLUMN c1, DROP COLUMN c2;`.
- Drop multiple indexes. For example, `ATLER TABLE t DROP INDEX i1, DROP INDEX i2;`.
- Drop a column covered by a single-column index. For example, `ALTER TABLE t DROP COLUMN c1`, in which the schema contains `INDEX idx(c1)`.

### tidb_enable_cascades_planner

> **Warning:**
Expand Down