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

MERGE statement fails with NullPointerException if ON clause references non-existent column

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.11.1.1
    • 10.11.1.3, 10.12.1.1
    • SQL
    • None
    • Repro attached

    Description

      ij> create table t1(x int);
      0 rows inserted/updated/deleted
      ij> create table t2(y int);
      0 rows inserted/updated/deleted
      ij> merge into t1 using t2 on z when matched then update set x=x+1;
      ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
      

      Stack trace with line numbers on trunk:

      java.lang.NullPointerException
      	at org.apache.derby.impl.sql.compile.MergeNode.addColumn(MergeNode.java:947)
      	at org.apache.derby.impl.sql.compile.MergeNode.getColumnsFromList(MergeNode.java:930)
      	at org.apache.derby.impl.sql.compile.MergeNode.getColumnsInExpression(MergeNode.java:314)
      	at org.apache.derby.impl.sql.compile.MergeNode.buildSelectList(MergeNode.java:816)
      	at org.apache.derby.impl.sql.compile.MergeNode.bindLeftJoin(MergeNode.java:579)
      	at org.apache.derby.impl.sql.compile.MergeNode.bindStatement(MergeNode.java:396)
      	at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:401)
      	at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:99)
      	at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:1114)
      	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:683)
      	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:631)
      	at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:367)
      	at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:529)
      	at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:371)
      	at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:247)
      	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)
      	at org.apache.derby.iapi.tools.run.main(run.java:53)
      

      Attachments

        1. d6703-1a.diff
          4 kB
          Knut Anders Hatlen

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: