Skip to content

Commit

Permalink
Update the multi-schema change DDL limitation (#9641)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreoxmt authored Aug 5, 2022
1 parent 53140a9 commit 0da233c
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 29 deletions.
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.
* When you use a single `ALTER TABLE` statement to alter multiple schema objects (such as columns or indexes) of a table, specifying the same object in multiple changes is not supported. For example, if you execute the `ALTER TABLE t1 MODIFY COLUMN c1 INT, DROP COLUMN c1` command, the `Unsupported operate same column/index` error is output.
* `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.
- Changing the same column or index when altering multiple schema objects in a single statement is not supported.

- 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

0 comments on commit 0da233c

Please sign in to comment.