Skip to content

Commit

Permalink
[PostgreSQL] Fix set operation precedence (#3567)
Browse files Browse the repository at this point in the history
Now the origin select_cause is redundant since simple_select matches select_with_parens
  • Loading branch information
tisonkun authored Jul 19, 2023
1 parent 5b6a6dd commit 4cfe10d
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions sql/postgresql/PostgreSQLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -2902,33 +2902,25 @@ select_no_parens
;

select_clause
: simple_select
| select_with_parens
: simple_select_intersect ((UNION | EXCEPT) all_or_distinct simple_select_intersect)*
;

simple_select
simple_select_intersect
: simple_select_pramary (INTERSECT all_or_distinct simple_select_pramary)*
;

simple_select_pramary
: ( SELECT (opt_all_clause into_clause opt_target_list | distinct_clause target_list)
into_clause
from_clause
where_clause
group_clause
having_clause
window_clause
| values_clause
| TABLE relation_expr
| select_with_parens set_operator_with_all_or_distinct (simple_select | select_with_parens)
)
(set_operator_with_all_or_distinct (simple_select | select_with_parens))*
;

set_operator
: UNION # union
| INTERSECT # intersect
| EXCEPT # except
;

set_operator_with_all_or_distinct
: set_operator all_or_distinct
)
| values_clause
| TABLE relation_expr
| select_with_parens
;

with_clause
Expand Down

0 comments on commit 4cfe10d

Please sign in to comment.