You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2010/01/25 13:29:46 UTC

[jira] Commented: (DERBY-4488) Nullpointer when performing INSERT INTO

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

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

On the second execution, GenericStatementContext.topResultSet is null, and that's why the cleanup is not performed the second time.

The topResultSet field of the statement context is set in NoRowsResultSetImpl's constructor, so on the first execution it is non-null. When cleaning up after the error, it is set to null to prepare the statement context for reuse. Then, on re-execution, InsertResultSet sets it in normalInsertCore(). However, normalInsertCore() is not called until after getNextRowCore() has been called, so topResultSet is still null when the exception is thrown on the second execution.

DeleteResultSet and UpdateResultSet set topResultSet earlier in their setup() methods. I think InsertResultSet should do the same. It might also make sense to push this code into NoRowsResultSetImpl.setup(), and perhaps remove it from NoRowsResultSetImpl's constructor too.

> Nullpointer when performing INSERT INTO
> ---------------------------------------
>
>                 Key: DERBY-4488
>                 URL: https://issues.apache.org/jira/browse/DERBY-4488
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4, 10.3.2.1, 10.3.3.0, 10.4.1.3, 10.4.2.0, 10.5.1.1, 10.5.2.0, 10.5.3.0, 10.6.0.0
>            Reporter: Huib
>         Attachments: d4488.sql, debug info.txt
>
>
> To replicate, execute the following 4 queries:
> CREATE TABLE feed (fst INTEGER, snd VARCHAR(50), UNIQUE(fst))
> INSERT INTO feed VALUES (1, 'fst')
> CREATE TABLE tbl (col1 INTEGER, col2 INTEGER NOT NULL REFERENCES feed (fst) ON DELETE RESTRICT ON UPDATE RESTRICT)
> INSERT INTO tbl(col1) SELECT 1 FROM feed
> The result of the last INSERT INTO query is:
> java.lang.NullPointerException
> 	at org.apache.derby.impl.store.access.btree.BTreeScan.initScanParams(Unknown Source)
> 	at org.apache.derby.impl.store.access.btree.BTreeScan.reopenScan(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.TableScanResultSet.reopenScanController(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.TableScanResultSet.reopenScanController(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.TableScanResultSet.reopenCore(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.BulkTableScanResultSet.reopenCore(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.reopenCore(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.NormalizeResultSet.reopenCore(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source)

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