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

NULL is treated as 0 in CTE

    XMLWordPrintable

    Details

      Description

      testcase:

      WITH RECURSIVE cte AS (
      	SELECT 1 AS a UNION ALL
      	SELECT NULL FROM cte WHERE a IS NOT NULL)
      SELECT * FROM cte;
      

      it produces an infinite loop, so will get (max_recursive_iterations) strings with 0 (plus 1 sting with 1)
      if we use union distinct:

      MariaDB [test]> WITH RECURSIVE cte AS (
          -> SELECT 1 AS a UNION 
          -> SELECT NULL FROM cte WHERE a IS NOT NULL)
          -> SELECT * FROM cte;
      +---+
      | a |
      +---+
      | 1 |
      | 0 |
      +---+
      2 rows in set (0.001 sec)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              igor Igor Babaev
              Reporter:
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: