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

NullPointerException with JOIN...USING and invalid table name in select list

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.6.1.0
    • 10.6.1.0
    • SQL
    • None
    • Repro attached

    Description

      ij version 10.6
      ij> connect 'jdbc:derby:memory:db;create=true';
      ij> create table t(a int, b int, c int);
      0 rows inserted/updated/deleted
      ij> select t.* from t t1 join t t2 using (a);
      ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
      java.sql.SQLException: Java exception: ': java.lang.NullPointerException'.
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95)
      at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:142)
      at org.apache.derby.impl.jdbc.Util.javaException(Util.java:299)
      at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:403)
      at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
      at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2204)
      at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:614)
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:555)
      at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:329)
      at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:521)
      at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:363)
      at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:261)
      at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
      at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
      at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
      at org.apache.derby.tools.ij.main(ij.java:59)
      Caused by: java.sql.SQLException: Java exception: ': java.lang.NullPointerException'.
      at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119)
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70)
      ... 16 more
      Caused by: java.lang.NullPointerException
      at org.apache.derby.impl.sql.compile.JoinNode.getAllResultColumns(JoinNode.java:431)
      at org.apache.derby.impl.sql.compile.FromList.expandAll(FromList.java:474)
      at org.apache.derby.impl.sql.compile.ResultColumnList.expandAllsAndNameColumns(ResultColumnList.java:1598)
      at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(ResultColumnList.java:686)
      at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(SelectNode.java:451)
      at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(DMLStatementNode.java:227)
      at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java:140)
      at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(CursorNode.java:249)
      at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:319)
      at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88)
      at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:824)
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606)
      ... 9 more

      The query is expected to fail (because the table name in t.* does not match any of the joined tables), but not with a NullPointerException. A similar query with ON instead of USING fails more gracefully:

      ij> select t.* from t t1 join t t2 on t1.a=t2.a;
      ERROR 42X10: 'T' is not an exposed table name in the scope in which it appears.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            knutanders Knut Anders Hatlen
            knutanders Knut Anders Hatlen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment