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

Interval() with expressions is not working in Tidb #30519

Closed
ramanich1 opened this issue Dec 8, 2021 · 2 comments · Fixed by #30528
Closed

Interval() with expressions is not working in Tidb #30519

ramanich1 opened this issue Dec 8, 2021 · 2 comments · Fixed by #30528
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@ramanich1
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
SELECT (INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2;
SELECT INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3);

2. What did you expect to see? (Required)

mysql> SELECT (INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2;
+-----------------------------------------------------+
| (INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2 |
+-----------------------------------------------------+
|                                             50.0000 |
+-----------------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3);
+---------------------------------------+
| INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3) |
+---------------------------------------+
|                                     2 |
+---------------------------------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> SELECT (INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 58 near "" 
mysql> SELECT INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 44 near "" 

4. What is your TiDB version? (Required)

| Release Version: v5.4.0-alpha-264-g6efa36df6
Edition: Community
Git Commit Hash: 6efa36df6cff325106f67ecfe3d79816ba37ca6a
Git Branch: master
UTC Build Time: 2021-11-29 16:57:51
GoVersion: go1.17.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
@ramanich1 ramanich1 added the type/bug The issue is confirmed as a bug. label Dec 8, 2021
@Defined2014
Copy link
Contributor

Defined2014 commented Dec 8, 2021

Seems the problem is caused by precedence for interval.

mysql> SELECT (INTERVAL(0,(1*5)/2)) + (INTERVAL(5,4,3));
+-------------------------------------------+
| (INTERVAL(0,(1*5)/2)) + (INTERVAL(5,4,3)) |
+-------------------------------------------+
|                                         2 |
+-------------------------------------------+
1 row in set (0.01 sec)

@github-actions
Copy link

github-actions bot commented Dec 9, 2021

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants