1. Derby
  2. DERBY-1583

With grant revoke enabled, defining a trigger whose actions updates a table (from different schema) results in NPE


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s:
    • Fix Version/s:,
    • Component/s: SQL
    • Labels:
    • Urgency:


      While working on SQL authorization work, I ran across a test case where Derby will throw a NPE when a trigger is defined with it's action as update a table from another schema. I don't have much details on why but following is the test case. Derby is trying to put privilege requirement for a column into privilege requirements list and it expects the column's tableUUID to be not null but in this particular case, it is null.

      connect 'jdbc:derby:c:/dellater/dbmain;create=true' user 'mamta1' as mamta1;
      create table t11TriggerRevokeTest (c111 int not null primary key, c12 int);
      grant TRIGGER on t11TriggerRevokeTest to mamta2;
      create table t12TriggerRevokeTest (c121 int, c122 int, c123 int);
      grant UPDATE(c122, c121) on t12TriggerRevokeTest to mamta2;
      connect 'jdbc:derby:c:/dellater/dbmain;create=true' user 'mamta2' as mamta2;
      create trigger tr11t11 after insert on mamta1.t11TriggerRevokeTest for each statement mode db2sql
      update mamta1.t12TriggerRevokeTest set c122 = 99;

      The stack trace looks as follows
      ij(MAMTA2)> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.java.lang.NullPointerException
      at org.apache.derby.impl.sql.compile.CompilerContextImpl.addRequiredColumnPriv(
      at org.apache.derby.impl.sql.compile.ResultColumn.bindResultColumnByName(
      at org.apache.derby.impl.sql.compile.ResultColumnList.bindResultColumnsByName(
      at org.apache.derby.impl.sql.compile.ResultSetNode.bindResultColumns(
      at org.apache.derby.impl.sql.compile.SelectNode.bindResultColumns(
      at org.apache.derby.impl.sql.compile.UpdateNode.bind(
      at org.apache.derby.impl.sql.GenericStatement.prepMinion(
      at org.apache.derby.impl.sql.GenericStatement.prepareStorable(
      at org.apache.derby.iapi.sql.dictionary.SPSDescriptor.compileStatement(
      at org.apache.derby.iapi.sql.dictionary.SPSDescriptor.prepareAndRelease(
      at org.apache.derby.impl.sql.execute.CreateTriggerConstantAction.createSPS(
      at org.apache.derby.impl.sql.execute.CreateTriggerConstantAction.executeConstantAction(
      at org.apache.derby.impl.sql.GenericPreparedStatement.execute(
      at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(

      1. setTableDescriptor.diff
        3 kB
        Bryan Pendleton
      2. setTableDescriptor.diff
        0.3 kB
        Bryan Pendleton
      3. skipAddPriv_v2.diff
        8 kB
        Bryan Pendleton
      4. skipAddPriv_v3.diff
        9 kB
        Bryan Pendleton
      5. skipAddPriv.diff
        3 kB
        Bryan Pendleton

        Issue Links


          Gavin made changes -
          Workflow jira [ 12376749 ] Default workflow, editable Closed status [ 12801429 ]
          Andrew McIntyre made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Bryan Pendleton made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s [ 11187 ]
          Derby Info [Patch Available]
          Fix Version/s [ 12312027 ]
          Mike Matrigali made changes -
          Fix Version/s [ 12310800 ]
          Bryan Pendleton made changes -
          Attachment skipAddPriv_v3.diff [ 12339808 ]
          Bryan Pendleton made changes -
          Derby Info [Patch Available]
          Bryan Pendleton made changes -
          Attachment skipAddPriv_v2.diff [ 12339803 ]
          Bryan Pendleton made changes -
          Derby Info [Patch Available]
          Bryan Pendleton made changes -
          Attachment skipAddPriv.diff [ 12339741 ]
          Bryan Pendleton made changes -
          Link This issue relates to DERBY-1724 [ DERBY-1724 ]
          Bryan Pendleton made changes -
          Attachment setTableDescriptor.diff [ 12339650 ]
          Bryan Pendleton made changes -
          Derby Info [Patch Available]
          Assignee Bryan Pendleton [ bryanpendleton ]
          Bryan Pendleton made changes -
          Attachment setTableDescriptor.diff [ 12339646 ]
          Bryan Pendleton made changes -
          Link This issue is duplicated by DERBY-1754 [ DERBY-1754 ]
          Bryan Pendleton made changes -
          Link This issue blocks DERBY-1489 [ DERBY-1489 ]
          Rick Hillegas made changes -
          Urgency Normal Urgent
          Yip Ng made changes -
          Link This issue is related to DERBY-464 [ DERBY-464 ]
          Rick Hillegas made changes -
          Field Original Value New Value
          Urgency Normal
          Mamta A. Satoor created issue -


            • Assignee:
              Bryan Pendleton
              Mamta A. Satoor
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: