Skip to content

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

Open
tiancaiamao wants to merge 3 commits intomasterfrom
column-masking-policy
Open

*: add document for column-level masking policy feature#22613
tiancaiamao wants to merge 3 commits intomasterfrom
column-masking-policy

Conversation

@tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Mar 23, 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.

  • 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
Copy link

ti-chi-bot bot commented Mar 23, 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 tangenta 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 the missing-translation-status This PR does not have translation status info. label Mar 23, 2026
@gemini-code-assist
Copy link
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
Copy link
Contributor

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

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.


## Overview

A masking policy is bound to a table column and evaluated at query result time. The policy uses SQL expressions to determine how to mask the data based on the current user's identity or role.
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve clarity and adhere to the active voice principle, consider rephrasing this sentence to specify that TiDB performs the action.

Repository Style Guide Reference: line 43 (Passive voice overuse)

Suggested change
A masking policy is bound to a table column and evaluated at query result time. The policy uses SQL expressions to determine how to mask the data based on the current user's identity or role.
TiDB binds a masking policy to a table column and evaluates it at query result time.

## Behavior considerations

### At-result masking

Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To maintain an active voice throughout the documentation, specify that TiDB is the agent performing the action.

Repository Style Guide Reference: line 43 (Passive voice overuse)

Suggested change
TiDB applies masking policies **at result time**, which means:

Comment on lines +474 to +475
When you drop a column or table that has a masking policy, the policy is automatically removed from the system. When you rename a column or table, the masking policy remains bound to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve clarity and maintain an active voice, specify that TiDB performs these actions and clarify the target of the masking policy when renaming.

Repository Style Guide Reference: line 43 (Passive voice overuse)

Suggested change
When you drop a column or table that has a masking policy, the policy is automatically removed from the system. When you rename a column or table, the masking policy remains bound to it.
When you drop a column or table that has a masking policy, TiDB automatically removes the policy from the system. When you rename a column or table, the masking policy remains bound to the renamed column or table.

Comment on lines +148 to +151
- **String** → Returns a string of the same length with all characters replaced by `'X'`
- **Date/DATETIME/TIMESTAMP** → Returns `1970-01-01` (preserving original type and fractional seconds precision)
- **Duration** → Returns `00:00:00`
- **YEAR** → Returns `1970`
Copy link
Contributor

Choose a reason for hiding this comment

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

low

For better readability and consistent markdown, please rephrase these lines to avoid the non-standard arrow symbol and use a colon instead.

Repository Style Guide Reference: line 34 (Code snippets, command names, options, and paths should be in backticks (`).)

Suggested change
- **String** Returns a string of the same length with all characters replaced by `'X'`
- **Date/DATETIME/TIMESTAMP** Returns `1970-01-01` (preserving original type and fractional seconds precision)
- **Duration** Returns `00:00:00`
- **YEAR** Returns `1970`
- **String**: Returns a string of the same length with all characters replaced by `'X'`
- **Date/DATETIME/TIMESTAMP**: Returns `1970-01-01` (preserving original type and fractional seconds precision)
- **Duration**: Returns `00:00:00`
- **YEAR**: Returns `1970`

Comment on lines +218 to +220
- **Types**: DATE, DATETIME, TIMESTAMP
- **Placeholders**: The `date_literal` follows format `'YYYY-MM-DD'` where Y/M/D components can be preserved or fixed values for redaction
- **Time Component**: Hours, minutes, and seconds are reset to `00:00:00`
Copy link
Contributor

Choose a reason for hiding this comment

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

low

For improved sentence structure and clarity, consider rephrasing this description.

Repository Style Guide Reference: line 15 (Logical flow and sentence structure)

Suggested change
- **Types**: DATE, DATETIME, TIMESTAMP
- **Placeholders**: The `date_literal` follows format `'YYYY-MM-DD'` where Y/M/D components can be preserved or fixed values for redaction
- **Time Component**: Hours, minutes, and seconds are reset to `00:00:00`
- **Placeholders**: The `date_literal` follows the `'YYYY-MM-DD'` format. Y/M/D components can be preserved or fixed values for redaction
- **Time Component**: Hours, minutes, and seconds are reset to `00:00:00`

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 23, 2026

@tiancaiamao: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-verify cadf28d link true /test pull-verify

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant