db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (DERBY-5972) Grammar doesn't accept OR operator without parentheses
Date Mon, 05 Nov 2012 15:24:11 GMT

    [ https://issues.apache.org/jira/browse/DERBY-5972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13487713#comment-13487713
] 

Knut Anders Hatlen edited comment on DERBY-5972 at 11/5/12 3:22 PM:
--------------------------------------------------------------------

I think "select b1 or b2 from t" is valid syntax.

Starting with this rule in the SQL:2003 standard, part 2, section 7.12 <query specification>

<select list> ::=
<asterisk>
| <select sublist> [ { <comma> <select sublist> }... ]

and following the rules via <select sublist>, <derived column> and <value expression>
brings you to

6.34 <boolean value expression>

<boolean value expression> ::=
<boolean term>
| <boolean value expression> OR <boolean term>

So it looks to me as if parentheses are not required by the standard for OR expressions in
the select list.
                
      was (Author: knutanders):
    I think "select b1 or b2 from t".

Staring with this rule in the SQL:2003 standard, part 2, section 7.12 <query specification>

<select list> ::=
<asterisk>
| <select sublist> [ { <comma> <select sublist> }... ]

and following the rules via <select sublist>, <derived column> and <value expression>
brings you to

6.34 <boolean value expression>

<boolean value expression> ::=
<boolean term>
| <boolean value expression> OR <boolean term>

So it looks to me as if parentheses are not required by the standard for OR expressions in
the select list.
                  
> Grammar doesn't accept OR operator without parentheses
> ------------------------------------------------------
>
>                 Key: DERBY-5972
>                 URL: https://issues.apache.org/jira/browse/DERBY-5972
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.10.0.0
>            Reporter: Knut Anders Hatlen
>
> The grammar doesn't accept the OR operator without parentheses in some constructs.
> For example, in a select list:
> ij> create table t(b1 boolean, b2 boolean);
> 0 rows inserted/updated/deleted
> ij> select b1 or b2 from t;
> ERROR 42X01: Syntax error: Encountered "or" at line 1, column 11. (errorCode = 30000)
> Issue the 'help' command for general information on IJ command syntax.
> Any unrecognized commands are treated as potential SQL commands and executed directly.
> Consult your DBMS server reference documentation for details of the SQL syntax supported
by your server.
> However, it does not fail if OR is replaced by AND, or if parentheses are used around
the OR expression:
> ij> select (b1 or b2) from t;
> 1    
> -----
> 0 rows selected
> ij> select b1 and b2 from t;
> 1    
> -----
> 0 rows selected
> Similar behaviour is seen in VALUES statements:
> ij> values true or false;
> ERROR 42X01: Syntax error: Encountered "or" at line 1, column 13. (errorCode = 30000)
> Issue the 'help' command for general information on IJ command syntax.
> Any unrecognized commands are treated as potential SQL commands and executed directly.
> Consult your DBMS server reference documentation for details of the SQL syntax supported
by your server.
> ij> values (true or false);
> 1    
> -----
> true 
> 1 row selected
> ij> values true and false;
> 1    
> -----
> false
> 1 row selected

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message