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

Mayuresh Nirhali commented on DERBY-2103:
-----------------------------------------

After some investigation, I found that, when the expected error happens, 
lookingAhead flag in SQLParser implementation is true and due  to the exception 
this flag is not cleared. The parser object is cached and later used by the 
next parsing activity. Following code demonstrates the scenario.

  final private boolean jj_3_12() {
    Token xsp;
    xsp = jj_scanpos;
    lookingAhead = true;
    jj_semLA = getToken(3).kind != LARGE;   // ------- The exception happens in 
this call   
    lookingAhead = false;                                    // ------- This is 
not called due to the exception.
    if (!jj_semLA || jj_3R_60()) return true;
    if (jj_3R_61()) return true;
    return false;
  }

The simple fix could be to wrap the lookingAhead assignment  after the call 
within finally block.
then, the same method would look like below,

    lookingAhead = true;
    try { jj_semLA = getToken(3).kind != LARGE; }
    finally { lookingAhead = false; }

I tried this and this has fixed the testcase.
Now, my concern is that, there are many such methods in SQLParser 
implementation.For the fix to be complete and to be able to avoid future issues 
due to same problem, all methods which should change needs to identified.
While, I am trying to do the same, I would really appreciate any inputs in this 
regard.

Thanks,
Mayuresh

> After a Lexical Error due to syntax error ,    even a simple create table 
> does not work  on the same connection.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-2103
>                 URL: https://issues.apache.org/jira/browse/DERBY-2103
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.3.0.0
>            Reporter: Suresh Thalamati
>         Assigned To: Mayuresh Nirhali
>            Priority: Minor
>
> connect 'jdbc:derby:wombat;create=true';
> create table t1(a int ) ;
> create table "t2"(a int ) ;
> -- this should fail. 
> create table foo (a int ,  \"YEAR\" int ) ;
> -- but this should not fail. But failing
> create table t4 ( b int ) ;
> FYI:
> $ java org.apache.derby.tools.ij
> ij version 10.3
> ij> run 'weird1.sql';
> ij> connect 'jdbc:derby:wombat;create=true';
> ij> create table t1(a int ) ;
> 0 rows inserted/updated/deleted
> ij> create table "t2"(a int ) ;
> 0 rows inserted/updated/deleted
> ij> -- this should fail.
> create table foo (a int ,  \"YEAR\" int ) ;
> ERROR 42X02: Lexical error at line 2, column 28.  Encountered: "\\" (92), 
> after
> : "".
> ij> -- but this should not fail. But failing
> create table t4 ( b int ) ;
> ERROR 42X01: Syntax error: Encountered "" at line 2, column 21.
> ij>

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

        

Reply via email to