Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-6688

NPE (or sane: ASSERT failure) with ROW_NUMBER in some subqueries

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.10.2.0
    • Fix Version/s: 10.10.2.1, 10.11.1.1, 10.12.1.1
    • Component/s: SQL
    • Labels:
      None
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Deviation from standard

      Description

      This subquery usage works:

      select * from (select x from t order by row_number() over () fetch first 1 row only) tt;
      

      but this one leads to NPE in insane mode, or a Sanity ASSERT failure in sane mode:

      select * from t where x =  (select x from t order by row_number() over () fetch first row only);
      

      leading to this error:

      Exception in thread "main" java.sql.SQLException: Java exception: ': java.lang.NullPointerException'.
              at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
              at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
              at org.apache.derby.impl.jdbc.Util.seeNextException(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.EmbedStatement.execute(Unknown Source)
              at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
              at derby6565.Derby6565.main(Derby6565.java:33)
      Caused by: ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
              at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
              at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source)
              ... 11 more
      Caused by: java.lang.NullPointerException
              at org.apache.derby.impl.sql.compile.UnaryOperatorNode.getReceiverInterfaceName(Unknown Source)
              at org.apache.derby.impl.sql.compile.UnaryOperatorNode.generateExpression(Unknown Source)
              at org.apache.derby.impl.sql.compile.ResultColumn.generateExpression(Unknown Source)
              at org.apache.derby.impl.sql.compile.ResultColumnList.generateEvaluatedRow(Unknown Source)
              at org.apache.derby.impl.sql.compile.ResultColumnList.generateCore(Unknown Source)
              at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generateMinion(Unknown Source)
              at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generate(Unknown Source)
              at org.apache.derby.impl.sql.compile.OrderByList.generate(Unknown Source)
              at org.apache.derby.impl.sql.compile.OrderByNode.generate(Unknown Source)
              at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generateMinion(Unknown Source)
              at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generate(Unknown Source)
              at org.apache.derby.impl.sql.compile.RowCountNode.generate(Unknown Source)
              at org.apache.derby.impl.sql.compile.SubqueryNode.generateExpression(Unknown Source)
              at org.apache.derby.impl.sql.compile.BinaryOperatorNode.generateExpression(Unknown Source)
              at org.apache.derby.impl.sql.compile.ResultColumn.generateExpression(Unknown Source)
              at org.apache.derby.impl.sql.compile.ResultColumnList.generateEvaluatedRow(Unknown Source)
              at org.apache.derby.impl.sql.compile.ResultColumnList.generateCore(Unknown Source)
              at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generateMinion(Unknown Source)
              at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generate(Unknown Source)
              at org.apache.derby.impl.sql.compile.UpdateNode.generate(Unknown Source)
              at org.apache.derby.impl.sql.compile.StatementNode.generate(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)
              ... 3 more
      

      The immediate problem is that the field #operand is null.

        Attachments

        1. derby-6688.diff
          2 kB
          Dag H. Wanvik
        2. derby-6688-b.diff
          5 kB
          Dag H. Wanvik
        3. derby-6688-b.status
          0.8 kB
          Dag H. Wanvik

          Issue Links

            Activity

              People

              • Assignee:
                dagw Dag H. Wanvik
                Reporter:
                dagw Dag H. Wanvik
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: