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

parser: fix aggregate functions compatibility to MySQL8.0 #1123

Closed
wants to merge 2 commits into from

Conversation

hidehalo
Copy link

@hidehalo hidehalo commented Dec 9, 2020

What problem does this PR solve?

close #1116

What is changed and how it works?

change yacc rules of SumExpr below :

  • VAR_POP
  • VAR_SAMP
  • VARIANCE
  • STDDEV_POP
  • STDDEV_SAMP

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to be included in the release note

- std
- stddev
- stddev_pop
- stddev_samp
- var_pop
- var_samp
- variance
@CLAassistant
Copy link

CLAassistant commented Dec 9, 2020

CLA assistant check
All committers have signed the CLA.

@@ -1,19 +1,26 @@
module github.com/pingcap/parser

require (
github.com/cznic/fileutil v0.0.0-20181122101858-4d67cfea8c87 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think you need to modify go.mod and go.sum.

Copy link
Author

Choose a reason for hiding this comment

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

👌

@@ -3243,6 +3243,48 @@ func (s *testParserSuite) TestErrorMsg(c *C) {

_, _, err = parser.Parse("select 1 collate some_unknown_collation", "", "")
c.Assert(err.Error(), Equals, "[ddl:1273]Unknown collation: 'some_unknown_collation'")

_, _, err = parser.Parse("select std(all c1) from t", "", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

if you're truly aiming for MySQL 8.0 compatibility then all must still be supported.

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.20    |
+-----------+
1 row in set (0.00 sec)

mysql> select std(all a) from a;
+------------+
| std(all a) |
+------------+
|        0.5 |
+------------+
1 row in set (0.00 sec)

mysql> select std(distinct a) from a;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distinct a) from a' at line 1

@hidehalo
Copy link
Author

I think it should close for now, if it is necessary for related issue, we just let it re-open.

@hidehalo hidehalo closed this Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

parser: fix aggregate functions compatibility to MySQL8.0
4 participants