Skip to content

*: add document for column-level masking policy feature#22613

Open
tiancaiamao wants to merge 15 commits into
masterfrom
column-masking-policy
Open

*: add document for column-level masking policy feature#22613
tiancaiamao wants to merge 15 commits into
masterfrom
column-masking-policy

Conversation

@tiancaiamao

@tiancaiamao tiancaiamao commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

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.

  • 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)
  • v5.4 (TiDB 5.4 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

… Grafana

This commit addresses issue #21768 by adding a new section to document
the default login credentials for TiDB Dashboard and Grafana when using
TiUP playground.

Changes:
- Add 'Access TiDB Dashboard and Grafana' section
- Document TiDB Dashboard default credentials (root, empty password)
- Document Grafana default credentials (admin/admin)
- Add note about using updated root password if changed
@ti-chi-bot ti-chi-bot Bot added the missing-translation-status This PR does not have translation status info. label Mar 23, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces comprehensive documentation for the new column-level masking policy feature in TiDB. This feature is designed to enhance data security and compliance by allowing sensitive data to be masked at the column level, with masking rules configurable based on user roles and privileges. The documentation covers the feature's functionality, management, and various masking options, ensuring users can effectively implement and manage data protection.

Highlights

  • New Documentation for Column-Level Masking Policy: A comprehensive document has been added to explain the new column-level masking policy feature in TiDB, enhancing data security and compliance.
  • Detailed Feature Explanation: The new documentation provides an in-depth overview of the masking policy, including its purpose, key characteristics, and benefits for protecting sensitive data.
  • Policy Management and Syntax: Instructions are provided for creating, modifying, enabling, disabling, and dropping masking policies, along with the necessary SQL syntax and required privileges.
  • Built-in Masking Functions: Four dedicated built-in functions (MASK_PARTIAL, MASK_FULL, MASK_NULL, MASK_DATE) are detailed, offering various methods for data redaction with examples for different data types.
  • Conditional Masking and Restrictions: The document explains how to implement conditional masking based on user identity (current_user()) and roles (current_role()), and how to use the RESTRICT ON clause to prevent data exfiltration during specific SQL operations.
  • Behavioral Considerations and Limitations: Key aspects such as at-result masking, supported column types, and current limitations (e.g., no masking on views or temporary tables) are clearly outlined.
  • Table of Contents Update: The main Table of Contents (TOC.md) has been updated to include a direct link to the new column-level masking policy documentation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 23, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces comprehensive documentation for TiDB's new Column-Level Masking Policy feature, including its overview, required privileges, syntax for creation and management, details on built-in masking functions (MASK_PARTIAL, MASK_FULL, MASK_NULL, MASK_DATE), conditional masking based on user/role, RESTRICT ON semantics, behavior considerations, and MySQL compatibility notes. The review comments suggest improvements to enhance the documentation's clarity, maintain an active voice, and ensure consistent markdown formatting.

Comment thread column-level-masking-policy.md Outdated
Comment thread column-level-masking-policy.md
Comment thread column-level-masking-policy.md Outdated
Comment thread column-level-masking-policy.md Outdated
Comment thread column-level-masking-policy.md Outdated
@qiancai qiancai added the v9.0-beta.3 This PR/issue applies to TiDB v9.0-beta.3. label Mar 24, 2026
@tiancaiamao

Copy link
Copy Markdown
Contributor Author

Ref pingcap/tidb#65744

Comment thread column-level-masking-policy.md Outdated
Comment thread column-level-masking-policy.md Outdated
Comment thread column-level-masking-policy.md Outdated
@qiancai qiancai self-assigned this May 8, 2026
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ti-chi-bot

ti-chi-bot Bot commented May 9, 2026

Copy link
Copy Markdown

[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 ask for approval from qiancai. 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

tiancaiamao and others added 3 commits May 9, 2026 14:35
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: tiancaiamao <tiancaiamao@gmail.com>
@tiancaiamao
tiancaiamao requested a review from bb7133 May 9, 2026 07:38
@qiancai
qiancai force-pushed the column-masking-policy branch from 9fa5c36 to dc69955 Compare May 26, 2026 06:57
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Auto-sync failed

Source PR: https://github.com/pingcap/docs-cn/pull/21454/files/e83787336ac1427368e6e86196a7def3133e57d4..fc90d60de2812fd073a664777d25894218c5ed35
Target PR: #22613

Translated changes were not pushed to the target branch. Please check the workflow logs for details.

Synced from: https://github.com/pingcap/docs-cn/pull/21454/files/e83787336ac1427368e6e86196a7def3133e57d4..fc90d60de2812fd073a664777d25894218c5ed35
Target PR: #22613
AI Provider: azure

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Auto-sync completed successfully

Source PR: https://github.com/pingcap/docs-cn/pull/21454/files/e83787336ac1427368e6e86196a7def3133e57d4..fc90d60de2812fd073a664777d25894218c5ed35
Target PR: #22613

English documentation has been updated based on Chinese documentation changes.

@qiancai

qiancai commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

/gemini review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

| `TableName` | The name of the target table. |
| `Identifier` (in parentheses) | The name of the target column. Each column can be bound to at most one masking policy. |
| `Expression` | The masking expression. You can use built-in masking functions such as `MASK_FULL`, `MASK_PARTIAL`, `MASK_NULL`, and `MASK_DATE`, or use a custom expression containing `CURRENT_USER()` or `CURRENT_ROLE()` to implement identity-based conditional masking. |
| `RESTRICT ON (...)` | Optional. Restricts specific operations on the masked column to prevent the original data from being obtained indirectly through these operations. The operations that can be restricted include `INSERT INTO SELECT`, `UPDATE SELECT`, `DELETE SELECT`, and `CTAS`. |

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
| `RESTRICT ON (...)` | Optional. Restricts specific operations on the masked column to prevent the original data from being obtained indirectly through these operations. The operations that can be restricted include `INSERT INTO SELECT`, `UPDATE SELECT`, `DELETE SELECT`, and `CTAS`. |
| `RESTRICT ON (...)` | Optional. Restricts specific operations on the masked column to prevent the original data from being obtained indirectly through these operations. The operations that can be restricted include `INSERT_INTO_SELECT`, `UPDATE_SELECT`, `DELETE_SELECT`, and `CTAS`. |


# CREATE MASKING POLICY

`CREATE MASKING POLICY` creates a [data masking policy](column-level-masking-policy.md) for columns in a table. After you enable a masking policy for a column, TiDB masks the results of that column according to the policy definition when returning query results, preventing sensitive data from being viewed by unauthorized users.

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
`CREATE MASKING POLICY` creates a [data masking policy](column-level-masking-policy.md) for columns in a table. After you enable a masking policy for a column, TiDB masks the results of that column according to the policy definition when returning query results, preventing sensitive data from being viewed by unauthorized users.
`CREATE MASKING POLICY` creates a [data masking policy](/column-level-masking-policy.md) for columns in a table. After you enable a masking policy for a column, TiDB masks the results of that column according to the policy definition when returning query results, preventing sensitive data from being viewed by unauthorized users.


### Filter results using the WHERE clause

You can also use the `WHERE` clause to filter masking policies that meet specific conditions. For example, you can view enabled masking policies on the `employee` table as follows:

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
You can also use the `WHERE` clause to filter masking policies that meet specific conditions. For example, you can view enabled masking policies on the `employee` table as follows:
You can also use the `WHERE` clause to filter masking policies that meet specific conditions. For example, you can view enabled masking policies on the `employees` table as follows:


### Manage column-level masking policies

You can use `ALTER TABLE` to manage [column-level masking policies](column-level-masking-policy.md) on tables, including adding, enabling, disabling, modifying, and dropping masking policies.

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
You can use `ALTER TABLE` to manage [column-level masking policies](column-level-masking-policy.md) on tables, including adding, enabling, disabling, modifying, and dropping masking policies.
You can use `ALTER TABLE` to manage [column-level masking policies](/column-level-masking-policy.md) on tables, including adding, enabling, disabling, modifying, and dropping masking policies.


# SHOW MASKING POLICIES

The `SHOW MASKING POLICIES` statement lets you view information about the [Column-level masking policies](column-level-masking-policy.md) defined on a specified table.

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
The `SHOW MASKING POLICIES` statement lets you view information about the [Column-level masking policies](column-level-masking-policy.md) defined on a specified table.
The `SHOW MASKING POLICIES` statement lets you view information about the [Column-level masking policies](/column-level-masking-policy.md) defined on a specified table.

@bb7133 bb7133 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot

ti-chi-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

@bb7133: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

LGTM

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@qiancai

qiancai commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

hold this PR because the related code is not fully ready according to @tiancaiamao

@qiancai qiancai added translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed missing-translation-status This PR does not have translation status info. labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. v9.0-beta.3 This PR/issue applies to TiDB v9.0-beta.3.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants