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] [Commented] (DERBY-5161) Cannot rollback after syntax error in internal statement
Date Tue, 29 Mar 2011 09:01:07 GMT

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

Knut Anders Hatlen commented on DERBY-5161:
-------------------------------------------

The rollback exception is raised by this code in GenericLanguageConnectionContext.doRollback():

        StatementContext statementContext = getStatementContext();
        if (requestedByUser &&
            (statementContext != null) &&
            statementContext.inUse() &&
            statementContext.isAtomic())
        {
            throw StandardException.newException(SQLState.LANG_NO_ROLLBACK_IN_NESTED_CONNECTION);
        }

So it seems the problem is that the statement context wasn't popped from the stack when the
internal statement failed.

Looking at the code in GenericStatement.prepMinion(), in which the failing call to parseStatement()
is invoked, there is a try/finally block that ensures the compiler context is popped from
the stack, but the statement context isn't popped until after the finally clause, and may
therefore be forgotten in the case of a failure. I think we may want to move the call to popStatementContext()
into the finally clause.

> Cannot rollback after syntax error in internal statement
> --------------------------------------------------------
>
>                 Key: DERBY-5161
>                 URL: https://issues.apache.org/jira/browse/DERBY-5161
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.7.1.1
>            Reporter: Knut Anders Hatlen
>
> To reproduce, execute the statements below in ij. Can only be reproduced this way before
DERBY-5157. I don't know how to reproduce it when that bug is fixed.
> ij version 10.7
> ij> connect 'jdbc:derby:db;create=true';
> ij> autocommit off;
> ij> create table t(x int);
> 0 rows inserted/updated/deleted
> ij> alter table t add column """" int default 42;
> ERROR 42X01: Syntax error: Encountered "\"" at line 1, column 22.
> 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> rollback;
> ERROR X0Y67: Cannot issue rollback in a nested connection when there is a pending operation
in the parent connection.
> The error message implies that we've called rollback() on a nested transaction, whereas
we're in fact called it on the parent transaction.
> Expected result: The rollback statement should abort the transaction without raising
any errors.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message