Skip to content

ddl: Fix default value filling with finer granularity (#10682)#10690

Open
ti-chi-bot wants to merge 7 commits intopingcap:release-7.5from
ti-chi-bot:cherry-pick-10682-to-release-7.5
Open

ddl: Fix default value filling with finer granularity (#10682)#10690
ti-chi-bot wants to merge 7 commits intopingcap:release-7.5from
ti-chi-bot:cherry-pick-10682-to-release-7.5

Conversation

@ti-chi-bot
Copy link
Member

@ti-chi-bot ti-chi-bot commented Jan 29, 2026

This is an automated cherry-pick of #10682

What problem does this PR solve?

Issue Number: close #10680

Problem Summary:

DROP DATABASE IF EXISTS db_1483421321;
CREATE DATABASE db_1483421321;
USE db_1483421321;
CREATE TABLE t0(c0 TINYINT, handle INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(handle));
ALTER TABLE t0 SET TIFLASH REPLICA 1;
-- this SLEEP will make sure the case always reproducable, it not, make it longer
select sleep(5);
SELECT /*+ read_from_storage(tiflash[t0]) */ * FROM t0 order by 1;
SELECT /*+ read_from_storage(tikv[t0]) */ * FROM t0 order by 1;

ALTER TABLE t0 ADD COLUMN c1 DECIMAL NULL;
ALTER TABLE t0 ADD COLUMN c2 FLOAT NULL DEFAULT 0.0795439693286002;
ALTER TABLE t0 ADD COLUMN c5 DECIMAL NOT NULL;
ALTER TABLE t0 ADD COLUMN c4 DECIMAL DEFAULT 247262911;
ALTER TABLE t0 MODIFY COLUMN c2 FLOAT NOT NULL;
ALTER TABLE t0 MODIFY COLUMN c5 DECIMAL NULL;
ALTER TABLE t0 MODIFY COLUMN c1 BIGINT DEFAULT -56083770 NOT NULL;
-- first insert
INSERT IGNORE INTO t0 (c1, c2, c5, c4) VALUES (-2051270087, 0.44141045099028775, 0.0, 15523);
UPDATE t0 SET c5 = 870337888;

ALTER TABLE t0 MODIFY COLUMN c1 BIGINT NULL;
-- second insert
INSERT INTO t0 (c2, c5, c4) VALUES (0.004406799693866592, 0.8752311290235516, 14652);

---- TiFlash data inconsistent with TiKV after modifying a column from NOT NULL to NULL
-- in tiflash, handle=2, c1=0
SELECT /*+ read_from_storage(tiflash[t0]) */ * FROM t0 order by 1;
+--------+--------+-------------+--------------+-----------+-------+
| c0     | handle | c1          | c2           | c5        | c4    |
+--------+--------+-------------+--------------+-----------+-------+
| <null> | 1      | -2051270087 | 0.44141045   | 870337888 | 15523 |
| <null> | 2      | 0           | 0.0044067996 | 1         | 14652 |
+--------+--------+-------------+--------------+-----------+-------+

-- in tikv, handle=2, c1=null
SELECT /*+ read_from_storage(tikv[t0]) */ * FROM t0 order by 1;
+--------+--------+-------------+--------------+-----------+-------+
| c0     | handle | c1          | c2           | c5        | c4    |
+--------+--------+-------------+--------------+-----------+-------+
| <null> | 1      | -2051270087 | 0.44141045   | 870337888 | 15523 |
| <null> | 2      | <null>      | 0.0044067996 | 1         | 14652 |
+--------+--------+-------------+--------------+-----------+-------+

Root cause

  • TiDB can omit a column in the row value when the column is NULL and both DefaultValue and OriginDefaultValue are nil (see TiDB CanSkip).
  • If TiFlash is still on the old schema (column is NOT NULL), addDefaultValueToColumnIfPossible currently accepts the missing column and fills defaultValueToField().
  • When origin_default_value is empty, defaultValueToField() for NOT NULL falls back to GenDefaultField (zero), so TiFlash returns 0 while TiKV (new schema) returns NULL.

What is changed and how it works?

ddl: Fix default value filling with finer granularity
- Tightens addDefaultValueToColumnIfPossible
  - For NOT NULL missing columns, force_decode=false now returns false unless there is an origin default.
  - This forces a schema sync instead of silently filling 0.
  - force_decode=true still fills a default value (best-effort).

With old schema (NOT NULL, no origin default), missing column now triggers schema sync. After schema sync, column becomes nullable, so missing column can be decode and stored in tiflash with NULL, matching TiKV.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Fixed a TiFlash/TiKV mismatch after altering a column from NOT NULL to NULL

Summary by CodeRabbit

  • Bug Fixes

    • More robust handling of missing columns during row decoding: respects NOT NULL/origin-default semantics, primary-key decoding, force-decode behavior, and now requests schema synchronization when filling is impossible.
    • Improved consistency for nullability transitions across storage backends.
  • New Features

    • Public APIs to detect and convert origin-default values for reliable default filling.
  • Tests

    • New unit and end-to-end tests covering default-value filling, region decoding, and alter-nullability scenarios.
  • Chores

    • CLI tooling now detects and reports the configured code-formatter version.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. labels Jan 29, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jan 29, 2026

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be LGTMed and approved by the reviewers firstly.
  2. For pull requests to TiDB-x branches, it must have no failed tests.
  3. AFTER it has lgtm and approved labels, please wait for the cherry-pick merging approval from triage owners.
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.

@ti-chi-bot
Copy link
Member Author

@JaySon-Huang This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jan 29, 2026

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

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 ti-community-infra/tichi repository.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

Centralized row-decoding now backfills missing columns using origin-default/default/NULL rules or requests a schema sync via a new helper; adds ColumnInfo helpers for origin-default access and safe parsing; documents RegionBlockReader decoding positions; and extends unit and full-stack tests covering nullability and default-filling behaviors.

Changes

Cohort / File(s) Summary
Row decoding helper & usage
dbms/src/TiDB/Decode/RowCodec.cpp
Add addDefaultValueToColumnIfPossible and integrate it into V1/V2 decoding paths to fill missing columns or return false to trigger schema sync based on force_decode, PK semantics, NOT NULL and origin/default logic.
Column schema helpers
dbms/src/TiDB/Schema/TiDB.h, dbms/src/TiDB/Schema/TiDB.cpp
Add ColumnInfo::hasOriginDefaultValue() and ColumnInfo::defaultValueToField() with type-aware parsing; guard JSON deserialization of comments and certain fields to avoid overwriting when absent/null.
Region block reader (comments only)
dbms/src/Storages/KVStore/Decode/RegionBlockReader.cpp
Add explanatory comments clarifying mapping between read_column_ids, schema_snapshot, and block insertion positions; no functional change.
RegionBlockReader tests
dbms/src/Storages/KVStore/tests/gtest_region_block_reader.cpp
Add TEST_F(RegionBlockReaderTest, ReadFromRegionDefaultValue) exercising NOT NULL/nullable/origin-default permutations and force_decode behavior with hex-encoded region entries.
Schema tests
dbms/src/TiDB/Schema/tests/gtest_table_info.cpp
Expand origin_default parsing tests; assert hasOriginDefaultValue() and defaultValueToField() results across multiple JSON scenarios.
RowCodec test utils & fullstack tests
dbms/src/TiDB/tests/RowCodecTestUtils.h, tests/fullstack-test2/ddl/alter_column_nullable.test
Set generated ColumnInfo.state to StatePublic; add full-stack scenarios validating TiFlash vs TiKV consistency across nullability and default transitions.
Tooling
format-diff.py
Add clang-format detection helpers, --clang_format CLI option, and print selected clang-format version before formatting.

Sequence Diagram(s)

sequenceDiagram
    participant Decoder as Row Decoder
    participant Helper as addDefaultValueToColumnIfPossible
    participant ColInfo as ColumnInfo
    participant Block as Block

    Decoder->>Decoder: parse encoded row, detect column id mismatch
    Decoder->>Helper: request fill(column_info, block_pos, force_decode, ignore_pk_if_absent)
    activate Helper
    Helper->>ColInfo: hasOriginDefaultValue()
    ColInfo-->>Helper: bool
    alt origin-default present
        Helper->>ColInfo: defaultValueToField()
        ColInfo-->>Helper: Field
        Helper->>Block: insert Field at block_pos
        Helper-->>Decoder: success
    else origin-default absent
        alt nullable or force_decode permits
            Helper->>Block: insert NULL or generated default
            Helper-->>Decoder: success
        else cannot fill
            Helper-->>Decoder: failure (request schema sync)
        end
    end
    deactivate Helper
    Decoder->>Decoder: continue decoding or trigger schema sync
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • #10689 — Overlapping changes introducing the RowCodec helper and ColumnInfo origin-default helpers plus RegionBlockReader test updates.
  • #10687 — Related edits modifying default-filling logic and integrating the helper into decoding paths.
  • #10682 — Similar modifications to decoding/default handling and tests; likely a closely related sibling PR.

Suggested labels

approved, lgtm, needs-cherry-pick-release-7.5

Suggested reviewers

  • JinheLin
  • kolafish
  • gengliqi

Poem

🐇
I hop through rows where gaps appear,
I tuck in defaults when the path is clear,
If schemas shift and I cannot cope,
I raise a flag and hold on hope,
Then nibble till the data's dear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing default value filling with finer granularity in DDL operations.
Description check ✅ Passed The description comprehensively addresses all template sections: problem statement with issue number, detailed root cause analysis, specific changes made with commit message, completed checklist showing unit and integration tests included, confirmed side effects, and release note provided.
Linked Issues check ✅ Passed The PR fully addresses issue #10680 by implementing the exact fix required: tightening addDefaultValueToColumnIfPossible to force schema sync for missing NOT NULL columns without origin defaults, resolving the TiFlash/TiKV data inconsistency.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the default value filling logic and supporting the schema synchronization mechanism; no unrelated or extraneous modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@dbms/src/Storages/KVStore/Decode/RegionBlockReader.cpp`:
- Around line 114-151: The file contains unresolved merge conflict markers that
inserted a VersionColResolver<RegionUncommittedDataList> specialization and a
stray "private:" block inside RegionBlockReader::readImpl, breaking compilation;
move the entire VersionColResolver<RegionUncommittedDataList> struct out of the
readImpl function scope to namespace/global scope and remove the conflict
markers, then restore readImpl to use the correct column-id mapping (replace the
residual sorted_column_id_with_pos with schema_snapshot->getColId2BlockPosMap()
as used in the incoming change) so VersionColResolver,
RegionUncommittedDataList, and RegionBlockReader::readImpl are correctly defined
and compile.

In `@dbms/src/TiDB/Decode/RowCodec.cpp`:
- Around line 418-424: Resolve the leftover Git conflict markers inside
addDefaultValueToColumnIfPossible by removing the <<<<<<<, =======, and >>>>>>>
lines and consolidating the two comment variants into a single coherent comment
(e.g., "fallthrough for best-effort fill when force_decode == true" or the
longer explanation about filling primary-key-flagged columns for older schemas)
so the file compiles; ensure only one comment remains above the fallthrough
logic and no conflict markers remain.

In `@dbms/src/TiDB/Schema/tests/gtest_table_info.cpp`:
- Around line 140-170: Remove the Git conflict markers and keep the new
ParseCase tests that validate origin_default parsing: delete the lines with
<<<<<<< HEAD, =======, and >>>>>>> 01b12dd900 and ensure both ParseCase blocks
(the ones asserting col_3.defaultValueToField() == "100" and == "200") remain
intact; verify the tests still reference TableInfo, getColumnInfo(3), and the
assertions on col_3.tp, hasNotNullFlag(), hasOriginDefaultValue(), and
defaultValueToField() so the origin_default parsing tests for issue `#10663`
compile and run.
🧹 Nitpick comments (1)
dbms/src/Storages/KVStore/tests/gtest_region_block_reader.cpp (1)

694-866: Comprehensive test coverage for default value handling in region decoding.

This test thoroughly validates the fix for issue #10680 by covering all key scenarios:

  • NOT NULL columns without origin_default (schema sync required)
  • NOT NULL columns with origin_default (can decode without force)
  • NOT NULL columns with non-public state (schema sync required even with origin_default)
  • Nullable columns (NULL preserved for missing values)

The test correctly verifies both force_decode=false and force_decode=true paths for each scenario.

Minor: Lines 818 and 844 have a typo "thrid" → "third" in comments.

✏️ Fix typos in comments
             // the thrid elem is filled wih origin_default
+            // the third elem is filled with origin_default

(Apply similar fix at line 844)

Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jan 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 ask for approval from jayson-huang. 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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@dbms/src/Storages/KVStore/tests/gtest_region_block_reader.cpp`:
- Around line 818-819: Fix the typo in the comment above the createColumn<Int64>
call: change "thrid" to "third" (and correct "wih" to "with" if present) so the
comment reads e.g. "the third elem is filled with origin_default" near the
createColumn<Int64>({-2051270087, -2051270087, -56083770})); this touches the
comment text only—no code changes required.
- Around line 844-845: Fix the typo in the inline comment next to the
createColumn<Int64> call in the gtest_region_block_reader test: change "thrid
elem is filled wih origin_default" to "third elem is filled with origin_default"
near the createColumn<Int64>({-2051270087, -2051270087, -56083770}) invocation
so the test comment reads correctly.
🧹 Nitpick comments (1)
dbms/src/TiDB/Schema/tests/gtest_table_info.cpp (1)

140-167: Good test coverage for origin_default parsing.

These new ParseCase tests properly validate the hasOriginDefaultValue() and defaultValueToField() methods for the fix described in issue #10663.

Note: The second ParseCase (lines 155-167) is missing the ASSERT_TRUE(col_3.hasOriginDefaultValue()) assertion that the first case has at line 151. Consider adding it for consistency.

📝 Suggested addition for consistency
                     auto col_3 = table_info.getColumnInfo(3);
                     ASSERT_EQ(col_3.tp, TiDB::TP::TypeVarchar);
                     ASSERT_TRUE(col_3.hasNotNullFlag());
+                    ASSERT_TRUE(col_3.hasOriginDefaultValue());
                     // The "origin_default" is "200", which is used for filling default value for old rows that is inserted before this column is added.
                     ASSERT_EQ(col_3.defaultValueToField().get<String>(), "200");

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@dbms/src/Storages/KVStore/tests/gtest_region_block_reader.cpp`:
- Around line 762-799: The comment and assertion conflict: for the schema
referenced by
getDecodingStorageSchemaSnapshot(table_info_c1_not_null_no_origin_default) the
stored origin default is "-56083770" but the test asserts 0; decide which
behavior is intended and make them consistent—if the implementation
intentionally fills a zero fallback for missing not-null defaults, update the
comment near the RegionBlockReader/read test to say “fills zero fallback for
missing not-null default” and keep ASSERT_COLUMN_EQ against
createColumn<Int64>({0,...}) (adjust values accordingly); otherwise update the
ASSERT_COLUMN_EQ to expect createColumn<Int64>({-56083770,-56083770,0}) (or the
correct per-row default) and change the comment to say “fills the origin default
(-56083770) for c1.” Ensure changes reference the test using RegionBlockReader,
reader.read, and
getDecodingStorageSchemaSnapshot(table_info_c1_not_null_no_origin_default).
🧹 Nitpick comments (3)
dbms/src/Storages/KVStore/tests/gtest_region_block_reader.cpp (3)

697-750: Rename new locals to camelCase to match style.

These new locals are snake_case in a C++ test file (e.g., table_info_c1_not_null_no_origin_default, region_start_key, data_list_read). Please rename to camelCase to align with the codebase conventions. The snippet below shows one example; apply similarly to the other locals.

🔧 Example rename
-    TableInfo table_info_c1_not_null_no_origin_default(
+    TableInfo tableInfoC1NotNullNoOriginDefault(
         R"({"cols":[{"id":1,"name":{"L":"c0","O":"c0"},"offset":0,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":4,"Tp":1}},{"id":2,"name":{"L":"handle","O":"handle"},"offset":1,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":515,"Flen":11,"Tp":3}},{"default":"-56083770","id":7,"name":{"L":"c1","O":"c1"},"offset":2,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":1,"Flen":20,"Tp":8}},{"id":4,"name":{"L":"c2","O":"c2"},"offset":3,"origin_default":"0.07954397","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":-1,"Flag":4097,"Flen":12,"Tp":4}},{"id":5,"name":{"L":"c5","O":"c5"},"offset":4,"origin_default":"0","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":10,"Tp":246}},{"default":"247262911","id":6,"name":{"L":"c4","O":"c4"},"offset":5,"origin_default":"247262911","state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Flag":0,"Flen":10,"Tp":246}}],"id":636,"index_info":[],"is_common_handle":false,"keyspace_id":4294967295,"name":{"L":"t0","O":"t0"},"pk_is_handle":true,"state":5,"tiflash_replica":{"Available":true,"Count":1},"update_timestamp":463845180343844895})",
         NullspaceID);
@@
-    auto decoding_schema = getDecodingStorageSchemaSnapshot(table_info_c1_not_null_no_origin_default);
+    auto decoding_schema = getDecodingStorageSchemaSnapshot(tableInfoC1NotNullNoOriginDefault);

As per coding guidelines, Method and variable names in C++ must use camelCase (e.g., readBlock, totalBytes).


744-747: Prefer ColumnFamilyType::Write over string literal.

Using a string literal here is more error‑prone and inconsistent with the earlier test in this file. Consider using the enum to keep it type‑safe.

♻️ Suggested change
-        region->insert("write", TiKVKey(bytesFromHexString(k)), TiKVValue(bytesFromHexString(v)));
+        region->insert(ColumnFamilyType::Write, TiKVKey(bytesFromHexString(k)), TiKVValue(bytesFromHexString(v)));

855-858: Use the fixture logger and add context to decoded‑block logs.

This test already has a LoggerPtr logger member; using it and adding region_id improves consistency and traceability. Apply similarly to the other LOG_INFO calls in this test.

🔍 Example adjustment
-        LOG_INFO(
-            Logger::get(),
-            "Decoded block:\n{}",
-            DB::tests::getColumnsContent(res_block.getColumnsWithTypeAndName()));
+        LOG_INFO(
+            logger,
+            "Decoded block for region_id={}:\n{}",
+            region_id,
+            DB::tests::getColumnsContent(res_block.getColumnsWithTypeAndName()));

As per coding guidelines, Use LoggerPtr and LOG_INFO(log, ...) with relevant context (e.g., region_id, table_id) for logging in storage engine code.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@format-diff.py`:
- Around line 32-39: The try_find_clang_format function currently only tries
'clang-format-13' and can return a non-existent binary; update
try_find_clang_format to include 'clang-format' as a fallback candidate (e.g.,
candidates = ['clang-format-13', 'clang-format'] and still honor exec_path at
front) and return None if no executable is found. Then update
get_clang_format_version to check the result of try_find_clang_format (or accept
None) and raise a clear FileNotFoundError with a descriptive message if no
clang-format binary is found instead of attempting to execute a missing binary.
Ensure you reference try_find_clang_format and get_clang_format_version when
making these changes.

@JaySon-Huang JaySon-Huang force-pushed the cherry-pick-10682-to-release-7.5 branch from d590bf3 to 3ab5a7b Compare January 30, 2026 05:27
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@format-diff.py`:
- Around line 42-45: The function get_clang_format_version calls subprocess.run
but doesn't capture stdout, so proc.stdout is None and causes an AttributeError;
update the subprocess.run call in get_clang_format_version to capture output
(e.g., pass capture_output=True or stdout=subprocess.PIPE and text=True) and
then use proc.stdout.strip(); also handle subprocess.CalledProcessError by
either re-raising or logging a clear error so failures to run the clang-format
command are surfaced.
🧹 Nitpick comments (1)
format-diff.py (1)

102-108: Avoid shell concatenation when invoking clang-format.

Now that --clang_format is user-supplied, building a shell string can break on paths with spaces and invites quoting issues. Prefer list args and shell=False.

♻️ Suggested refactor
-            cmd = clang_format_cmd + ' -i {}'.format(file)
-            if subprocess.Popen(cmd, shell=True, cwd=tiflash_repo_path).wait():
+            cmd = [clang_format_cmd, '-i', file]
+            if subprocess.Popen(cmd, cwd=tiflash_repo_path).wait():
                 exit(-1)

@JaySon-Huang JaySon-Huang force-pushed the cherry-pick-10682-to-release-7.5 branch 2 times, most recently from 6f83936 to c2de343 Compare January 30, 2026 06:38
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang JaySon-Huang force-pushed the cherry-pick-10682-to-release-7.5 branch from 11deacf to fd83fae Compare February 3, 2026 06:04
@JaySon-Huang
Copy link
Contributor

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/cherry-pick-not-approved release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants