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

Fixed: failed to parse WHERE / GROUP BY clauses in a SELECT statement without a FROM table #587

Merged
merged 2 commits into from
Oct 27, 2019

Conversation

zhenghaoz
Copy link
Contributor

Fixed: Failed to parse WHERE / GROUP BY clauses in a SELECT statement without a FROM table

What problem does this PR solve?

Fixed #115

Bad SQL Case:

select 1 where true;
select 1 group by 1;
select 1 having true;

Check List

Tests

  • Unit test

Issue #115: Failed to parse WHERE / GROUP BY clauses in a SELECT statement without a FROM table
@zhenghaoz zhenghaoz requested a review from a team October 25, 2019 11:36
@ghost ghost requested review from tangenta and removed request for a team October 25, 2019 11:36
parser.y Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 26, 2019

Codecov Report

Merging #587 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #587      +/-   ##
==========================================
+ Coverage   71.85%   71.87%   +0.01%     
==========================================
  Files          32       32              
  Lines        7899     7897       -2     
==========================================
  Hits         5676     5676              
+ Misses       1684     1682       -2     
  Partials      539      539
Impacted Files Coverage Δ
ast/dml.go 73.96% <ø> (+0.11%) ⬆️
parser.go 70.37% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8adf16...da2ef8b. Read the comment docs.

Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

LGTM

@kennytm kennytm added the status/LGT1 LGT1 label Oct 26, 2019
Copy link
Contributor

@tangenta tangenta left a comment

Choose a reason for hiding this comment

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

LGTM

@tangenta tangenta merged commit e36338a into pingcap:master Oct 27, 2019
@tiancaiamao
Copy link
Collaborator

I find a problem:

Before this COMMIT:

mysql> SELECT @@autocommit limit 1;
+--------------+
| @@autocommit |
+--------------+
| 1            |
+--------------+
1 row in set (0.00 sec)

After this COMMIT:

mysql> SELECT @@autocommit limit 1;
+----------------------+
| @@autocommit limit 1 |
+----------------------+
| 1                    |
+----------------------+
1 row in set (0.00 sec)

Note the column name is different.

@zhenghaoz
Copy link
Contributor Author

Is it casued by line 6061 in parser.y?

} else {
	lastEnd = len(src)
	if src[lastEnd-1] == ';' {
		lastEnd--
	}
}

@tiancaiamao
Copy link
Collaborator

The gramma change seems not right, can we have:

select 1 where true group by 1 having 1>0

@tiancaiamao
Copy link
Collaborator

I'm trying to fix but not sure it's better to fix, or rollback this PR first. It seems to introduce other problems.

Could you find a way to make all the tests pass in #596 @zhenghaoz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to parse WHERE / GROUP BY clauses in a SELECT statement without a FROM table
4 participants