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 2009/05/25 20:44:45 UTC

[jira] Commented: (DERBY-4247) Null pointer exception generated when preparing a statement containing "IN (?)" or "= ?", but not if using "IN (?, ?)" or enclosing the select query in another query.

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

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

Using the SQL script Bryan posted at derby-user (http://mail-archives.apache.org/mod_mbox/db-derby-user/200905.mbox/%3c4A1ABAF2.4040903@amberpoint.com%3e) I found that the query started failing after this commit:

------------------------------------------------------------------------
r754579 | dag | 2009-03-15 02:30:42 +0100 (Sun, 15 Mar 2009) | 4 lines

DERBY-4071 AssertFailure when selecting rows from a table with CHARACTER and VARCHAR columns

Patch derby-4071 which fixes this issue.

------------------------------------------------------------------------

> Null pointer exception generated when preparing a statement containing "IN (?)" or "= ?", but not if using "IN (?, ?)" or enclosing the select query in another query.
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4247
>                 URL: https://issues.apache.org/jira/browse/DERBY-4247
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.1.1
>         Environment: Nom du système d'exploitation :         Linux
> Architecture du système d'exploitation :         i386
> Version du système d'exploitation :         2.6.22.18-laptop-1mdv
> java.specification.name: Java Platform API Specification
> java.specification.version: 1.6
> --------- Informations Derby --------
> JRE - JDBC: Java SE 6 - JDBC 4.0
> [/home/gleguern/office/atelier/jmbrowser/libs/derby.jar] 10.5.1.1 - (764942)
> [/usr/local/db-derby-10.4.2.0-bin/lib/derbytools.jar] 10.4.2.0 - (689064)
> [/usr/local/db-derby-10.4.2.0-bin/lib/derby.jar] 10.4.2.0 - (689064)
> ------------------------------------------------------
>            Reporter: Le Guernic
>
> Null pointer exception generated when preparing a statement containing "IN (?)", "GROUP BY", and "HAVING".
> The bug occurs if using "IN (?)" or "= ?", but not if using "IN (?, ?)" or enclosing the select query in another query.
> The tables involved are:
> 	"CREATE TABLE types (" +
> 	"  id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY," +
> 	"  name VARCHAR(128) NOT NULL UNIQUE," +
> 	"  shortName VARCHAR(64) NOT NULL" +
> 	")";
> 	"CREATE TABLE methodParameters (" +
> 	"  method INT REFERENCES methods (id)," +
> 	"  position INT," +
> 	"  parameter INT REFERENCES types (id)" +
> 	")";
> The null pointer exception is generated by the command:   dbConnection.prepareStatement(sqlStr);
> when sqlStr is:
>   SELECT method   FROM methodParameters AS mp        INNER JOIN types ON mp.parameter = types.id   WHERE types.name IN (?)   GROUP BY method   HAVING COUNT(method) >= ?
> or
>   SELECT method   FROM methodParameters AS mp        INNER JOIN types ON mp.parameter = types.id   WHERE types.name = ?   GROUP BY method   HAVING COUNT(method) >= ?
> but not when sqlStr is:
>   SELECT method   FROM methodParameters AS mp        INNER JOIN types ON mp.parameter = types.id   WHERE types.name IN (?, ?)   GROUP BY method   HAVING COUNT(method) >= ?
> or
> SELECT method FROM methodParameters WHERE method IN (  SELECT method   FROM methodParameters AS mp        INNER JOIN types ON mp.parameter = types.id   WHERE types.name IN (?)   GROUP BY method   HAVING COUNT(method) >= ? )
> The information about the exception are:
>  SQL state: XJ001
>  Error code: 0
>  Message: Exception Java : ': java.lang.NullPointerException'.
> java.sql.SQLException: Exception Java : ': java.lang.NullPointerException'.
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
>         at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
>         at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
>         at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
>         at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
>         at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement40.<init>(Unknown Source)
>         at org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
>         at org.thinkcollabs.jmbrowser.db.DAO.initSelect(DAO.java:375)
>         at org.thinkcollabs.jmbrowser.db.DB_Derby$MethodDataLoader.run(DB_Derby.java:254)
> Caused by: java.sql.SQLException: Exception Java : ': java.lang.NullPointerException'.
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
>         ... 16 more
> Caused by: java.lang.NullPointerException
>         at org.apache.derby.impl.sql.compile.ColumnReference.remapColumnReferencesToExpressions(Unknown Source)
>         at org.apache.derby.impl.sql.compile.AggregateNode.getNewExpressionResultColumn(Unknown Source)
>         at org.apache.derby.impl.sql.compile.GroupByNode.addAggregateColumns(Unknown Source)
>         at org.apache.derby.impl.sql.compile.GroupByNode.addNewColumnsForAggregation(Unknown Source)
>         at org.apache.derby.impl.sql.compile.GroupByNode.addAggregates(Unknown Source)
>         at org.apache.derby.impl.sql.compile.GroupByNode.init(Unknown Source)
>         at org.apache.derby.iapi.sql.compile.NodeFactory.getNode(Unknown Source)
>         at org.apache.derby.impl.sql.compile.SelectNode.genProjectRestrict(Unknown Source)
>         at org.apache.derby.impl.sql.compile.SelectNode.modifyAccessPaths(Unknown Source)
>         at org.apache.derby.impl.sql.compile.DMLStatementNode.optimizeStatement(Unknown Source)
>         at org.apache.derby.impl.sql.compile.CursorNode.optimizeStatement(Unknown Source)
>         at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
>         at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
>         at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
>         ... 9 more

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