Submitted by: @mrotteveel
Attachments:
query-expr-v3.diff
See also discussion with subject "Standard-compliance for query expressions" on firebird-devel (March 6th, 2021).
The SQL standard allows parentheses around query expressions (without with-clause), and Firebird does not. It would be helpful if Firebird added this support.
Specifically, SQL:2016 specifies the following:
```
<query expression> ::=
[ <with clause> ] <query expression body>
[ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
<query expression body> ::=
<query term>
| <query expression body> UNION [ ALL | DISTINCT ]
[ <corresponding spec> ] <query term>
| <query expression body> EXCEPT [ ALL | DISTINCT ]
[ <corresponding spec> ] <query term>
<query term> ::=
<query primary>
| <query term> INTERSECT [ ALL | DISTINCT ]
[ <corresponding spec> ] <query primary>
<query primary> ::=
<simple table>
| <left paren> <query expression body>
[ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
<right paren>
<simple table> ::=
<query specification>
| <table value constructor>
| <explicit table>
<query specification> ::=
SELECT [ <set quantifier> ] <select list> <table expression>
::=
\[ \]
\[ \]
\[ \]
\[ \]
\`\`\`
If I follow the grammar in parse.y correctly, the problem is that in Firebird, <query primary> is basically <query specification>, so it's missing the following alternative:
```
<left paren> <query expression body>
[ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
<right paren>
```
Adriano wrote the attached patch.
Submitted by: @mrotteveel
Attachments:
query-expr-v3.diff
See also discussion with subject "Standard-compliance for query expressions" on firebird-devel (March 6th, 2021).
The SQL standard allows parentheses around query expressions (without with-clause), and Firebird does not. It would be helpful if Firebird added this support.
Specifically, SQL:2016 specifies the following:
```
<query expression> ::=
[ <with clause> ] <query expression body>
[ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
<query expression body> ::=
<query term>
| <query expression body> UNION [ ALL | DISTINCT ]
[ <corresponding spec> ] <query term>
| <query expression body> EXCEPT [ ALL | DISTINCT ]
[ <corresponding spec> ] <query term>
<query term> ::=
<query primary>
| <query term> INTERSECT [ ALL | DISTINCT ]
[ <corresponding spec> ] <query primary>
<query primary> ::=
<simple table>
| <left paren> <query expression body>
[ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
<right paren>
<simple table> ::=
<query specification>
| <table value constructor>
| <explicit table>
<query specification> ::=
::= \[ \] \[ \] \[ \] \[ \] \`\`\`SELECT [ <set quantifier> ] <select list> <table expression>
If I follow the grammar in parse.y correctly, the problem is that in Firebird, <query primary> is basically <query specification>, so it's missing the following alternative:
```
<left paren> <query expression body>
[ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
<right paren>
```
Adriano wrote the attached patch.