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

CONVERT_TZ should return NULL if its arguments are invalid. #11161

Closed
SunRunAway opened this issue Jul 10, 2019 · 1 comment · Fixed by #11176
Closed

CONVERT_TZ should return NULL if its arguments are invalid. #11161

SunRunAway opened this issue Jul 10, 2019 · 1 comment · Fixed by #11176
Assignees
Labels
component/expression help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility type/enhancement The issue or PR belongs to an enhancement.

Comments

@SunRunAway
Copy link
Contributor

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.
SELECT CONVERT_TZ( '2004-01-01 12:00:00', '', '');
SELECT CONVERT_TZ( '2004-01-01 12:00:00', 'a', '');
SELECT CONVERT_TZ( '2004-01-01 12:00:00', 0, '');
  1. What did you expect to see?

Due to https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_convert-tz,

This function returns NULL if the arguments are invalid.

mysql> SELECT CONVERT_TZ( '2004-01-01 12:00:00', '', '');
+--------------------------------------------+
| CONVERT_TZ( '2004-01-01 12:00:00', '', '') |
+--------------------------------------------+
| NULL                                       |
+--------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT CONVERT_TZ( '2004-01-01 12:00:00', 'a', '');
+---------------------------------------------+
| CONVERT_TZ( '2004-01-01 12:00:00', 'a', '') |
+---------------------------------------------+
| NULL                                        |
+---------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT CONVERT_TZ( '2004-01-01 12:00:00', 0, '');
+-------------------------------------------+
| CONVERT_TZ( '2004-01-01 12:00:00', 0, '') |
+-------------------------------------------+
| NULL                                      |
+-------------------------------------------+
1 row in set (0.00 sec)
  1. What did you see instead?
mysql> SELECT CONVERT_TZ( '2004-01-01 12:00:00', '', '');
+--------------------------------------------+
| CONVERT_TZ( '2004-01-01 12:00:00', '', '') |
+--------------------------------------------+
| 2004-01-01 12:00:00                        |
+--------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT CONVERT_TZ( '2004-01-01 12:00:00', 'a', '');
ERROR 1105 (HY000): unknown time zone a
mysql> SELECT CONVERT_TZ( '2004-01-01 12:00:00', 0, '');
ERROR 1105 (HY000): unknown time zone 0
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
@SunRunAway SunRunAway added type/compatibility help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Jul 10, 2019
@tcmichael
Copy link

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants