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

Simplify handling of untyped nulls in CASE and NULLIF expressions

    XMLWordPrintableJSON

Details

    • Release Note Needed

    Description

      The parser translates both CASE and NULLIF expressions into ConditionalNodes, but it represents untyped NULLs differently in the two cases.

      In a CASE expression, any branch that is an untyped NULL, is translated into an UntypedNullConstantNode that's wrapped in a CastNode that casts the value to CHAR(1). The CastNode is replaced with a cast to the correct type during the bind phase.

      A NULLIF expression is turned into a CASE expression that has a THEN NULL clause. The parser simply creates an UntypedNullConstantNode for that clause, without wrapping it in a CastNode. A CastNode is instead added during the bind phase.

      This slight difference in how NULLs are represented by the parser in the two cases, means that ConditionalNode needs to handle the two cases differently during the bind phase. It would be better if the parser generated NULLs in the same way for the two cases, so that ConditionalNode didn't need to know if it was generated for a CASE expression or a NULLIF expression.

      Attachments

        1. d6566-1a.diff
          34 kB
          Knut Anders Hatlen
        2. releaseNote.html
          5 kB
          Knut Anders Hatlen

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: