forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parser: support empty target list in SELECT
This commit adds support for parsing empty target list for SELECT stmts (i.e. queries of the form `SELECT;`, `SELECT ALL FROM t;`, `SELECT FROM t;` where the projection column list is omitted). Apparently, some tools like hasura use it to get the row count. This is achieved by making `target_list` optional. However, the caveat is that the new parsing rule runs into a shift/reduce conflict with `SELECT error` rule (since now both options can match empty string after `SELECT` AFAICT). I tried adjusting the precedence of the newly adjusted rule to resolve this conflict but didn't succeed (Raphael tried doing the same with the same result). Release note (sql change): CockroachDB now supports parsing queries like `SELECT FROM t` that only produce the row count and do not output any columns.
- Loading branch information
1 parent
cbe17c3
commit da147cf
Showing
10 changed files
with
46 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
simple_select_clause ::= | ||
'SELECT' ( 'ALL' | ) ( ( target_elem ) ( ( ',' target_elem ) )* ) ( 'FROM' ( ( table_ref ) ( ( ',' table_ref ) )* ) ( ( 'AS' 'OF' 'SYSTEM' 'TIME' a_expr ) | ) | ) ( ( 'WHERE' a_expr ) | ) ( 'GROUP' 'BY' group_by_list | ) ( 'HAVING' a_expr | ) ( 'WINDOW' window_definition_list | ) | ||
'SELECT' ( 'ALL' | ) opt_target_list ( 'FROM' ( ( table_ref ) ( ( ',' table_ref ) )* ) ( ( 'AS' 'OF' 'SYSTEM' 'TIME' a_expr ) | ) | ) ( ( 'WHERE' a_expr ) | ) ( 'GROUP' 'BY' group_by_list | ) ( 'HAVING' a_expr | ) ( 'WINDOW' window_definition_list | ) | ||
| 'SELECT' ( 'DISTINCT' ) ( ( target_elem ) ( ( ',' target_elem ) )* ) ( 'FROM' ( ( table_ref ) ( ( ',' table_ref ) )* ) ( ( 'AS' 'OF' 'SYSTEM' 'TIME' a_expr ) | ) | ) ( ( 'WHERE' a_expr ) | ) ( 'GROUP' 'BY' group_by_list | ) ( 'HAVING' a_expr | ) ( 'WINDOW' window_definition_list | ) | ||
| 'SELECT' ( 'DISTINCT' 'ON' '(' ( ( a_expr ) ( ( ',' a_expr ) )* ) ')' ) ( ( target_elem ) ( ( ',' target_elem ) )* ) ( 'FROM' ( ( table_ref ) ( ( ',' table_ref ) )* ) ( ( 'AS' 'OF' 'SYSTEM' 'TIME' a_expr ) | ) | ) ( ( 'WHERE' a_expr ) | ) ( 'GROUP' 'BY' group_by_list | ) ( 'HAVING' a_expr | ) ( 'WINDOW' window_definition_list | ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters