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

min ( distinct ) over ( ) returns wrong value

Details

    Description

      10.2.3 beta

      The following query works

      select TDEC.CDEC, min( distinct TDEC.CDEC ) over () from TDEC 
       
      CDEC	min( distinct TDEC.CDEC ) over ()
      <null>	-1
      -1	-1
      0	-1
      1	-1
      0.1	-1
      10	-1
      

      The same query applied to a simple view that projects the table does not

      select `tdec`.`RNUM` AS `RNUM`,`tdec`.`CDEC` AS `CDEC` from `tdec` 
       
       
      select VDEC.CDEC, min( distinct VDEC.CDEC ) over () from VDEC 
       
      CDEC	min( distinct VDEC.CDEC ) over ()
      <null>	10
      -1	10
      0	10
      1	10
      0.1	10
      10	10
      

      Attachments

        Activity

          Thanks for the report.

          Test case

          create table TDEC (CDEC int, RNUM int);
          create view VDEC as select * from TDEC;
          insert into TDEC (CDEC) values (null),(-1),(0),(1),(0),(10);
          select TDEC.CDEC, min( distinct TDEC.CDEC ) over () from TDEC ;
          select VDEC.CDEC, min( distinct VDEC.CDEC ) over () from VDEC ;
          

          MariaDB [test]> select TDEC.CDEC, min( distinct TDEC.CDEC ) over () from TDEC ;
          +------+-----------------------------------+
          | CDEC | min( distinct TDEC.CDEC ) over () |
          +------+-----------------------------------+
          | NULL |                                -1 |
          |   -1 |                                -1 |
          |    0 |                                -1 |
          |    1 |                                -1 |
          |    0 |                                -1 |
          |   10 |                                -1 |
          +------+-----------------------------------+
          6 rows in set (0.00 sec)
          

          MariaDB [test]> select VDEC.CDEC, min( distinct VDEC.CDEC ) over () from VDEC ;
          +------+-----------------------------------+
          | CDEC | min( distinct VDEC.CDEC ) over () |
          +------+-----------------------------------+
          | NULL |                                10 |
          |   -1 |                                10 |
          |    0 |                                10 |
          |    1 |                                10 |
          |    0 |                                10 |
          |   10 |                                10 |
          +------+-----------------------------------+
          6 rows in set (0.00 sec)
          

          elenst Elena Stepanova added a comment - Thanks for the report. Test case create table TDEC (CDEC int , RNUM int ); create view VDEC as select * from TDEC; insert into TDEC (CDEC) values ( null ),(-1),(0),(1),(0),(10); select TDEC.CDEC, min ( distinct TDEC.CDEC ) over () from TDEC ; select VDEC.CDEC, min ( distinct VDEC.CDEC ) over () from VDEC ; MariaDB [test]> select TDEC.CDEC, min ( distinct TDEC.CDEC ) over () from TDEC ; + ------+-----------------------------------+ | CDEC | min ( distinct TDEC.CDEC ) over () | + ------+-----------------------------------+ | NULL | -1 | | -1 | -1 | | 0 | -1 | | 1 | -1 | | 0 | -1 | | 10 | -1 | + ------+-----------------------------------+ 6 rows in set (0.00 sec) MariaDB [test]> select VDEC.CDEC, min ( distinct VDEC.CDEC ) over () from VDEC ; + ------+-----------------------------------+ | CDEC | min ( distinct VDEC.CDEC ) over () | + ------+-----------------------------------+ | NULL | 10 | | -1 | 10 | | 0 | 10 | | 1 | 10 | | 0 | 10 | | 10 | 10 | + ------+-----------------------------------+ 6 rows in set (0.00 sec)

          No longer reproducible. Probably fixed by one of Igor's patches. Adding testcase and closing.

          cvicentiu Vicențiu Ciorbaru added a comment - No longer reproducible. Probably fixed by one of Igor's patches. Adding testcase and closing.

          Current HEAD doesn't feature this problem. Added test case just in case.

          cvicentiu Vicențiu Ciorbaru added a comment - Current HEAD doesn't feature this problem. Added test case just in case.

          People

            cvicentiu Vicențiu Ciorbaru
            the6campbells the6campbells
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.