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

NPE while inserting into a table which has a generated column and an insert trigger

    XMLWordPrintableJSON

Details

    • Normal
    • High Value Fix, Repro attached

    Description

      The following script generates an NPE on the concluding insert:

      connect 'jdbc:derby:memory:dummy;create=true';

      create function getRegion( v int )
      returns varchar( 20 )
      language java parameter style java deterministic no sql
      external name 'java.lang.Integer.toString'
      ;

      create table orders
      (
      orderID bigint primary key,
      salesPrice int not null,
      region generated always as ( getRegion( salesPrice ) )
      )
      ;
      create table dummy( a int );

      create trigger newOrderTrigger
      after insert on orders
      for each row
      insert into dummy( a ) values ( 1 )
      ;

      insert into orders( orderID, salesPrice ) values ( 1, 2 )
      ;

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

      Here is the NPE:

      java.lang.NullPointerException
      at org.apache.derby.impl.sql.execute.DMLWriteResultSet.objectifyStreams(Unknown Source)
      at org.apache.derby.impl.sql.execute.DMLWriteResultSet.getNextRowCore(Unknown Source)
      at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source)
      at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
      at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
      at org.apache.derby.impl.tools.ij.ij.executeImmediate(Unknown Source)
      at org.apache.derby.impl.tools.ij.utilMain.doCatch(Unknown Source)
      at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(Unknown Source)
      at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source)
      at org.apache.derby.impl.tools.ij.Main.go(Unknown Source)
      at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source)
      at org.apache.derby.impl.tools.ij.Main.main(Unknown Source)
      at org.apache.derby.tools.ij.main(Unknown Source)

      Attachments

        1. d4779.diff
          5 kB
          Siddharth Srivastava
        2. d4779.diff
          2 kB
          Siddharth Srivastava
        3. derby-4779_10_5_diff.txt
          6 kB
          Katherine Marsden
        4. test1.diff
          7 kB
          Siddharth Srivastava
        5. testreport.txt
          1 kB
          Siddharth Srivastava

        Issue Links

          Activity

            People

              siddharthsrivastava Siddharth Srivastava
              rhillegas Richard N. Hillegas
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: