Derby
  1. Derby
  2. DERBY-4413

INSERT from SELECT DISTINCT gives assertFailure (sane), or NPE (insane) in presence of generated columns

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.5.1.1, 10.5.2.0, 10.5.3.0
    • Fix Version/s: 10.5.3.1, 10.6.1.0
    • Component/s: SQL
    • Labels:
      None
    • Urgency:
      Normal
    • Issue & fix info:
      Repro attached

      Description

      When a generated column is present in a table, an INSERT DISTINCT fail:
      Repro:

      create table t(i integer,
      j integer not null generated always as (i*66));
      insert into t values 1,2;
      insert into t select distinct i from t;

      In an insane build we see this assertFailure:

      ij version 10.5
      ij> connect 'jdbc:derby:wombat2;create=true';
      ij> create table t(i integer,
      j integer not null generated always as (i*66));
      0 rows inserted/updated/deleted
      ij> insert into t values 1,2;
      2 rows inserted/updated/deleted
      ij> insert into t select distinct i from t;
      ERROR XJ001: Java exception: 'ASSERT FAILED col[1] is null: org.apache.derby.shared.common.sanity.AssertFailure'.
      java.sql.SQLException: Java exception: 'ASSERT FAILED col[1] is null: org.apache.derby.shared.common.sanity.AssertFailure'.
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95)
      at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87)
      at org.apache.derby.impl.jdbc.Util.javaException(Util.java:244)
      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:2201)
      at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
      at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1323)
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625)
      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:505)
      at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:347)
      at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:245)
      at org.apache.derby.impl.tools.ij.Main.go(Main.java:217)
      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)
      Caused by: java.sql.SQLException: Java exception: 'ASSERT FAILED col[1] is null: org.apache.derby.shared.common.sanity.AssertFailure'.
      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)
      ... 18 more
      Caused by: org.apache.derby.shared.common.sanity.AssertFailure: ASSERT FAILED col[1] is null
      at org.apache.derby.shared.common.sanity.SanityManager.THROWASSERT(SanityManager.java:162)
      at org.apache.derby.shared.common.sanity.SanityManager.THROWASSERT(SanityManager.java:147)
      at org.apache.derby.impl.store.access.sort.MergeSort.checkColumnTypes(MergeSort.java:458)
      at org.apache.derby.impl.store.access.sort.MergeInserter.insert(MergeInserter.java:98)
      at org.apache.derby.impl.sql.execute.SortResultSet.loadSorter(SortResultSet.java:317)
      at org.apache.derby.impl.sql.execute.SortResultSet.openCore(SortResultSet.java:268)
      at org.apache.derby.impl.sql.execute.NormalizeResultSet.openCore(NormalizeResultSet.java:139)
      at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:415)
      at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:416)
      at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:297)
      at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1235)
      ... 11 more

      1. derby-4413.diff
        4 kB
        Dag H. Wanvik
      2. derby-4413.stat
        0.3 kB
        Dag H. Wanvik
      3. derby-4413-2.diff
        5 kB
        Dag H. Wanvik
      4. derby-4413-2.stat
        0.3 kB
        Dag H. Wanvik
      5. derby-4413-rollback.diff
        3 kB
        Dag H. Wanvik
      6. derby-4413-rollback.stat
        0.1 kB
        Dag H. Wanvik

        Issue Links

          Activity

          Dag H. Wanvik created issue -
          Dag H. Wanvik made changes -
          Field Original Value New Value
          Affects Version/s 10.5.2.0 [ 12314116 ]
          Affects Version/s 10.5.1.1 [ 12313771 ]
          Dag H. Wanvik made changes -
          Attachment derby-4413.diff [ 12422968 ]
          Attachment derby-4413.stat [ 12422969 ]
          Dag H. Wanvik made changes -
          Assignee Dag H. Wanvik [ dagw ]
          Dag H. Wanvik made changes -
          Issue & fix info [Repro attached] [Patch Available, Repro attached]
          Dag H. Wanvik made changes -
          Attachment derby-4413-2.diff [ 12423089 ]
          Attachment derby-4413-2.stat [ 12423090 ]
          Dag H. Wanvik made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Issue & fix info [Repro attached, Patch Available] [Repro attached]
          Fix Version/s 10.6.0.0 [ 12313727 ]
          Resolution Fixed [ 1 ]
          Dag H. Wanvik made changes -
          Link This issue is blocked by DERBY-4442 [ DERBY-4442 ]
          Dag H. Wanvik made changes -
          Link This issue is blocked by DERBY-4442 [ DERBY-4442 ]
          Dag H. Wanvik made changes -
          Link This issue is blocked by DERBY-4442 [ DERBY-4442 ]
          Dag H. Wanvik made changes -
          Link This issue is blocked by DERBY-4442 [ DERBY-4442 ]
          Dag H. Wanvik made changes -
          Link This issue relates to DERBY-4442 [ DERBY-4442 ]
          Dag H. Wanvik made changes -
          Attachment derby-4413-rollback.diff [ 12426459 ]
          Attachment derby-4413-rollback.stat [ 12426460 ]
          Dag H. Wanvik made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Dag H. Wanvik made changes -
          Status Reopened [ 4 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Lily Wei made changes -
          Link This issue is required by DERBY-4728 [ DERBY-4728 ]
          Lily Wei made changes -
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          Mike Matrigali made changes -
          Assignee Dag H. Wanvik [ dagw ] Mike Matrigali [ mikem ]
          Mike Matrigali made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Assignee Mike Matrigali [ mikem ] Dag H. Wanvik [ dagw ]
          Fix Version/s 10.5.3.1 [ 12314182 ]
          Resolution Fixed [ 1 ]
          Dag H. Wanvik made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Gavin made changes -
          Workflow jira [ 12479796 ] Default workflow, editable Closed status [ 12798539 ]

            People

            • Assignee:
              Dag H. Wanvik
              Reporter:
              Dag H. Wanvik
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development