From 6ac3583e05e8176e09d9c8d3b32f2b1ded4bca0a Mon Sep 17 00:00:00 2001 From: Joy Nag Date: Tue, 9 Aug 2022 13:39:35 +1000 Subject: [PATCH 1/8] Document require_primary_key system variable --- system-variables.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/system-variables.md b/system-variables.md index 52673a6ffc2ee..320cbf84cb777 100644 --- a/system-variables.md +++ b/system-variables.md @@ -429,6 +429,14 @@ This variable is an alias for `last_insert_id`. - Default value: `ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION` - This variable controls a number of MySQL compatibility behaviors. See [SQL Mode](/sql-mode.md) for more information. +### sql_require_primary_key New in TBD + +- Scope: SESSION | GLOBAL +- Default value: "OFF" +- This variable, when turned "ON" will prevent table creation without primary keys in a cluster. Behaves similar to sysvar + [sql_require_primary_key](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_require_primary_key) in MySQL 8.0 +- Can be useful with TiCDC based replication, as TiCDC silently ignores tables without primary keys atm + ### sql_select_limit New in v4.0.2 - Scope: SESSION | GLOBAL From 204e2d9941887f8db26305a6cbb42f3cfd69606c Mon Sep 17 00:00:00 2001 From: Joy Nag Date: Tue, 16 Aug 2022 07:10:07 +1000 Subject: [PATCH 2/8] PR feedback: Update doc to mention the sysvar prevents dropping of primary keys as well --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 320cbf84cb777..70ec802f20c3a 100644 --- a/system-variables.md +++ b/system-variables.md @@ -433,7 +433,7 @@ This variable is an alias for `last_insert_id`. - Scope: SESSION | GLOBAL - Default value: "OFF" -- This variable, when turned "ON" will prevent table creation without primary keys in a cluster. Behaves similar to sysvar +- This variable, when turned "ON" will prevent table creation without primary keys and dropping of primary keys in a cluster. Behaves similar to sysvar [sql_require_primary_key](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_require_primary_key) in MySQL 8.0 - Can be useful with TiCDC based replication, as TiCDC silently ignores tables without primary keys atm From 3fae4c539e021397379fe35efe97b29b309d0d00 Mon Sep 17 00:00:00 2001 From: Joy Nag <452030+joycse06@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:13:36 +1000 Subject: [PATCH 3/8] Update system-variables.md Co-authored-by: Morgan Tocker --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 70ec802f20c3a..5df75398752e2 100644 --- a/system-variables.md +++ b/system-variables.md @@ -435,7 +435,7 @@ This variable is an alias for `last_insert_id`. - Default value: "OFF" - This variable, when turned "ON" will prevent table creation without primary keys and dropping of primary keys in a cluster. Behaves similar to sysvar [sql_require_primary_key](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_require_primary_key) in MySQL 8.0 -- Can be useful with TiCDC based replication, as TiCDC silently ignores tables without primary keys atm +- It is strongly recommended to enable this variable when using TiCDC. This is because replicating changes to a MySQL sink requires that tables have a primary key. ### sql_select_limit New in v4.0.2 From a71d435bcd99d108e0cae045ad0e86eaf62d84ca Mon Sep 17 00:00:00 2001 From: Joy Nag <452030+joycse06@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:13:44 +1000 Subject: [PATCH 4/8] Update system-variables.md Co-authored-by: Morgan Tocker --- system-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system-variables.md b/system-variables.md index 5df75398752e2..40fc40ffffc4c 100644 --- a/system-variables.md +++ b/system-variables.md @@ -433,8 +433,8 @@ This variable is an alias for `last_insert_id`. - Scope: SESSION | GLOBAL - Default value: "OFF" -- This variable, when turned "ON" will prevent table creation without primary keys and dropping of primary keys in a cluster. Behaves similar to sysvar - [sql_require_primary_key](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_require_primary_key) in MySQL 8.0 +- When enabled, this variable enforces that tables must have a primary key. Attempting to create or alter a table to not have a primary key will return an error. +- This feature is based on the similarly named [`sql_require_primary_key`](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_require_primary_key) in MySQL 8.0. - It is strongly recommended to enable this variable when using TiCDC. This is because replicating changes to a MySQL sink requires that tables have a primary key. ### sql_select_limit New in v4.0.2 From 5638120da91dbcc93c2b63a016539e4e0abd40dd Mon Sep 17 00:00:00 2001 From: Joy Nag <452030+joycse06@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:13:57 +1000 Subject: [PATCH 5/8] Update system-variables.md Co-authored-by: Morgan Tocker --- system-variables.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 40fc40ffffc4c..b3df27f53ea02 100644 --- a/system-variables.md +++ b/system-variables.md @@ -432,7 +432,9 @@ This variable is an alias for `last_insert_id`. ### sql_require_primary_key New in TBD - Scope: SESSION | GLOBAL -- Default value: "OFF" +- Persists to cluster: Yes +- Type: Boolean +- Default value: `OFF` - When enabled, this variable enforces that tables must have a primary key. Attempting to create or alter a table to not have a primary key will return an error. - This feature is based on the similarly named [`sql_require_primary_key`](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_require_primary_key) in MySQL 8.0. - It is strongly recommended to enable this variable when using TiCDC. This is because replicating changes to a MySQL sink requires that tables have a primary key. From 26d7e4eef620d0537f262b90d3e294f10909dd87 Mon Sep 17 00:00:00 2001 From: Joy Nag Date: Thu, 18 Aug 2022 11:52:26 +1000 Subject: [PATCH 6/8] Add expected version to be v6.3 --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index b3df27f53ea02..1a3aa73c3bf01 100644 --- a/system-variables.md +++ b/system-variables.md @@ -429,7 +429,7 @@ This variable is an alias for `last_insert_id`. - Default value: `ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION` - This variable controls a number of MySQL compatibility behaviors. See [SQL Mode](/sql-mode.md) for more information. -### sql_require_primary_key New in TBD +### sql_require_primary_key New in v6.3 - Scope: SESSION | GLOBAL - Persists to cluster: Yes From 58abe84b287912b490257553a05329b2fa11dce1 Mon Sep 17 00:00:00 2001 From: Joy Nag <452030+joycse06@users.noreply.github.com> Date: Thu, 29 Sep 2022 07:20:07 +1000 Subject: [PATCH 7/8] Update system-variables.md Co-authored-by: shichun-0415 <89768198+shichun-0415@users.noreply.github.com> --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 1a3aa73c3bf01..fa3af15eb09d3 100644 --- a/system-variables.md +++ b/system-variables.md @@ -429,7 +429,7 @@ This variable is an alias for `last_insert_id`. - Default value: `ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION` - This variable controls a number of MySQL compatibility behaviors. See [SQL Mode](/sql-mode.md) for more information. -### sql_require_primary_key New in v6.3 +### sql_require_primary_key New in v6.3.0 - Scope: SESSION | GLOBAL - Persists to cluster: Yes From b3a5f5742d87d779b5931baeaa5989b61be30c7d Mon Sep 17 00:00:00 2001 From: Joy Nag <452030+joycse06@users.noreply.github.com> Date: Thu, 29 Sep 2022 07:20:13 +1000 Subject: [PATCH 8/8] Update system-variables.md Co-authored-by: shichun-0415 <89768198+shichun-0415@users.noreply.github.com> --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index fa3af15eb09d3..695e5aba03fc8 100644 --- a/system-variables.md +++ b/system-variables.md @@ -435,7 +435,7 @@ This variable is an alias for `last_insert_id`. - Persists to cluster: Yes - Type: Boolean - Default value: `OFF` -- When enabled, this variable enforces that tables must have a primary key. Attempting to create or alter a table to not have a primary key will return an error. +- This variable controls whether to enforce the requirement that a table has a primary key. After this variable is enabled, attempting to create or alter a table without a primary key will produce an error. - This feature is based on the similarly named [`sql_require_primary_key`](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_require_primary_key) in MySQL 8.0. - It is strongly recommended to enable this variable when using TiCDC. This is because replicating changes to a MySQL sink requires that tables have a primary key.