Skip to content

Conversation

mjonss
Copy link
Contributor

@mjonss mjonss commented May 30, 2025

What problem does this PR solve?

Issue Number: close #61439

Problem Summary:
In #61337 there was a missed case, where INSERT IGNORE and STRICT mode was combined, which resulted in not inserting a row, when it should have been adjusted and inserted.

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

When a non-existing timestamp during DST transition is used in INSERT IGNORE with STRICT sql_mode, it is now adjusted to next valid timestamp and inserted with a warning, instead of skipped or set to '0000-00-00'.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 30, 2025
Copy link

tiprow bot commented May 30, 2025

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

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.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the behavior when combining INSERT IGNORE with STRICT mode during a DST transition by adjusting the erroneous timestamp and ensuring the row is inserted with a warning instead of being skipped.

  • Added integration tests to verify the correct behavior.
  • Updated expected test outputs in result files.
  • Adjusted error handling logic in pkg/executor/insert_common.go to give IGNORE precedence over STRICT mode.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/integrationtest/t/executor/insert.test Added integration test for INSERT IGNORE with DST transition case.
tests/integrationtest/r/executor/insert.result Updated expected result output for the new behavior.
pkg/executor/insert_common.go Changed error handling logic to account for ignore flag priority.
Comments suppressed due to low confidence (1)

pkg/executor/insert_common.go:329

  • [nitpick] Consider renaming 'ignoreErr' to a more descriptive name such as 'shouldIgnoreError' to clarify its purpose in determining whether to convert errors to warnings.
if !e.ignoreErr && e.Ctx().GetSessionVars().SQLMode.HasStrictMode() {

@mjonss mjonss requested review from YangKeao and Defined2014 May 30, 2025 23:55
Copy link

codecov bot commented May 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.6095%. Comparing base (fbf1586) to head (f86cae7).
Report is 238 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #61440        +/-   ##
================================================
+ Coverage   73.1533%   73.6095%   +0.4562%     
================================================
  Files          1727       1729         +2     
  Lines        479773     482535      +2762     
================================================
+ Hits         350970     355192      +4222     
+ Misses       107279     105851      -1428     
+ Partials      21524      21492        -32     
Flag Coverage Δ
integration 42.3893% <100.0000%> (?)
unit 72.4894% <100.0000%> (+0.0704%) ⬆️

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

Components Coverage Δ
dumpling 52.7804% <ø> (ø)
parser ∅ <ø> (∅)
br 47.3111% <ø> (-0.1406%) ⬇️
🚀 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.

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 31, 2025
@hawkingrei
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label May 31, 2025
@Defined2014 Defined2014 requested a review from xhebox June 3, 2025 01:41
Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Jun 3, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014, YangKeao

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Defined2014,YangKeao]

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 3, 2025
Copy link

ti-chi-bot bot commented Jun 3, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-05-31 00:50:21.359153089 +0000 UTC m=+57307.561498339: ☑️ agreed by Defined2014.
  • 2025-06-03 02:24:48.422451297 +0000 UTC m=+322174.624796562: ☑️ agreed by YangKeao.

@ti-chi-bot ti-chi-bot bot merged commit bed8f25 into pingcap:master Jun 3, 2025
24 checks passed
@mjonss mjonss deleted the insert-ignore-strict-dst-timestamp-61439 branch June 12, 2025 10:56
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Jul 8, 2025
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jul 8, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #62304.
But this PR has conflicts, please resolve them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

INSERT IGNORE + STRICT_TRANS_TABLES results in different TIMESTAMP than MySQL
5 participants