Skip to content

table, executor, lightning: fix generated column TIMESTAMP index inconsistency across session time zones#66771

Closed
Desel72 wants to merge 24 commits intopingcap:masterfrom
Desel72:fix/issue-#66753
Closed

table, executor, lightning: fix generated column TIMESTAMP index inconsistency across session time zones#66771
Desel72 wants to merge 24 commits intopingcap:masterfrom
Desel72:fix/issue-#66753

Conversation

@Desel72
Copy link
Copy Markdown

@Desel72 Desel72 commented Mar 8, 2026

What problem does this PR solve?

Issue Number: close #66753

Problem Summary:
Generated column expressions referencing TIMESTAMP columns produce different values depending on session timezone, causing index-record inconsistency. For example, HOUR(ts_col) returns different values in UTC vs UTC-8 because TIMESTAMP values are stored in UTC but converted to session timezone on read. This leads to [tikv:8141] assertion failed errors and ADMIN CHECK TABLE failures.

What changed and how does it work?

Force UTC timezone when evaluating generated column expressions that depend on TIMESTAMP columns. This ensures deterministic, consistent results regardless of session timezone.

Key changes:

  • Added CtxWithUTCLocation() helper to override eval context timezone to UTC
  • Added GeneratedColumnDependsOnTimestamp() to detect TIMESTAMP dependencies
  • Added ConvertTimestampDatumsToUTC() / ConvertTimestampMutRowToUTC() to convert TIMESTAMP values before expression evaluation
  • Applied UTC evaluation in all generated column code paths: INSERT (insert_common.go), UPDATE (write.go), ADMIN CHECK / DDL reorg (decoder.go), Lightning import (base.go), and virtual column filling (FillVirtualColumnValue)

Check List

Tests

  • Unit test

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

Fix a bug that generated columns referencing TIMESTAMP columns could produce inconsistent index entries when rows are inserted or updated from sessions with different time zones, causing `ADMIN CHECK TABLE` failures and assertion errors.

Summary by CodeRabbit

  • Bug Fixes

    • Generated columns that depend on TIMESTAMP values are now evaluated in UTC when needed, with results converted back to the session timezone to avoid double-conversion. This ensures consistent computed values across session time zones and preserves index/table integrity.
  • Tests

    • Added end-to-end tests covering STORED and VIRTUAL generated columns, chained dependencies, timezone switches, and admin checks to validate consistency and index/table correctness.

@pantheon-ai
Copy link
Copy Markdown

pantheon-ai bot commented Mar 8, 2026

Review Complete

Findings: 0 issues
Posted: 0
Duplicates/Skipped: 0

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Mar 8, 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 gmhdbjd, windtalker 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 contribution This PR is from a community contributor. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Mar 8, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Mar 8, 2026

Hi @Desel72. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 ti-chi-bot bot added the first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. label Mar 8, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Mar 8, 2026

Welcome @Desel72!

It looks like this is your first PR to pingcap/tidb 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tidb. 😃

@pingcap-cla-assistant
Copy link
Copy Markdown

pingcap-cla-assistant bot commented Mar 8, 2026

CLA assistant check
All committers have signed the CLA.

@tiprow
Copy link
Copy Markdown

tiprow bot commented Mar 8, 2026

Hi @Desel72. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 8, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds UTC-aware evaluation for generated columns that depend on TIMESTAMP across insert, update, import, decode, and virtual-column paths by converting TIMESTAMP inputs to UTC, using a UTC expression-eval context for generation/casting, then restoring the original session location and post-converting TIMESTAMP results back to the session zone.

Changes

Cohort / File(s) Summary
Table helpers & virtual column evaluation
pkg/table/column.go
Adds detection helpers for generated-columns depending on TIMESTAMP, conversion helpers to turn TIMESTAMP datums/MutRow values into UTC with restore closures, and updates FillVirtualColumnValue to evaluate affected generated/virtual columns in UTC and restore state.
Expression context utilities
pkg/expression/exprctx/context.go
Adds Location() on the override EvalContext and CtxWithUTCLocation helper to produce a BuildContext that forces UTC for expression evaluation.
Executor: insert/update paths
pkg/executor/insert_common.go, pkg/executor/write.go
Detects timestamp-dependent generated columns, converts row/mutRow timestamps to UTC and switches Eval/Cast contexts to UTC for generated-column evaluation, then restores original contexts and post-converts TIMESTAMP results back to session location.
Import / Lightning backend
pkg/lightning/backend/kv/base.go
During import-generated-column evaluation, converts record datums to UTC when needed, switches eval/cast contexts to UTC, evaluates and casts generated values, post-converts TIMESTAMP results back to session timezone, and updates mutRow/record.
Row decoder
pkg/util/rowDecoder/decoder.go
When evaluating remaining generated expressions, converts the eval buffer to UTC and uses a UTC evaluation context if needed; restores prior session TZ and post-converts TIMESTAMP results after casting.
Tests & BUILD
pkg/executor/test/writetest/write_test.go, pkg/executor/test/writetest/BUILD.bazel
Adds TestGeneratedColumnTimestampTZConsistency (end-to-end tests for STORED/VIRTUAL generated columns and index consistency across session time_zone changes) and adjusts test shard_count.
Executor imports
pkg/executor/write.go, pkg/executor/insert_common.go
Adds imports for time and expression/exprctx to support UTC conversion and UTC-aware eval contexts.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Executor
    participant TableInfo
    participant EvalCtx
    participant MutRow
    Client->>Executor: INSERT / UPDATE / IMPORT / DECODE
    Executor->>TableInfo: HasGeneratedColumnDependingOnTimestamp(tbl)?
    alt timestamp-dependent
        TableInfo-->>Executor: true
        Executor->>MutRow: ConvertTimestampDatumsToUTC / ConvertTimestampMutRowToUTC
        MutRow-->>Executor: restoreFunc
        Executor->>EvalCtx: CtxWithUTCLocation(originalCtx) -> utcCtx
        Executor->>EvalCtx: Evaluate generated expressions with utcCtx
        EvalCtx-->>Executor: Generated values (UTC)
        Executor->>MutRow: If gen col is TIMESTAMP, convert value from UTC -> session loc
        Executor->>MutRow: restoreFunc()
    else not timestamp-dependent
        TableInfo-->>Executor: false
        Executor->>EvalCtx: Evaluate generated columns with session location
    end
    Executor-->>Client: Persist row / return result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested labels

release-note, approved, lgtm

Poem

🐰 I hopped through timestamps from dusk to dawn,
I nudged them to UTC before the lawn.
I wrapped the eval context, then let columns decide,
Converted back gently and set timezones aside.
🌤️🔁

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing generated column TIMESTAMP index inconsistency across session time zones, which aligns with the changeset that adds UTC evaluation logic across multiple executor and table components.
Linked Issues check ✅ Passed The PR comprehensively addresses issue #66753 by implementing UTC-aware evaluation in all generated column code paths (INSERT, UPDATE, ADMIN CHECK, Lightning import, virtual columns) with test coverage, fully meeting the stated objectives.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the issue: adding UTC evaluation helpers, timestamp conversion utilities, and applying them consistently across all generated column evaluation paths. The test shard count adjustment is a minor configuration change related to test capacity.
Docstring Coverage ✅ Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The PR description comprehensively addresses the issue, clearly explains the problem with generated columns and TIMESTAMP values across time zones, details the solution approach with key technical changes, includes proper issue linking, specifies testing approach, and provides a detailed release note.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 8, 2026

Hi @bb7133
Sorry I will fix all problems soon.
Could you please review this PR?

Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
pkg/executor/test/writetest/write_test.go (1)

555-611: Add an indirect-dependency regression case.

This test only covers a generated column that directly references ts. It won't catch a chain like g1 DATETIME AS (ts) and g2 TIMESTAMP AS (g1), where the virtual-column backfill/check path still makes a different UTC decision. Please add one mixed-time_zone case with ADMIN CHECK for that shape so the fix is locked in end-to-end.

As per coding guidelines: **/*_test.go: MUST add a regression test and verify it fails before fix and passes after fix for bug fixes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/executor/test/writetest/write_test.go` around lines 555 - 611, Add a
regression case to TestGeneratedColumnTimestampTZConsistency that creates a
chained generated-column table (e.g., table name t_chain) with columns ts
TIMESTAMP, g1 DATETIME GENERATED ALWAYS AS (ts) (virtual or stored as
appropriate), and g2 TIMESTAMP GENERATED ALWAYS AS (g1) with an index on g2
(e.g., INDEX idx_g2); insert a row with time_zone = '+00:00', change session
time_zone to '-08:00' and perform an UPDATE to ts, then switch back to '+00:00'
and run ADMIN CHECK TABLE t_chain and ADMIN CHECK INDEX t_chain idx_g2 and
assert the reported g2 value is identical when read under both time zones
(similar to how gen_hour is checked), so the test exercises the indirect
dependency path (g1 -> g2) end-to-end.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/table/column.go`:
- Around line 870-925: The UTC switch must be decided at table-level, not
per-output-column: instead of looping only over virtualColumnIndex to set
needUTC, check all generated columns (scan colInfos for any column where
GeneratedColumnDependsOnTimestamp(...) is true) and set needUTC if any such
column exists; keep using tsColIndices for timestamp column positions and keep
the per-column isUTCCol check simple (use needUTC &&
GeneratedColumnDependsOnTimestamp(colInfos[idx], colInfos) if you still want to
restrict conversion to virtuals that are timestamp-derived), but ensure needUTC
is true whenever any generated column in the table transitively depends on a
TIMESTAMP so the whole FillVirtualColumnValue evaluation runs in UTC like other
evaluators.

---

Nitpick comments:
In `@pkg/executor/test/writetest/write_test.go`:
- Around line 555-611: Add a regression case to
TestGeneratedColumnTimestampTZConsistency that creates a chained
generated-column table (e.g., table name t_chain) with columns ts TIMESTAMP, g1
DATETIME GENERATED ALWAYS AS (ts) (virtual or stored as appropriate), and g2
TIMESTAMP GENERATED ALWAYS AS (g1) with an index on g2 (e.g., INDEX idx_g2);
insert a row with time_zone = '+00:00', change session time_zone to '-08:00' and
perform an UPDATE to ts, then switch back to '+00:00' and run ADMIN CHECK TABLE
t_chain and ADMIN CHECK INDEX t_chain idx_g2 and assert the reported g2 value is
identical when read under both time zones (similar to how gen_hour is checked),
so the test exercises the indirect dependency path (g1 -> g2) end-to-end.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ac22ac58-594a-4377-a4f0-a7e42d1a7e82

📥 Commits

Reviewing files that changed from the base of the PR and between 999e8f4 and fb4dfaa.

📒 Files selected for processing (7)
  • pkg/executor/insert_common.go
  • pkg/executor/test/writetest/write_test.go
  • pkg/executor/write.go
  • pkg/expression/exprctx/context.go
  • pkg/lightning/backend/kv/base.go
  • pkg/table/column.go
  • pkg/util/rowDecoder/decoder.go

…MP fix

Widen needUTC check in FillVirtualColumnValue to scan all generated
columns (not just virtualColumnIndex) so transitive TIMESTAMP
dependencies through stored columns are detected. Add chained
generated-column test case to cover indirect TIMESTAMP dependency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Desel72 Desel72 changed the title fix generated column TIMESTAMP index inconsistency across session time zones table, executor, lightning: fix generated column TIMESTAMP index inconsistency across session time zones Mar 8, 2026
Copy link
Copy Markdown

@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.

♻️ Duplicate comments (1)
pkg/table/column.go (1)

905-927: ⚠️ Potential issue | 🟠 Major

Run the whole virtual-column pass under UTC once needUTC is true.

isUTCCol still decides both EvalVirtualColumn and CastColumnValue per output column, so a chain like g1 DATETIME AS (ts) and g2 TIMESTAMP AS (g1) will still evaluate/cast g2 in the session timezone here. That keeps FillVirtualColumnValue out of sync with the other generated-column paths in this PR and can still produce divergent virtual values during reads or ADMIN CHECK.

🛠️ Suggested direction
-		isUTCCol := needUTC && len(tsColIndices) > 0 && GeneratedColumnDependsOnTimestamp(colInfos[idx], colInfos)
+		useUTCCtx := needUTC && origLoc != time.UTC
+		needTSRewrite := useUTCCtx && len(tsColIndices) > 0 && GeneratedColumnDependsOnTimestamp(colInfos[idx], colInfos)
 		for row := iter.Begin(); row != iter.End(); row = iter.Next() {
 			var datum types.Datum
 			var err error
-			if isUTCCol {
+			if needTSRewrite {
 				// Extract datums, convert TIMESTAMP columns from session TZ to UTC,
 				// evaluate in UTC context to get consistent results.
 				datums := make([]types.Datum, nCols)
 				for ci := 0; ci < nCols; ci++ {
 					datums[ci] = row.GetDatum(ci, &colInfos[ci].FieldType)
 				}
 				for _, ci := range tsColIndices {
 					if !datums[ci].IsNull() && datums[ci].Kind() == types.KindMysqlTime {
 						t := datums[ci].GetMysqlTime()
 						if convErr := t.ConvertTimeZone(origLoc, time.UTC); convErr == nil {
 							datums[ci].SetMysqlTime(t)
 						}
 					}
 				}
 				mutRow := chunk.MutRowFromDatums(datums)
 				datum, err = expCols[idx].EvalVirtualColumn(utcEvalCtx, mutRow.ToRow())
+			} else if useUTCCtx {
+				datum, err = expCols[idx].EvalVirtualColumn(utcEvalCtx, row)
 			} else {
 				datum, err = expCols[idx].EvalVirtualColumn(evalCtx, row)
 			}
 			if err != nil {
 				return err
 			}
@@
 			// Because the expression might return different type from
 			// the generated column, we should wrap a CAST on the result.
 			castCtx := ectx
-			if isUTCCol {
+			if useUTCCtx {
 				castCtx = utcCastCtx
 			}
 			castDatum, err := CastColumnValue(castCtx, datum, colInfos[idx], false, true)

Based on learnings: Correctness is first priority in TiDB changes; seemingly small changes can alter SQL semantics, consistency, or cluster behavior.

Also applies to: 934-938

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/table/column.go` around lines 905 - 927, The current code uses isUTCCol
to decide per-output-column whether to use utcEvalCtx for EvalVirtualColumn and
CastColumnValue, causing chains like g1 DATETIME AS (ts); g2 TIMESTAMP AS (g1)
to be evaluated/cast in session TZ and produce inconsistent virtual values;
change the virtual-column evaluation pass so that when needUTC is true (and
tsColIndices non-empty / GeneratedColumnDependsOnTimestamp indicates dependence)
you run the entire virtual-column pass under utcEvalCtx (use utcEvalCtx for all
expCols[idx].EvalVirtualColumn and CastColumnValue calls) instead of switching
per column by isUTCCol, ensuring expCols, FillVirtualColumnValue,
CastColumnValue, and any dependent evaluation use utcEvalCtx consistently; keep
GeneratedColumnDependsOnTimestamp, tsColIndices, expCols, utcEvalCtx and evalCtx
references to locate the affected code paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@pkg/table/column.go`:
- Around line 905-927: The current code uses isUTCCol to decide
per-output-column whether to use utcEvalCtx for EvalVirtualColumn and
CastColumnValue, causing chains like g1 DATETIME AS (ts); g2 TIMESTAMP AS (g1)
to be evaluated/cast in session TZ and produce inconsistent virtual values;
change the virtual-column evaluation pass so that when needUTC is true (and
tsColIndices non-empty / GeneratedColumnDependsOnTimestamp indicates dependence)
you run the entire virtual-column pass under utcEvalCtx (use utcEvalCtx for all
expCols[idx].EvalVirtualColumn and CastColumnValue calls) instead of switching
per column by isUTCCol, ensuring expCols, FillVirtualColumnValue,
CastColumnValue, and any dependent evaluation use utcEvalCtx consistently; keep
GeneratedColumnDependsOnTimestamp, tsColIndices, expCols, utcEvalCtx and evalCtx
references to locate the affected code paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cd87f872-0077-4079-9d52-841ec8356ee0

📥 Commits

Reviewing files that changed from the base of the PR and between fb4dfaa and 41e8712.

📒 Files selected for processing (2)
  • pkg/executor/test/writetest/write_test.go
  • pkg/table/column.go

Copy link
Copy Markdown

@pantheon-ai pantheon-ai 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 looks good. No issues found.

@lance6716
Copy link
Copy Markdown
Contributor

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Mar 8, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 8, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.1526%. Comparing base (f1964c5) to head (2526bb2).
⚠️ Report is 84 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #66771        +/-   ##
================================================
+ Coverage   77.7189%   78.1526%   +0.4337%     
================================================
  Files          2016       1945        -71     
  Lines        552594     539659     -12935     
================================================
- Hits         429470     421758      -7712     
+ Misses       121382     117474      -3908     
+ Partials       1742        427      -1315     
Flag Coverage Δ
integration 43.6785% <40.9836%> (-4.4517%) ⬇️
unit 76.5748% <85.7142%> (+0.3275%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 57.0098% <ø> (ø)
parser ∅ <ø> (∅)
br 48.8601% <ø> (-12.0245%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 9, 2026

/retest

@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 15, 2026

/retest

@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 15, 2026

Hi @lance6716 I've updated this PR. Please review this.

@lance6716
Copy link
Copy Markdown
Contributor

@wjhuang2016 @xhebox can you take a look? Thanks.

@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 17, 2026

Hi @wjhuang2016 @xhebox @qw4990 @winoros @guo-shaoge
Could you please review this? Thanks.

@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 18, 2026

Hi @MyonKeminta @D3Hunter @lance6716
I've passed all CI test. Could you please review this PR?

@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 19, 2026

Hi @lance6716 Could you please review this? I want to contribute to this project. I think this should be merged asap. Thanks

@lance6716
Copy link
Copy Markdown
Contributor

Hi @Desel72 I am not familiar with this part. Please wait other reviewers.

@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 19, 2026

@lance6716 Thanks for reply. Could you please let me know when this can be merged?

@lance6716
Copy link
Copy Markdown
Contributor

@lance6716 Thanks for reply. Could you please let me know when this can be merged?

Need 2 review's LGTM + code OWNER's approve. You can check comment of ti-chi-bot

genCols []GeneratedCol) (errCol *model.ColumnInfo, err error) {
genCols []GeneratedCol, tblInfo *model.TableInfo) (errCol *model.ColumnInfo, err error) {
mutRow := chunk.MutRowFromDatums(record)
evalCtx := se.GetExprCtx().GetEvalCtx()
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.

please build a case for lightning if it's also affected, and check it passes after the change

Desel72 and others added 2 commits March 19, 2026 04:42
Add TestEncodeGeneratedTimestampTZConsistency to verify that Lightning's
evalGeneratedColumns produces identical KV pairs for stored generated
columns depending on TIMESTAMP regardless of session time_zone.

Ref pingcap#66753

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 19, 2026

/retest

Desel72 and others added 4 commits March 19, 2026 12:39
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… columns

In multi-table UPDATE statements (e.g. UPDATE t1, t2 SET ...),
assign.Col.Index is the evalBuffer index spanning all tables in the join.
Accessing tblMeta.Columns[assign.Col.Index] causes an index-out-of-range
panic when the assignment refers to a column in another table.

Fix by using the table-local index (assign.Col.Index - offset) and
bounds-checking before accessing tblMeta.Columns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 19, 2026

/retest

1 similar comment
@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 19, 2026

/retest

@Desel72 Desel72 requested a review from D3Hunter March 20, 2026 14:24
@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Mar 25, 2026

@bb7133 @expxiaoli @qw4990 @AilinKid @joechenrh @GMHDBJD @D3Hunter @hawkingrei @zimulala @winoros
Could you please review this PR if you have free time. I think this can be merged.

@Desel72 Desel72 closed this Mar 30, 2026
@Desel72 Desel72 reopened this Mar 31, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Mar 31, 2026

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-tests-checked label, please finished the tests then check the finished items in description.

For example:

Tests

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

📖 For more info, you can check the "Contribute Code" section in the development guide.

@tiprow
Copy link
Copy Markdown

tiprow bot commented Mar 31, 2026

@Desel72: 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
tidb_parser_test 2526bb2 link true /test tidb_parser_test

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.

@Desel72 Desel72 closed this Mar 31, 2026
@Desel72
Copy link
Copy Markdown
Author

Desel72 commented Apr 3, 2026

/retest

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

Labels

contribution This PR is from a community contributor. do-not-merge/needs-tests-checked do-not-merge/needs-triage-completed first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. ok-to-test Indicates a PR is ready to be tested. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated-column TIMESTAMP index becomes inconsistent across session time zones

3 participants