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

group by removal in Item_singlerow_subselect causing inconsistent results

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5.27
    • 10.5
    • Optimizer
    • None

    Description

      create table t1 (t1a int, t1b int, t1c int) engine=myisam;
      insert into t1 values (1,1,1),(2,2,2);
       
      create table t2 (t2a int, t2b int, t2c int) engine=myisam;
      insert into t2 values (1,1,1),(2,2,2),(3,3,3);
      

      MariaDB [test]> select * from t2 where t2a in ( select t1a from t1 group by (select t1a > t2b) order by t1a );
       
      +------+------+------+
      | t2a  | t2b  | t2c  |
      +------+------+------+
      |    1 |    1 |    1 |
      |    2 |    2 |    2 |
      +------+------+------+
       
      2 rows in set (0.051 sec)
      MariaDB [test]> select * from t2 where t2a in ( select t1a from t1 group by (select t1a > t2b where true) order by t1a );
      +------+------+------+
      | t2a  | t2b  | t2c  |
      +------+------+------+
      |    1 |    1 |    1 |
      +------+------+------+
      1 row in set (0.019 sec)
       
      MariaDB [test]> prepare s from 'select * from t2 where t2a in ( select t1a from t1 group by (select t1a > t2b) order by t1a )';
       
      Query OK, 0 rows affected (0.006 sec)
      Statement prepared
       
      MariaDB [test]> execute s;
      +------+------+------+
      | t2a  | t2b  | t2c  |
      +------+------+------+
      |    1 |    1 |    1 |
      +------+------+------+
      
      

      Attachments

        Issue Links

          Activity

            Johnston Rex Johnston created issue -
            Johnston Rex Johnston made changes -
            Field Original Value New Value
            Description {code:sql}
            MariaDB [test]> select * from t2 where t2a in ( select t1a from t1 group by (select t1a > t2b) order by t1a );

            +------+------+------+
            | t2a | t2b | t2c |
            +------+------+------+
            | 1 | 1 | 1 |
            | 2 | 2 | 2 |
            +------+------+------+

            2 rows in set (0.051 sec)
            MariaDB [test]> select * from t2 where t2a in ( select t1a from t1 group by (select t1a > t2b where 1 > 0) order by t1a );
            +------+------+------+
            | t2a | t2b | t2c |
            +------+------+------+
            | 1 | 1 | 1 |
            +------+------+------+
            1 row in set (0.019 sec)

            MariaDB [test]> prepare s from 'select * from t2 where t2a in ( select t1a from t1 group by (select t1a > t2b) order by t1a )';

            Query OK, 0 rows affected (0.006 sec)
            Statement prepared

            MariaDB [test]> execute s;
            +------+------+------+
            | t2a | t2b | t2c |
            +------+------+------+
            | 1 | 1 | 1 |
            +------+------+------+

            {code}


            {code:sql}
            create table t1 (t1a int, t1b int, t1c int) engine=myisam;
            insert into t1 values (1,1,1),(2,2,2);

            create table t2 (t2a int, t2b int, t2c int) engine=myisam;
            insert into t2 values (1,1,1),(2,2,2),(3,3,3);
            {code}

            {code:sql}
            MariaDB [test]> select * from t2 where t2a in ( select t1a from t1 group by (select t1a > t2b) order by t1a );

            +------+------+------+
            | t2a | t2b | t2c |
            +------+------+------+
            | 1 | 1 | 1 |
            | 2 | 2 | 2 |
            +------+------+------+

            2 rows in set (0.051 sec)
            MariaDB [test]> select * from t2 where t2a in ( select t1a from t1 group by (select t1a > t2b where true) order by t1a );
            +------+------+------+
            | t2a | t2b | t2c |
            +------+------+------+
            | 1 | 1 | 1 |
            +------+------+------+
            1 row in set (0.019 sec)

            MariaDB [test]> prepare s from 'select * from t2 where t2a in ( select t1a from t1 group by (select t1a > t2b) order by t1a )';

            Query OK, 0 rows affected (0.006 sec)
            Statement prepared

            MariaDB [test]> execute s;
            +------+------+------+
            | t2a | t2b | t2c |
            +------+------+------+
            | 1 | 1 | 1 |
            +------+------+------+

            {code}


            Johnston Rex Johnston made changes -
            Assignee Rex Johnston [ JIRAUSER52533 ]
            Johnston Rex Johnston made changes -
            Johnston Rex Johnston made changes -
            Johnston Rex Johnston made changes -
            Johnston Rex Johnston made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            JIraAutomate JiraAutomate made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]

            People

              Johnston Rex Johnston
              Johnston Rex Johnston
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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