Skip to content

expression: fix extract day_microsecond/second/minute/hour from datetime#36367

Merged
ti-chi-bot merged 18 commits intopingcap:masterfrom
zanmato1984:fix-34998-again
Jul 20, 2022
Merged

expression: fix extract day_microsecond/second/minute/hour from datetime#36367
ti-chi-bot merged 18 commits intopingcap:masterfrom
zanmato1984:fix-34998-again

Conversation

@zanmato1984
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #36358

Problem Summary:

In #36297, we made extract(day_microsecond from datetime) not emit day portion according to the following experiment in MySQL:

mysql> select extract(day_microsecond from cast('2001-01-01 02:03:04.056789' as datetime(6)));
+---------------------------------------------------------------------------------+
| extract(day_microsecond from cast('2001-01-01 02:03:04.056789' as datetime(6))) |
+---------------------------------------------------------------------------------+
|                                                                     20304056789 |
+---------------------------------------------------------------------------------+
1 row in set (0.00 sec)

However it turns out to be a MySQL bug, see the following case in MySQL:

create table t(c datetime(6));
insert into t values('2001-01-01 02:03:04.050607');
mysql> select extract(day_microsecond from cast(c as datetime(6))), extract(day_microsecond from c) from t;
+------------------------------------------------------+---------------------------------+
| extract(day_microsecond from cast(c as datetime(6))) | extract(day_microsecond from c) |
+------------------------------------------------------+---------------------------------+
|                                          20304050607 |                   1020304050607 |
+------------------------------------------------------+---------------------------------+
1 row in set (0.00 sec)

And there is an issue stating this bug in https://bugs.mysql.com/bug.php?id=73240.

What is changed and how it works?

We consider the missing day portion of extract(day_microsecond from datetime) a bug, and fix it.

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

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

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 20, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • XuHuaiyu
  • windtalker

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Details

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. needs-cherry-pick-6.2 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 20, 2022
Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 20, 2022
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 20, 2022
@XuHuaiyu XuHuaiyu added the type/bugfix This PR fixes a bug. label Jul 20, 2022
@XuHuaiyu
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

DetailsCommit hash: 79db9b3

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 20, 2022
@zanmato1984
Copy link
Contributor Author

/run-unit-test

@zanmato1984
Copy link
Contributor Author

/run-build

@sre-bot
Copy link
Contributor

sre-bot commented Jul 20, 2022

@zanmato1984
Copy link
Contributor Author

/run-mysql-test

@zanmato1984
Copy link
Contributor Author

/run-check_dev_2

@zanmato1984
Copy link
Contributor Author

/run-mysql-test

@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

The

@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

tests

@zanmato1984
Copy link
Contributor Author

/run-unit-test

@zanmato1984
Copy link
Contributor Author

/run-check_dev_2

1 similar comment
@zanmato1984
Copy link
Contributor Author

/run-check_dev_2

@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

are

@zanmato1984
Copy link
Contributor Author

/run-check_dev_2

@zanmato1984
Copy link
Contributor Author

/run-build

@zanmato1984
Copy link
Contributor Author

/run-mysql-test

@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

very

@zanmato1984
Copy link
Contributor Author

/run-unit-test

@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

stable

@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

The

@zanmato1984
Copy link
Contributor Author

/run-unit-test

@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

coordination

@hawkingrei
Copy link
Member

/run-unit-test

@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

is

@hawkingrei
Copy link
Member

/run-check_dev_2

@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

very

@ti-chi-bot ti-chi-bot merged commit 25d777d into pingcap:master Jul 20, 2022
@ti-srebot
Copy link
Contributor

cherry pick to release-6.2 failed

@hawkingrei
Copy link
Member

😩

@zanmato1984 zanmato1984 deleted the fix-34998-again branch July 20, 2022 17:55
@zanmato1984
Copy link
Contributor Author

zanmato1984 commented Jul 20, 2022

efficient

@sre-bot
Copy link
Contributor

sre-bot commented Jul 20, 2022

TiDB MergeCI notify

🔴 Bad News! New failing [1] after this pr merged.
These new failed integration tests seem to be caused by the current PR, please try to fix these new failed integration tests, thanks!

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-compatibility-test 🟥 failed 1, success 0, total 1 3 min 14 sec New failing
idc-jenkins-ci/integration-cdc-test 🔴 failed 35, success 1, total 36 1 hr 11 min Existing failure
idc-jenkins-ci-tidb/integration-common-test 🔴 failed 1, success 10, total 11 47 min Existing failure
idc-jenkins-ci-tidb/tics-test ✅ all 1 tests passed 7 min 33 sec Fixed
idc-jenkins-ci-tidb/common-test 🟢 all 12 tests passed 18 min Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 7 min 1 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 6 min 11 sec Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 5 min 53 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 13 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

@MrCroxx
Copy link

MrCroxx commented Jul 26, 2022

🥵

@nolouch
Copy link
Member

nolouch commented Jul 26, 2022

:)

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

Labels

release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extract day_microsecond from datetime has no day portion

9 participants