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

The select stmt may fail due to "having clause is ambiguous" unexpected

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 10.1.21, 5.5, 10.0, 10.1, 10.2
    • Fix Version/s: 10.1.26, 5.5.57, 10.0.32, 10.2.8
    • Component/s: Server
    • Labels:
      None
    • Environment:
      ubuntu 14.04

      Description

      For mariadb 10.1.21

      Create two tables for test:

      mysql> create table t1 (c1 int, c2 int);
      Query OK, 0 rows affected (0.08 sec)
       
      mysql> create table t2 (c1 int, c2 int);
      Query OK, 0 rows affected (0.04 sec)
      

      Then test the following sqls:

      mysql> select t1.c1 as c1 , t2.c2 as c1 from t1, t2 where t2.c2 > 5 having t1.c1 < 3;
      Empty set (0.00 sec)
       
      mysql> select t1.c1 as c1 , t2.c2 as c1 from t1, t2 where t1.c1 < 20 and t2.c2 > 5 having t1.c1 < 3;
      Empty set (0.00 sec)
       
      mysql> select t1.c1 as c1 , t2.c2 as c1 from t1, t2 where t1.c1 < 20 and t2.c2 > 5 group by t1.c1 , t2.c2 having t1.c1 < 3;
      ERROR 1052 (23000): Column 't1.c1' in having clause is ambiguous
      

      Why the sql1 and sql2 can pass, but the sql3 fail due to "having clause is ambiguous"?
      The sql3 can pass for mariadb 10.0.27.

        Attachments

          Activity

            People

            • Assignee:
              serg Sergei Golubchik
              Reporter:
              gao1738 dennis
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: