Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table: Don't cast date default values (same as timestamp/datetime) | tidb-test=920d9bf1b1137cda1272bdd59ae527aee8067944 #59149

Merged

Conversation

YangKeao
Copy link
Member

This PR is a cherry-pick for #59049 on hotfix branch

What problem does this PR solve?

Issue Number: close #59047

Problem Summary:
During the executor build phase getColDefaultValue is called for the date column and fails, due to trying to cast the default value '0000-00-00' which fails due to default sql_mode.

The underlying issue seems to be that CREATE TABLE does not set column.OriginDefaultValue, while ALTER TABLE ADD COLUMN does, which is ignored in this PR.

What changed and how does it work?

Do as DATETIME and TIMESTAMP, skip cast.

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.

Fix UPDATE after ALTER ADD date column giving error for incorrect value '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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 23, 2025
@dveeden
Copy link
Contributor

dveeden commented Jan 23, 2025

I guess you might need a tidb-test change for this as well?

@YangKeao YangKeao changed the title table: Don't cast date default values (same as timestamp/datetime) (#… table: Don't cast date default values (same as timestamp/datetime) | tidb-test=pull/2473 Jan 23, 2025
@YangKeao
Copy link
Member Author

/retest

@YangKeao
Copy link
Member Author

YangKeao commented Jan 23, 2025

@YangKeao YangKeao changed the title table: Don't cast date default values (same as timestamp/datetime) | tidb-test=pull/2473 table: Don't cast date default values (same as timestamp/datetime) | tidb-test=920d9bf1b1137cda1272bdd59ae527aee8067944 Jan 23, 2025
@YangKeao
Copy link
Member Author

/retest

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-6.5-20241112-v6.5.11@e0726e7). Learn more about missing BASE report.

Additional details and impacted files
@@                        Coverage Diff                        @@
##             release-6.5-20241112-v6.5.11     #59149   +/-   ##
=================================================================
  Coverage                                ?   73.6096%           
=================================================================
  Files                                   ?       1097           
  Lines                                   ?     352928           
  Branches                                ?          0           
=================================================================
  Hits                                    ?     259789           
  Misses                                  ?      76410           
  Partials                                ?      16729           

@YangKeao
Copy link
Member Author

@dveeden Done. PTAL

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 23, 2025
Copy link

ti-chi-bot bot commented Jan 23, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dveeden, tiancaiamao

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 [dveeden,tiancaiamao]

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 Jan 23, 2025
Copy link

ti-chi-bot bot commented Jan 23, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-01-23 07:28:08.908107771 +0000 UTC m=+338616.239027167: ☑️ agreed by dveeden.
  • 2025-01-23 08:09:04.277793169 +0000 UTC m=+341071.608712574: ☑️ agreed by tiancaiamao.

@ti-chi-bot ti-chi-bot bot merged commit 7683911 into pingcap:release-6.5-20241112-v6.5.11 Jan 23, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants