Skip to content

sysvar: add tidb_enable_strict_not_null_check#21600

Open
xhebox wants to merge 1 commit intopingcap:masterfrom
xhebox:var
Open

sysvar: add tidb_enable_strict_not_null_check#21600
xhebox wants to merge 1 commit intopingcap:masterfrom
xhebox:var

Conversation

@xhebox
Copy link
Copy Markdown
Contributor

@xhebox xhebox commented Apr 30, 2026

First-time contributors' checklist

What is changed, added or deleted? (Required)

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions (in Chinese).

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Signed-off-by: xhe <xw897002528@gmail.com>
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 30, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign icemap for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 30, 2026
Comment thread system-variables.md
Comment on lines +2489 to +2490
- 这个变量用来控制是否可以插入 `null` 到非空列,关闭时允许此类插入。该设置的目的是提供一个从 TiDB 早期版本升级的方法,因为早期版本在验证类型方面不太严格。
- 该变量的默认值 `ON` 与 MySQL 兼容。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 这个变量用来控制是否可以插入 `null` 到非空列,关闭时允许此类插入。该设置的目的是提供一个从 TiDB 早期版本升级的方法,因为早期版本在验证类型方面不太严格。
- 该变量的默认值 `ON` 与 MySQL 兼容。
该变量用于控制在向定义为 NOT NULL 的列插入 NULL 值时的校验行为。其设计初衷是为不同来源的集群迁移及版本升级提供兼容性支撑:
MySQL 兼容性:
ON (默认值):与 MySQL 8.0 的标准行为保持一致。对于 NOT NULL 约束执行严格校验,插入 NULL 值将直接触发错误。
OFF:模拟 MySQL 5.7 及其早期版本在非严格模式下的行为。允许向非空列插入 NULL,此时系统不会报错,而是自动赋予该列对应数据类型的隐式默认值(例如数字类型填充 0,字符串类型填充空字符串 "")。
升级兼容性:
TiDB 在早期版本中对非空约束的校验相对宽松。当从低版本 TiDB(如 v6.x、v7.x 等)升级至 v8.5 或更高版本时,如果存量业务逻辑依赖于这种“隐式赋默认值”的行为,开启此变量可能会导致原有 SQL 报错。
使用建议
对于新创建的集群,建议保持默认值 ON,以确保数据的严谨性并符合现代数据库标准。
如果是从 MySQL 5.7 迁移至 TiDB,或从 TiDB 早期版本平滑升级至高版本且无法立即修改业务逻辑,可将此变量设置为 OFF 以维持业务连续性。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants