From fa1b398ed19cbb1690f554575e2dec69e5c09abd Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Thu, 25 Mar 2021 15:16:14 +0800 Subject: [PATCH 1/7] *: remove alter-primary-key configuration --- auto-random.md | 2 +- constraints.md | 25 ++++++++++++++++++-- dynamic-config.md | 1 - mysql-compatibility.md | 2 +- sql-statements/sql-statement-add-index.md | 2 +- sql-statements/sql-statement-create-index.md | 2 +- sql-statements/sql-statement-drop-index.md | 2 +- sql-statements/sql-statement-show-config.md | 2 -- tidb-configuration-file.md | 6 ++++- troubleshoot-hot-spot-issues.md | 2 +- 10 files changed, 34 insertions(+), 12 deletions(-) diff --git a/auto-random.md b/auto-random.md index 67ede73209ab5..11c1aaf68a372 100644 --- a/auto-random.md +++ b/auto-random.md @@ -142,7 +142,7 @@ This attribute supports forward compatibility, namely, downgrade compatibility. Pay attention to the following restrictions when you use `AUTO_RANDOM`: -- Specify this attribute for the primary key column **ONLY** of integer type. Otherwise, an error might occur. In addition, when the value of `alter-primary-key` is `true`, `AUTO_RANDOM` is not supported even on the integer primary key. +- Specify this attribute for the primary key column **ONLY** of integer type. Otherwise, an error might occur. In addition, when the primary key attribute is `NONCLUSTERED`, `AUTO_RANDOM` is not supported even on the integer primary key. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). - You cannot use `ALTER TABLE` to modify the `AUTO_RANDOM` attribute, including adding or removing this attribute. - You cannot change the column type of the primary key column that is specified with `AUTO_RANDOM` attribute. - You cannot specify `AUTO_RANDOM` and `AUTO_INCREMENT` for the same column at the same time. diff --git a/constraints.md b/constraints.md index 473820f56e2bc..785fbb0d4b5d9 100644 --- a/constraints.md +++ b/constraints.md @@ -245,9 +245,30 @@ Query OK, 0 rows affected (0.10 sec) * Table `t3` failed to be created, because a table can only have one primary key. * Table `t4` was created successfully, because even though there can be only one primary key, TiDB supports defining multiple columns as the composite primary key. -In addition to the rules above, by default, TiDB has an additional restriction that once a table is successfully created, its primary key cannot be changed. If you need to add/remove the primary key, you need to set `alter-primary-key` to `true` in the TiDB configuration file, and restart the TiDB instance to make it effective. +In addition to the rules above, TiDB currently only supports adding and deleting the primary keys of `NONCLUSTERED`. For example: -When the add/delete primary key feature is enabled, TiDB allows adding/deleting primary key to the table. However, it should be noted that, if a table with an integer type primary key has been created before the feature is enabled, you cannot delete its primary key constraint even when you enable the add/delete primary key feature. +{{< copyable "sql" >}} + +```sql +CREATE TABLE t5 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b) CLUSTERED); +ALTER TABLE t5 DROP PRIMARY KEY; +``` + +``` +ERROR 8200 (HY000): Unsupported drop primary key when the table is using clustered index +``` + +{{< copyable "sql" >}} + +```sql +CREATE TABLE t5 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b) NONCLUSTERED); +ALTER TABLE t5 DROP PRIMARY KEY; +``` + +``` +Query OK, 0 rows affected (0.10 sec) +``` +For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). ## FOREIGN KEY diff --git a/dynamic-config.md b/dynamic-config.md index 6d9930d86ce68..04076a72319e3 100644 --- a/dynamic-config.md +++ b/dynamic-config.md @@ -33,7 +33,6 @@ show config; | Type | Instance | Name | Value | +------+-----------------+-----------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tidb | 127.0.0.1:4001 | advertise-address | 127.0.0.1 | -| tidb | 127.0.0.1:4001 | alter-primary-key | false | | tidb | 127.0.0.1:4001 | binlog.binlog-socket | | | tidb | 127.0.0.1:4001 | binlog.enable | false | | tidb | 127.0.0.1:4001 | binlog.ignore-error | false | diff --git a/mysql-compatibility.md b/mysql-compatibility.md index 412e51bedaeb5..2e1a11b96456f 100644 --- a/mysql-compatibility.md +++ b/mysql-compatibility.md @@ -93,7 +93,7 @@ In TiDB, all supported DDL changes are performed online. Compared with DDL opera * 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. * Different types of indexes (`HASH|BTREE|RTREE|FULLTEXT`) are not supported, and will be parsed and ignored when specified. -* Adding/Dropping the primary key is unsupported unless [`alter-primary-key`](/tidb-configuration-file.md#alter-primary-key) is enabled. +* Adding/Dropping the primary key of `CLUSTERED` type is unsupported unless [`alter-primary-key`](/tidb-configuration-file.md#alter-primary-key) is enabled. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). * Changing the field type to its superset is unsupported. For example, TiDB does not support changing the field type from `INTEGER` to `VARCHAR`, or from `TIMESTAMP` to `DATETIME`. Otherwise, the error information `Unsupported modify column: type %d not match origin %d` might be output. * Change/Modify data type does not currently support "lossy changes", such as changing from BIGINT to INT. * Change/Modify decimal columns does not support changing the precision. diff --git a/sql-statements/sql-statement-add-index.md b/sql-statements/sql-statement-add-index.md index f1dbb912fac20..1bfb27001c2ff 100644 --- a/sql-statements/sql-statement-add-index.md +++ b/sql-statements/sql-statement-add-index.md @@ -124,7 +124,7 @@ mysql> EXPLAIN SELECT * FROM t1 WHERE c1 = 3; * `VISIBLE/INVISIBLE` index is not supported (currently only the master branch actually supports this feature). * 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 constraint to a table is not supported by default. You can enable the feature by setting the `alter-primary-key` configuration item to `true`. For details, see [alter-primary-key](/tidb-configuration-file.md#alter-primary-key). +* Adding the primary key of the `CLUSTERED` type to a table is not supported. For more details about the primary key of `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ## See also diff --git a/sql-statements/sql-statement-create-index.md b/sql-statements/sql-statement-create-index.md index b54b628cde16a..8a8272c3930fb 100644 --- a/sql-statements/sql-statement-create-index.md +++ b/sql-statements/sql-statement-create-index.md @@ -168,7 +168,7 @@ The global variables associated with the `CREATE INDEX` statement are `tidb_ddl_ * `FULLTEXT`, `HASH` and `SPATIAL` indexes are not supported. * Descending indexes are not supported (similar to MySQL 5.7). -* Adding the primary key constraint to a table is not supported by default. You can enable the feature by setting the `alter-primary-key` configuration item to `true`. For details, see [alter-primary-key](/tidb-configuration-file.md#alter-primary-key). +* Adding the primary key of the `CLUSTERED` type to a table is not supported. For more details about the primary key of `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ## See also diff --git a/sql-statements/sql-statement-drop-index.md b/sql-statements/sql-statement-drop-index.md index 226421b30d661..308d0922564ab 100644 --- a/sql-statements/sql-statement-drop-index.md +++ b/sql-statements/sql-statement-drop-index.md @@ -72,7 +72,7 @@ Query OK, 0 rows affected (0.30 sec) ## MySQL compatibility -* Removing the primary key constraint from a column is not supported by default. You can enable the feature by setting the `alter-primary-key` configuration item to `true`. For details, see [alter-primary-key](/tidb-configuration-file.md#alter-primary-key). +* Deleting the primary key of the `CLUSTERED` type is not supported. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ## See also diff --git a/sql-statements/sql-statement-show-config.md b/sql-statements/sql-statement-show-config.md index 06a4ff631ff7e..71adf0b3351c1 100644 --- a/sql-statements/sql-statement-show-config.md +++ b/sql-statements/sql-statement-show-config.md @@ -37,7 +37,6 @@ SHOW CONFIG; | Type | Instance | Name | Value | +------+----------------+-------------------------------------------------+---------------------------------------------------------------------+ | tidb | 127.0.0.1:4000 | advertise-address | 127.0.0.1 | -| tidb | 127.0.0.1:4000 | alter-primary-key | false | | tidb | 127.0.0.1:4000 | binlog.binlog-socket | | | tidb | 127.0.0.1:4000 | binlog.enable | false | ... @@ -74,7 +73,6 @@ SHOW CONFIG LIKE 'tidb'; | Type | Instance | Name | Value | +------+----------------+-------------------------------------------------+---------------------------------------------------------------------+ | tidb | 127.0.0.1:4000 | advertise-address | 127.0.0.1 | -| tidb | 127.0.0.1:4000 | alter-primary-key | false | | tidb | 127.0.0.1:4000 | binlog.binlog-socket | | | tidb | 127.0.0.1:4000 | binlog.enable | false | ... diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index a617634c991d2..04628635b783a 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -88,12 +88,16 @@ The TiDB configuration file supports more options than command-line parameters. - Determines whether to treat the `utf8` character set in old tables as `utf8mb4`. - Default value: `true` -### `alter-primary-key` +### `alter-primary-key` (Deprecated) - Determines whether to add or remove the primary key constraint to or from a column. - Default value: `false` - With this default setting, adding or removing the primary key constraint is not supported. You can enable this feature by setting `alter-primary-key` to `true`. However, if a table already exists before the switch is on, and the data type of its primary key column is an integer, dropping the primary key from the column is not possible even if you set this configuration item to `true`. +> **Note:** +> +> This configuration item no longer takes effect. If you need to add or delete the primary key, use `NONCLUSTERED` instead. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). + ### `server-version` + Modifies the version string returned by TiDB in the following situations: diff --git a/troubleshoot-hot-spot-issues.md b/troubleshoot-hot-spot-issues.md index d9ecf2e6dd566..d457163910c1b 100644 --- a/troubleshoot-hot-spot-issues.md +++ b/troubleshoot-hot-spot-issues.md @@ -106,7 +106,7 @@ ALTER TABLE:ALTER TABLE t SHARD_ROW_ID_BITS = 4; The value of `SHARD_ROW_ID_BITS` can be dynamically modified. The modified value only takes effect for newly written data. -When TiDB's `alter-primary-key` parameter is set to false, the table's integer primary key is used as the RowID. At this time, the `SHARD_ROW_ID_BITS` option can not be used because it changes the RowID generation rules. If the `alter-primary-key` parameter is set to true, TiDB no longer uses the integer primary key as the RowID when creating a table, and the table with the integer primary key can also use the `SHARD_ROW_ID_BITS` feature. +For a table with a primary key of the `CLUSTERED` type, TiDB uses the primary key of the table as the RowID, At this time, the `SHARD_ROW_ID_BITS` option can not be used because it changes the RowID generation rules. For tables that use the primary key of `NONCLUSTERED`, TiDB uses an automatically allocated 64-bit integer as the RowID. In this case, you can also use the `SHARD_ROW_ID_BITS` feature. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). The following two load diagrams shows the case where two tables without primary keys use `SHARD_ROW_ID_BITS` to scatter hotspots. The first diagram shows the situation before scattering hotspots, while the second one shows the situation after scattering hotspots. From 00bd833ddd3c10d351f126c9921ae715075cd7db Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Thu, 25 Mar 2021 15:42:32 +0800 Subject: [PATCH 2/7] Update constraints.md --- constraints.md | 1 + 1 file changed, 1 insertion(+) diff --git a/constraints.md b/constraints.md index 785fbb0d4b5d9..1bf5c7359bc0b 100644 --- a/constraints.md +++ b/constraints.md @@ -268,6 +268,7 @@ ALTER TABLE t5 DROP PRIMARY KEY; ``` Query OK, 0 rows affected (0.10 sec) ``` + For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). ## FOREIGN KEY From 0c6bc7ab937520012cee35bcaf1b8272c1c6f966 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Thu, 25 Mar 2021 18:22:18 +0800 Subject: [PATCH 3/7] refine the docs --- auto-random.md | 2 +- constraints.md | 2 +- sql-statements/sql-statement-create-index.md | 2 +- tidb-configuration-file.md | 2 +- troubleshoot-hot-spot-issues.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/auto-random.md b/auto-random.md index 11c1aaf68a372..f9197a178be81 100644 --- a/auto-random.md +++ b/auto-random.md @@ -142,7 +142,7 @@ This attribute supports forward compatibility, namely, downgrade compatibility. Pay attention to the following restrictions when you use `AUTO_RANDOM`: -- Specify this attribute for the primary key column **ONLY** of integer type. Otherwise, an error might occur. In addition, when the primary key attribute is `NONCLUSTERED`, `AUTO_RANDOM` is not supported even on the integer primary key. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). +- Specify this attribute for the primary key column **ONLY** of integer type. Otherwise, an error might occur. In addition, when the attribute of the primary key is `NONCLUSTERED`, `AUTO_RANDOM` is not supported even on the integer primary key. For more details about the primary key of `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). - You cannot use `ALTER TABLE` to modify the `AUTO_RANDOM` attribute, including adding or removing this attribute. - You cannot change the column type of the primary key column that is specified with `AUTO_RANDOM` attribute. - You cannot specify `AUTO_RANDOM` and `AUTO_INCREMENT` for the same column at the same time. diff --git a/constraints.md b/constraints.md index 1bf5c7359bc0b..626187edd3463 100644 --- a/constraints.md +++ b/constraints.md @@ -269,7 +269,7 @@ ALTER TABLE t5 DROP PRIMARY KEY; Query OK, 0 rows affected (0.10 sec) ``` -For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). +For more details about the primary key of `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ## FOREIGN KEY diff --git a/sql-statements/sql-statement-create-index.md b/sql-statements/sql-statement-create-index.md index 8a8272c3930fb..71e57d8c842cd 100644 --- a/sql-statements/sql-statement-create-index.md +++ b/sql-statements/sql-statement-create-index.md @@ -168,7 +168,7 @@ The global variables associated with the `CREATE INDEX` statement are `tidb_ddl_ * `FULLTEXT`, `HASH` and `SPATIAL` indexes are not supported. * Descending indexes are not supported (similar to MySQL 5.7). -* Adding the primary key of the `CLUSTERED` type to a table is not supported. For more details about the primary key of `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). +* 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 diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 04628635b783a..77ede19dd999a 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -96,7 +96,7 @@ The TiDB configuration file supports more options than command-line parameters. > **Note:** > -> This configuration item no longer takes effect. If you need to add or delete the primary key, use `NONCLUSTERED` instead. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). +> This configuration item no longer takes effect. If you need to add or delete the primary key, use `NONCLUSTERED` instead. For more details about the primary key of `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ### `server-version` diff --git a/troubleshoot-hot-spot-issues.md b/troubleshoot-hot-spot-issues.md index d457163910c1b..1426623af511d 100644 --- a/troubleshoot-hot-spot-issues.md +++ b/troubleshoot-hot-spot-issues.md @@ -106,7 +106,7 @@ ALTER TABLE:ALTER TABLE t SHARD_ROW_ID_BITS = 4; The value of `SHARD_ROW_ID_BITS` can be dynamically modified. The modified value only takes effect for newly written data. -For a table with a primary key of the `CLUSTERED` type, TiDB uses the primary key of the table as the RowID, At this time, the `SHARD_ROW_ID_BITS` option can not be used because it changes the RowID generation rules. For tables that use the primary key of `NONCLUSTERED`, TiDB uses an automatically allocated 64-bit integer as the RowID. In this case, you can also use the `SHARD_ROW_ID_BITS` feature. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). +For a table using a primary key of the `CLUSTERED` type, TiDB uses the primary key of the table as the RowID. At this time, the `SHARD_ROW_ID_BITS` option can not be used because it changes the RowID generation rules. For a table using the primary key of the `NONCLUSTERED` type, TiDB uses an automatically allocated 64-bit integer as the RowID. In this case, you can also use the `SHARD_ROW_ID_BITS` feature. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). The following two load diagrams shows the case where two tables without primary keys use `SHARD_ROW_ID_BITS` to scatter hotspots. The first diagram shows the situation before scattering hotspots, while the second one shows the situation after scattering hotspots. From f996870987310a86b32f8ee7f69123ebf7cb7749 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Thu, 25 Mar 2021 18:25:51 +0800 Subject: [PATCH 4/7] add the article --- auto-random.md | 2 +- constraints.md | 2 +- mysql-compatibility.md | 2 +- sql-statements/sql-statement-add-index.md | 2 +- tidb-configuration-file.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/auto-random.md b/auto-random.md index f9197a178be81..d80743d3f9150 100644 --- a/auto-random.md +++ b/auto-random.md @@ -142,7 +142,7 @@ This attribute supports forward compatibility, namely, downgrade compatibility. Pay attention to the following restrictions when you use `AUTO_RANDOM`: -- Specify this attribute for the primary key column **ONLY** of integer type. Otherwise, an error might occur. In addition, when the attribute of the primary key is `NONCLUSTERED`, `AUTO_RANDOM` is not supported even on the integer primary key. For more details about the primary key of `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). +- Specify this attribute for the primary key column **ONLY** of integer type. Otherwise, an error might occur. In addition, when the attribute of the primary key is `NONCLUSTERED`, `AUTO_RANDOM` is not supported even on the integer primary key. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). - You cannot use `ALTER TABLE` to modify the `AUTO_RANDOM` attribute, including adding or removing this attribute. - You cannot change the column type of the primary key column that is specified with `AUTO_RANDOM` attribute. - You cannot specify `AUTO_RANDOM` and `AUTO_INCREMENT` for the same column at the same time. diff --git a/constraints.md b/constraints.md index 626187edd3463..8ec916d6a8f3d 100644 --- a/constraints.md +++ b/constraints.md @@ -269,7 +269,7 @@ ALTER TABLE t5 DROP PRIMARY KEY; Query OK, 0 rows affected (0.10 sec) ``` -For more details about the primary key of `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). +For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ## FOREIGN KEY diff --git a/mysql-compatibility.md b/mysql-compatibility.md index 2e1a11b96456f..19ec8cc790ba4 100644 --- a/mysql-compatibility.md +++ b/mysql-compatibility.md @@ -93,7 +93,7 @@ In TiDB, all supported DDL changes are performed online. Compared with DDL opera * 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. * Different types of indexes (`HASH|BTREE|RTREE|FULLTEXT`) are not supported, and will be parsed and ignored when specified. -* Adding/Dropping the primary key of `CLUSTERED` type is unsupported unless [`alter-primary-key`](/tidb-configuration-file.md#alter-primary-key) is enabled. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). +* Adding/Dropping the primary key of the `CLUSTERED` type is unsupported unless [`alter-primary-key`](/tidb-configuration-file.md#alter-primary-key) is enabled. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). * Changing the field type to its superset is unsupported. For example, TiDB does not support changing the field type from `INTEGER` to `VARCHAR`, or from `TIMESTAMP` to `DATETIME`. Otherwise, the error information `Unsupported modify column: type %d not match origin %d` might be output. * Change/Modify data type does not currently support "lossy changes", such as changing from BIGINT to INT. * Change/Modify decimal columns does not support changing the precision. diff --git a/sql-statements/sql-statement-add-index.md b/sql-statements/sql-statement-add-index.md index 1bfb27001c2ff..681a7c0dcfb3c 100644 --- a/sql-statements/sql-statement-add-index.md +++ b/sql-statements/sql-statement-add-index.md @@ -124,7 +124,7 @@ mysql> EXPLAIN SELECT * FROM t1 WHERE c1 = 3; * `VISIBLE/INVISIBLE` index is not supported (currently only the master branch actually supports this feature). * 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 `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). +* 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 diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 77ede19dd999a..79ab6d89b235e 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -96,7 +96,7 @@ The TiDB configuration file supports more options than command-line parameters. > **Note:** > -> This configuration item no longer takes effect. If you need to add or delete the primary key, use `NONCLUSTERED` instead. For more details about the primary key of `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). +> This configuration item no longer takes effect. If you need to add or delete the primary key, use `NONCLUSTERED` instead. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ### `server-version` From 3dd98752ae99a25256b9dfc5d2d6be0ac1d9aac1 Mon Sep 17 00:00:00 2001 From: JoyinQ <56883733+Joyinqin@users.noreply.github.com> Date: Fri, 26 Mar 2021 09:39:40 +0800 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> --- constraints.md | 2 +- mysql-compatibility.md | 2 +- sql-statements/sql-statement-drop-index.md | 2 +- troubleshoot-hot-spot-issues.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/constraints.md b/constraints.md index 8ec916d6a8f3d..564ff67452293 100644 --- a/constraints.md +++ b/constraints.md @@ -245,7 +245,7 @@ Query OK, 0 rows affected (0.10 sec) * Table `t3` failed to be created, because a table can only have one primary key. * Table `t4` was created successfully, because even though there can be only one primary key, TiDB supports defining multiple columns as the composite primary key. -In addition to the rules above, TiDB currently only supports adding and deleting the primary keys of `NONCLUSTERED`. For example: +In addition to the rules above, TiDB currently only supports adding and deleting the primary keys of the `NONCLUSTERED` type. For example: {{< copyable "sql" >}} diff --git a/mysql-compatibility.md b/mysql-compatibility.md index 19ec8cc790ba4..3291bd2d82e67 100644 --- a/mysql-compatibility.md +++ b/mysql-compatibility.md @@ -93,7 +93,7 @@ In TiDB, all supported DDL changes are performed online. Compared with DDL opera * 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. * Different types of indexes (`HASH|BTREE|RTREE|FULLTEXT`) are not supported, and will be parsed and ignored when specified. -* Adding/Dropping the primary key of the `CLUSTERED` type is unsupported unless [`alter-primary-key`](/tidb-configuration-file.md#alter-primary-key) is enabled. For more details about the primary key of `CLUSTERED`, refer to [clustered index](/clustered-indexes.md). +* 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). * Changing the field type to its superset is unsupported. For example, TiDB does not support changing the field type from `INTEGER` to `VARCHAR`, or from `TIMESTAMP` to `DATETIME`. Otherwise, the error information `Unsupported modify column: type %d not match origin %d` might be output. * Change/Modify data type does not currently support "lossy changes", such as changing from BIGINT to INT. * Change/Modify decimal columns does not support changing the precision. diff --git a/sql-statements/sql-statement-drop-index.md b/sql-statements/sql-statement-drop-index.md index 308d0922564ab..ad8f2bd1ec780 100644 --- a/sql-statements/sql-statement-drop-index.md +++ b/sql-statements/sql-statement-drop-index.md @@ -72,7 +72,7 @@ Query OK, 0 rows affected (0.30 sec) ## MySQL compatibility -* Deleting the primary key of the `CLUSTERED` type is not supported. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). +* Dropping the primary key of the `CLUSTERED` type is not supported. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ## See also diff --git a/troubleshoot-hot-spot-issues.md b/troubleshoot-hot-spot-issues.md index 1426623af511d..55d8c73148af6 100644 --- a/troubleshoot-hot-spot-issues.md +++ b/troubleshoot-hot-spot-issues.md @@ -106,7 +106,7 @@ ALTER TABLE:ALTER TABLE t SHARD_ROW_ID_BITS = 4; The value of `SHARD_ROW_ID_BITS` can be dynamically modified. The modified value only takes effect for newly written data. -For a table using a primary key of the `CLUSTERED` type, TiDB uses the primary key of the table as the RowID. At this time, the `SHARD_ROW_ID_BITS` option can not be used because it changes the RowID generation rules. For a table using the primary key of the `NONCLUSTERED` type, TiDB uses an automatically allocated 64-bit integer as the RowID. In this case, you can also use the `SHARD_ROW_ID_BITS` feature. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). +For the table with a primary key of the `CLUSTERED` type, TiDB uses the primary key of the table as the RowID. At this time, the `SHARD_ROW_ID_BITS` option cannot be used because it changes the RowID generation rules. For the table with the primary key of the `NONCLUSTERED` type, TiDB uses an automatically allocated 64-bit integer as the RowID. In this case, you can use the `SHARD_ROW_ID_BITS` feature. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). The following two load diagrams shows the case where two tables without primary keys use `SHARD_ROW_ID_BITS` to scatter hotspots. The first diagram shows the situation before scattering hotspots, while the second one shows the situation after scattering hotspots. From 71b1b1feabdd1228e893bae8153fa10c0c0fce8b Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Fri, 26 Mar 2021 10:04:33 +0800 Subject: [PATCH 6/7] Update tidb-configuration-file.md --- tidb-configuration-file.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 79ab6d89b235e..7a4f5b4715bad 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -96,7 +96,7 @@ The TiDB configuration file supports more options than command-line parameters. > **Note:** > -> This configuration item no longer takes effect. If you need to add or delete the primary key, use `NONCLUSTERED` instead. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). +> This configuration item has been deprecated, and currently only takes effect when the value of `@tidb_enable_clustered_index` is `INT_ONLY`.If you need to add or remove the primary key, use the `NONCLUSTERED` keyword instead when creating the table. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ### `server-version` From fc64a4166c7369b14e53423a659229ce04db453c Mon Sep 17 00:00:00 2001 From: JoyinQ <56883733+Joyinqin@users.noreply.github.com> Date: Fri, 26 Mar 2021 13:45:34 +0800 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> --- tidb-configuration-file.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 7a4f5b4715bad..c57980a49c92b 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -96,7 +96,7 @@ The TiDB configuration file supports more options than command-line parameters. > **Note:** > -> This configuration item has been deprecated, and currently only takes effect when the value of `@tidb_enable_clustered_index` is `INT_ONLY`.If you need to add or remove the primary key, use the `NONCLUSTERED` keyword instead when creating the table. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). +> This configuration item has been deprecated, and currently takes effect only when the value of `@tidb_enable_clustered_index` is `INT_ONLY`. If you need to add or remove the primary key, use the `NONCLUSTERED` keyword instead when creating the table. For more details about the primary key of the `CLUSTERED` type, refer to [clustered index](/clustered-indexes.md). ### `server-version`