db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dag H. Wanvik (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (DERBY-2374) UNION PROBLEM WITH PARENTHESIS
Date Wed, 28 Oct 2009 00:16:59 GMT

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

Dag H. Wanvik edited comment on DERBY-2374 at 10/28/09 12:15 AM:
-----------------------------------------------------------------

Could this is a heuristic made necessary by the LL(n) nature of the
parser (recursive descent)? I think the parser can't really know
whether it's seeing seeing a "( <table reference ... " or a "( <query
expression body.."  without looking past the matching ")" +
correlation and seeing a join operator or not.

- If it does see a join operator there, it should descend into <table
reference>)

- If is does *not* see a join operator there, it should descend into
<query expression body>, i.e. a subquery, which it failed to do here.

I suspect this long back-ahead + paren matching may be beyond JavaCC..

So, the authors of this code found a workable heuristic, which fails in
this case :( Maybe there is a way to finesse it, though..


      was (Author: dagw):
    Could this is a heuristic made necessary by the LL(n) nature of the
parser (recursive descent)? I think the parser can't really know
whether it's seeing seeing a "( <table reference ... " or a "( <query
expression body.."  without looking past the matching ")" +
correlation and seeing a join operator or not.

- If it does see a join operator there, it should descend into <table
reference>)

- If is does *not* see a join operator there, it should descend into
<query expression body>, i.e. a subquery, which it failed to do here.

I suspect this long back-ahead + paren matching may be beyong JavaCC..

So, the authors of this code found a workable heuristic, which fails in
this case :( Maybe there is a way to finesse it, though..

  
> UNION PROBLEM WITH PARENTHESIS
> ------------------------------
>
>                 Key: DERBY-2374
>                 URL: https://issues.apache.org/jira/browse/DERBY-2374
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.3, 10.2.2.0, 10.3.3.1, 10.4.2.1, 10.5.3.1, 10.6.0.0
>            Reporter: Kenneth Gee
>            Priority: Minor
>
> The following query shows the error using the Derby demo toursDB:
> SELECT FLIGHT_ID , SEGMENT_NUMBER , ARRIVE_TIME
>   FROM (
>          (SELECT HW.FLIGHT_ID , HW.SEGMENT_NUMBER , HW.ARRIVE_TIME FROM FLIGHTS HW)
>            UNION
>          (SELECT SW.FLIGHT_ID , SW.SEGMENT_NUMBER , SW.ARRIVE_TIME FROM FLIGHTS SW)
>        ) SRC;
> ERROR 42X01: Syntax error: Encountered "UNION" at line 4, column 12.
> The following query works:
> SELECT FLIGHT_ID , SEGMENT_NUMBER , ARRIVE_TIME
>   FROM (
>          SELECT HW.FLIGHT_ID , HW.SEGMENT_NUMBER , HW.ARRIVE_TIME FROM FLIGHTS HW
>           UNION
>          SELECT SW.FLIGHT_ID , SW.SEGMENT_NUMBER , SW.ARRIVE_TIME FROM FLIGHTS SW
>        )  SRC;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message