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

Function DAY/DAYOFMONTH should do type conversation #11178

Closed
SunRunAway opened this issue Jul 10, 2019 · 12 comments · Fixed by #21220
Closed

Function DAY/DAYOFMONTH should do type conversation #11178

SunRunAway opened this issue Jul 10, 2019 · 12 comments · Fixed by #21220
Assignees
Labels
challenge-program component/expression help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@SunRunAway
Copy link
Contributor

SunRunAway commented Jul 10, 2019

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.

  2. What did you expect to see?

mysql> SELECT DAY(120.000), DAYOFMONTH(0.000), DAYOFMONTH(0);
+--------------+-------------------+---------------+
| DAY(120.000) | DAYOFMONTH(0.000) | DAYOFMONTH(0) |
+--------------+-------------------+---------------+
|           20 |                 0 |             0 |
+--------------+-------------------+---------------+
1 row in set (0.00 sec)
  1. What did you see instead?
mysql> SELECT DAY(120.000), DAYOFMONTH(0.000), DAYOFMONTH(0);
+--------------+-------------------+---------------+
| DAY(120.000) | DAYOFMONTH(0.000) | DAYOFMONTH(0) |
+--------------+-------------------+---------------+
|         NULL |              NULL |          NULL |
+--------------+-------------------+---------------+
1 row in set, 3 warnings (0.00 sec)

mysql> show warnings;
+---------+------+--------------------------------------------------------+
| Level   | Code | Message                                                |
+---------+------+--------------------------------------------------------+
| Warning | 1292 | invalid time format: '120.000'                         |
| Warning | 1292 | invalid time format: '0.000'                           |
| Warning | 1292 | Incorrect datetime value: '0000-00-00 00:00:00.000000' |
+---------+------+--------------------------------------------------------+
3 rows in set (0.00 sec)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
    fdbc149

SIG slack channel

#sig-exec

Score

  • 300

Mentor

@SunRunAway SunRunAway added the type/bug The issue is confirmed as a bug. label Jul 10, 2019
@SunRunAway
Copy link
Contributor Author

Perhaps it's a common issue for all date and time functions.

In MySQL,

mysql>  SELECT  TO_SECONDS('0.112') ; show warnings;
+---------------------+
| TO_SECONDS('0.112') |
+---------------------+
|         63140342400 |
+---------------------+
1 row in set (0.00 sec)

Empty set (0.00 sec)

In TiDB,

mysql>  SELECT  TO_SECONDS('0.112') ; show warnings;
+---------------------+
| TO_SECONDS('0.112') |
+---------------------+
|                NULL |
+---------------------+
1 row in set, 1 warning (0.00 sec)

+---------+------+------------------------------+
| Level   | Code | Message                      |
+---------+------+------------------------------+
| Warning | 1292 | invalid time format: '0.112' |
+---------+------+------------------------------+
1 row in set (0.00 sec)

@SunRunAway SunRunAway added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. and removed help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Jul 12, 2019
@ghost
Copy link

ghost commented Jul 12, 2020

Confirming I can still reproduce this against master:

SELECT DAY(120.000), DAYOFMONTH(0.000), DAYOFMONTH(0);
SHOW WARNINGS;
SELECT TO_SECONDS('0.112') ;
SHOW WARNINGS;

..

mysql> SELECT DAY(120.000), DAYOFMONTH(0.000), DAYOFMONTH(0);
+--------------+-------------------+---------------+
| DAY(120.000) | DAYOFMONTH(0.000) | DAYOFMONTH(0) |
+--------------+-------------------+---------------+
|         NULL |              NULL |          NULL |
+--------------+-------------------+---------------+
1 row in set, 3 warnings (0.00 sec)

mysql> SHOW WARNINGS;
+---------+------+-------------------------------------------------+
| Level   | Code | Message                                         |
+---------+------+-------------------------------------------------+
| Warning | 1292 | Incorrect time value: '120.000'                 |
| Warning | 1292 | Incorrect datetime value: '0000-00-00 00:00:00' |
| Warning | 1292 | Incorrect datetime value: '0000-00-00 00:00:00' |
+---------+------+-------------------------------------------------+
3 rows in set (0.00 sec)

mysql> SELECT TO_SECONDS('0.112') ;
+---------------------+
| TO_SECONDS('0.112') |
+---------------------+
|                NULL |
+---------------------+
1 row in set, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+---------+------+-------------------------------+
| Level   | Code | Message                       |
+---------+------+-------------------------------+
| Warning | 1292 | Incorrect time value: '0.112' |
+---------+------+-------------------------------+
1 row in set (0.00 sec)

mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-750-g8a661044c
Edition: Community
Git Commit Hash: 8a661044cedf8daad1de4fbf79a390962b6f6c3b
Git Branch: master
UTC Build Time: 2020-07-10 10:52:37
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@youwithouto
Copy link

Hi @SunRunAway , can I work on this issue as the HP TiDB challenge?

@XiaoGe2030
Copy link

/pick-up

@ti-challenge-bot
Copy link

It is not a pickable issue!

More

Tip : If you want this issue to be picked, you need to add a challenge-program label to it.

Warning: None

@Patrick0308
Copy link
Contributor

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

@ti-challenge-bot
Copy link

@Patrick0308 You did not submit PR within 7 days, so give up automatically.

@ti-challenge-bot ti-challenge-bot bot removed the picked label Sep 16, 2020
@Patrick0308
Copy link
Contributor

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

@ti-challenge-bot
Copy link

@Patrick0308 You did not submit PR within 7 days, so give up automatically.

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
challenge-program component/expression help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants