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

NullPointerException at ResultSet.close() time for simple query using UNION and INTERSECT

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 10.1.3.1, 10.2.1.6
    • 10.2.1.6
    • SQL
    • None
    • Embedded and server modes, with derby.language.logQueryPlan=true

    Description

      If I set "derby.language.logQueryPlan" to true and then attempt to execute the following simple query using UNION and INTERSECT, Derby will return the correct results and then, after returning the results, will throw a NullPointerException. This error also occurs for 10.1.

      To reproduce:

      > java -Dderby.language.logQueryPlan=true org.apache.derby.tools.ij

      and then do:

      create table t1 (i int);
      create table t2 (j int);
      create table t3 (a int);

      ij> select i from t1 union (select j from t2 intersect select a from t3);
      1
      -----------

      0 rows selected
      ERROR XJ001: Java exception: ': java.lang.NullPointerException'.

      If I add data, the query will return the correct results, but then throw the NPE.

      insert into t1 values 1, 2, 3, 4, 5;
      insert into t2 values 2, 4, 6, 8, 10;
      insert into t3 values 2, 3, 4;

      ij> select i from t1 union (select j from t2 intersect select a from t3);
      1
      -----------
      1
      2
      3
      4
      5

      5 rows selected
      ERROR XJ001: Java exception: ': java.lang.NullPointerException'.

      The embedded and client stack traces are shown below. Both suggest that the problem occurs during the close of the result set.

      – Embedded –

      java.lang.NullPointerException
      at org.apache.derby.impl.sql.execute.rts.RealUnionResultSetStatistics.getStatementExecutionPlanText(RealUnionResultSetStatistics.java:107)
      at org.apache.derby.impl.sql.execute.rts.RealSortStatistics.getStatementExecutionPlanText(RealSortStatistics.java:124)
      at org.apache.derby.impl.sql.execute.rts.RunTimeStatisticsImpl.getStatementExecutionPlanText(RunTimeStatisticsImpl.java:293)
      at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.finishAndRTS(BasicNoPutResultSetImpl.java:633)
      at org.apache.derby.impl.sql.execute.SortResultSet.finish(SortResultSet.java:479)
      at org.apache.derby.impl.jdbc.EmbedResultSet.close(EmbedResultSet.java:533)
      at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:272)
      at org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:260)
      at org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:381)
      at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:434)
      at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310)
      at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
      at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
      at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:55)
      at org.apache.derby.tools.ij.main(ij.java:60)

      – Client –

      ERROR (no SQLState): actual code point, 4692 does not match expected code point, 9224
      java.sql.SQLException: actual code point, 4692 does not match expected code point, 9224
      at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:280)
      at org.apache.derby.client.am.ResultSet.close(ResultSet.java:412)
      at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:272)
      at org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:260)
      at org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:381)
      at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:434)
      at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310)
      at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
      at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
      at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:55)
      at org.apache.derby.tools.ij.main(ij.java:60)
      Caused by: org.apache.derby.client.am.DisconnectException: actual code point, 4692 does not match ex
      pected code point, 9224
      at org.apache.derby.client.net.Reply.zThrowSyntaxError(Reply.java:1157)
      at org.apache.derby.client.net.Reply.parseLengthAndMatchCodePoint(Reply.java:1057)
      at org.apache.derby.client.net.NetConnectionReply.parseSQLCARD(NetConnectionReply.java:2519)

      at org.apache.derby.client.net.NetConnectionReply.parseRDBCMMreply(NetConnectionReply.java:2
      00)
      at org.apache.derby.client.net.NetConnectionReply.readLocalCommit(NetConnectionReply.java:13
      3)
      at org.apache.derby.client.net.ConnectionReply.readLocalCommit(ConnectionReply.java:42)
      at org.apache.derby.client.net.NetConnection.readLocalCommit_(NetConnection.java:1347)
      at org.apache.derby.client.am.Connection.readCommit(Connection.java:624)
      at org.apache.derby.client.am.Connection.readAutoCommit(Connection.java:614)
      at org.apache.derby.client.am.ResultSet.readAutoCommitIfNotAutoCommitted(ResultSet.java:509)

      at org.apache.derby.client.am.ResultSet.readCloseAndAutoCommit(ResultSet.java:474)
      at org.apache.derby.client.am.ResultSet.flowCloseAndAutoCommitIfNotAutoCommitted(ResultSet.j
      ava:455)
      at org.apache.derby.client.am.ResultSet.closeX(ResultSet.java:425)
      at org.apache.derby.client.am.ResultSet.close(ResultSet.java:407)

      ERROR XJ001: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC: java.lang.NullPointerException
      [XX] XJ001.U
      java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC: java.lang.NullPointerException[XX]XJ001.U
      at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:280)
      at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:295)
      at org.apache.derby.client.am.ResultSet.close(ResultSet.java:412)
      at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:272)
      at org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:260)
      at org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:381)
      at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:434)
      at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310)
      at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
      at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
      at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:55)
      at org.apache.derby.tools.ij.main(ij.java:60)

      Attachments

        1. derby939trunkdiffpatch2.txt
          41 kB
          Yip Ng
        2. derby939trunkstatpatch2.txt
          0.7 kB
          Yip Ng
        3. derby939trunkdiffpatch1.txt
          40 kB
          Yip Ng
        4. derby939trunkstatpatch1.txt
          0.7 kB
          Yip Ng

        Activity

          People

            yipng Yip Ng
            army A B
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: