Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-6884

greatest and coalesce on null date does not produce null

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.5.40, 10.0.14
    • Fix Version/s: 10.0
    • Component/s: OTHER
    • Labels:
      None

      Description

      I create a table and insert one row like this:

      create table datetest (nr decimal(1), date1 date);
      insert into datetest values (1,null);
      

      The bug can be reproduced with this statement:

      least(coalesce(date1), coalesce(date1)) 
      

      this should return null, but it doesnt.
      E.g.

      select * from datetest where least(coalesce(date1), coalesce(date1)) is not null; 
      

      ==> Returns one row

      It is also possible to insert this "corrupt null" into a table:

      insert into datetest select 2, least(coalesce(date1), coalesce(date1))  from datetest;
      

      if you select from this table with a select * from datetest where date1 is not null, you will get the row with nr=2

      Additional info:
      I get the same error using "greatest" instead of "least".
      I get the same error if I use more than one parameter for coalesce.
      I do not get this error if I use another datataype, like varchar instead of date.
      I do not get this error on another database like oracle 11g.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            Thanks for the report.

            Show
            elenst Elena Stepanova added a comment - Thanks for the report.

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                Sektat Marcel Schneider
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: