Allow parenthesized query expression for standard-compliance
------------------------------------------------------------

                 Key: CORE-6511
                 URL: http://tracker.firebirdsql.org/browse/CORE-6511
             Project: Firebird Core
          Issue Type: Improvement
          Components: Engine
            Reporter: Mark Rotteveel
         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>

<table expression> ::=
  <from clause>
    [ <where clause> ]
    [ <group by clause> ]
    [ <having clause> ]
    [ <window clause> ]
```

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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to