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

NullPointerException during execution for query with LEFT OUTER JOIN whose inner table selects all constants.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.0.2.0, 10.0.2.1, 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.1.4, 10.3.2.1
    • Component/s: SQL
    • Labels:
      None

      Description

      For a query having a LEFT OUTER JOIN such that the right, or "inner", table is a SELECT subquery whose result column list consists entirely of constants, Derby may throw an execution-time NPE while trying to apply the join predicate. I say "may" because it depends on which join strategy the optimizer chooses.

      Using optimizer overrides I was able to reproduce this problem against trunk with the following (admittedly nonsense) query:

      create table t1 (i int, j int);
      insert into t1 values (-1, -2), (-2, -4), (-3, -9);

      select * from
      t1 left outer join
      (select -1 a, 1 b from t1) x0 --DERBY-PROPERTIES joinStrategy=NESTEDLOOP
      on x0.a = t1.i;

      I |J |A |B
      -----------------------------------------------
      -1 |-2 |-1 |1
      -1 |-2 |-1 |1
      -1 |-2 |-1 |1
      ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
      ERROR XJ001: Java exception: ': java.lang.NullPointerException'.

      Running the same query also failed with the same NPE on 10.0.2.1, even though optimizer overrides don't exist there. So I'm marking all known releases to be affected by this issue.

      Note: while this particular query may not make much sense, I have seen a user with a very large, auto-generated query that, when executed, fails due to this problem. So it is worth investigating...

        Attachments

        1. derby-3538_diff.txt
          3 kB
          Katherine Marsden
        2. d3538_notTested.diff
          0.9 kB
          A B

          Activity

            People

            • Assignee:
              army A B
              Reporter:
              army A B
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: