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

when lead() returns null on a datetime field, the result is treated as the literal string '[NULL]'

Details

    Description

      /* when lead() returns null on a datetime field, the result is treated as the literal string '[NULL]' */
       
      	create temporary table d1(d datetime);
      	insert into d1 values ('2018-01-01 00:00:00'),('2018-02-01 00:00:00');
      	
      	/* null record is not returned */
      	select *
      	from 
      		(
      			select *, lead(d) over (order by d) as x from d1
      		) a
      	where x is null
      	
      	/* null record is returned when treated as a string */
      	select *
      	from 
      		(
      			select *, lead(d) over (order by d) as x from d1
      		) a
      	where x = '[NULL]'
      	
      	drop table d1
      
      

      Attachments

        Issue Links

          Activity

            alice Alice Sherepa added a comment - - edited

            Here are results, that I get, seems to work correct
            Please add your .cnf file(s)

            MariaDB [test]> select version();
            +----------------+
            | version()      |
            +----------------+
            | 10.3.0-MariaDB |
            +----------------+
            1 row in set (0.00 sec)
             
            MariaDB [test]> CREATE TEMPORARY TABLE d1(d datetime);
            Query OK, 0 rows affected (0.00 sec)
             
            MariaDB [test]> INSERT INTO d1 VALUES ('2018-01-01 00:00:00'),('2018-02-01 00:00:00');
            Query OK, 2 rows affected (0.00 sec)
            Records: 2  Duplicates: 0  Warnings: 0
             
            MariaDB [test]> SELECT * FROM 
                -> (SELECT *, lead(d) over (ORDER BY d) AS x FROM d1) a
                -> WHERE x IS NULL;
            +---------------------+------+
            | d                   | x    |
            +---------------------+------+
            | 2018-02-01 00:00:00 | NULL |
            +---------------------+------+
            1 row in set, 2 warnings (0.00 sec)
             
            Warning (Code 1292): Incorrect datetime value: ''
            Warning (Code 1292): Incorrect datetime value: ''
             
            MariaDB [test]> SELECT * FROM 
                -> (SELECT *, lead(d) over (ORDER BY d) AS x FROM d1) a
                -> WHERE x = 'NULL';
            Empty set, 3 warnings (0.00 sec)
             
            Warning (Code 1292): Incorrect datetime value: 'NULL'
            Warning (Code 1292): Incorrect datetime value: ''
            Warning (Code 1292): Incorrect datetime value: ''
             
            MariaDB [test]> SELECT * FROM 
                -> (SELECT *, lead(d) over (ORDER BY d) AS x FROM d1) a
                -> WHERE x = '[NULL]';
            Empty set, 3 warnings (0.00 sec)
             
            Warning (Code 1292): Incorrect datetime value: '[NULL]'
            Warning (Code 1292): Incorrect datetime value: ''
            Warning (Code 1292): Incorrect datetime value: ''
            

            alice Alice Sherepa added a comment - - edited Here are results, that I get, seems to work correct Please add your .cnf file(s) MariaDB [test]> select version(); +----------------+ | version() | +----------------+ | 10.3.0-MariaDB | +----------------+ 1 row in set (0.00 sec)   MariaDB [test]> CREATE TEMPORARY TABLE d1(d datetime); Query OK, 0 rows affected (0.00 sec)   MariaDB [test]> INSERT INTO d1 VALUES ('2018-01-01 00:00:00'),('2018-02-01 00:00:00'); Query OK, 2 rows affected (0.00 sec) Records: 2 Duplicates: 0 Warnings: 0   MariaDB [test]> SELECT * FROM -> (SELECT *, lead(d) over (ORDER BY d) AS x FROM d1) a -> WHERE x IS NULL; +---------------------+------+ | d | x | +---------------------+------+ | 2018-02-01 00:00:00 | NULL | +---------------------+------+ 1 row in set, 2 warnings (0.00 sec)   Warning (Code 1292): Incorrect datetime value: '' Warning (Code 1292): Incorrect datetime value: ''   MariaDB [test]> SELECT * FROM -> (SELECT *, lead(d) over (ORDER BY d) AS x FROM d1) a -> WHERE x = 'NULL'; Empty set, 3 warnings (0.00 sec)   Warning (Code 1292): Incorrect datetime value: 'NULL' Warning (Code 1292): Incorrect datetime value: '' Warning (Code 1292): Incorrect datetime value: ''   MariaDB [test]> SELECT * FROM -> (SELECT *, lead(d) over (ORDER BY d) AS x FROM d1) a -> WHERE x = '[NULL]'; Empty set, 3 warnings (0.00 sec)   Warning (Code 1292): Incorrect datetime value: '[NULL]' Warning (Code 1292): Incorrect datetime value: '' Warning (Code 1292): Incorrect datetime value: ''
            corbin_mdb Corbin Bohne added a comment - - edited

            This was on a temporary install of MariaDB on AWS EC2. It's since been uninstalled and I can't recover the .cnf files. Let me talk to our DevOps to confirm the MariaDB version that we we had installed really quick and get back to you. Perhaps it was 10.3.x

            corbin_mdb Corbin Bohne added a comment - - edited This was on a temporary install of MariaDB on AWS EC2. It's since been uninstalled and I can't recover the .cnf files. Let me talk to our DevOps to confirm the MariaDB version that we we had installed really quick and get back to you. Perhaps it was 10.3.x
            corbin_mdb Corbin Bohne added a comment -

            Okay, it was actually version 10.3.7. Sorry about the initial miscommunication. Test and let me know if you can replicate.

            corbin_mdb Corbin Bohne added a comment - Okay, it was actually version 10.3.7. Sorry about the initial miscommunication. Test and let me know if you can replicate.
            alice Alice Sherepa added a comment -

            corbin_mdb, thanks, reproducible on MariaDB 10.3.5 and higher
            The behavior has changed after commit 95d075a0e5

            CREATE TEMPORARY TABLE d1(d datetime);
            INSERT INTO d1 VALUES ('2018-01-01 00:00:00'),('2018-02-01 00:00:00');
            SELECT *, lead(d) over (ORDER BY d) AS x FROM d1;
            d	x
            2018-01-01 00:00:00	2018-02-01 00:00:00
            2018-02-01 00:00:00	2018-02-01 00:00:00
            

            before:

            CREATE TEMPORARY TABLE d1(d datetime);
            INSERT INTO d1 VALUES ('2018-01-01 00:00:00'),('2018-02-01 00:00:00');
            SELECT *, lead(d) over (ORDER BY d) AS x FROM d1;
            d	x
            2018-01-01 00:00:00	2018-02-01 00:00:00
            2018-02-01 00:00:00	NULL
            

            alice Alice Sherepa added a comment - corbin_mdb , thanks, reproducible on MariaDB 10.3.5 and higher The behavior has changed after commit 95d075a0e5 CREATE TEMPORARY TABLE d1(d datetime); INSERT INTO d1 VALUES ('2018-01-01 00:00:00'),('2018-02-01 00:00:00'); SELECT *, lead(d) over (ORDER BY d) AS x FROM d1; d x 2018-01-01 00:00:00 2018-02-01 00:00:00 2018-02-01 00:00:00 2018-02-01 00:00:00 before: CREATE TEMPORARY TABLE d1(d datetime); INSERT INTO d1 VALUES ('2018-01-01 00:00:00'),('2018-02-01 00:00:00'); SELECT *, lead(d) over (ORDER BY d) AS x FROM d1; d x 2018-01-01 00:00:00 2018-02-01 00:00:00 2018-02-01 00:00:00 NULL

            People

              bar Alexander Barkov
              corbin_mdb Corbin Bohne
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.