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

ONLY_FULL_GROUP_BY is not applied to queries from view

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.5, 10.1, 10.2, 10.3, 10.4
    • Fix Version/s: 10.1, 10.2, 10.3, 10.4
    • Component/s: Views
    • Labels:
      None

      Description

      ONLY_FULL_GROUP_BY is ignored when a query is reading from a view:

      CREATE TABLE t (a INT);
      INSERT INTO t VALUES (1),(2);
      CREATE VIEW v AS SELECT * FROM t;
      SET sql_mode= 'ONLY_FULL_GROUP_BY';
      SELECT a, COUNT(*) FROM v;
       
      # Cleanup
      DROP VIEW v;
      DROP TABLE t;
      

      10.4 c3394870

      MariaDB [test]> SET sql_mode= 'ONLY_FULL_GROUP_BY';
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> SELECT a, COUNT(*) FROM v;
      +------+----------+
      | a    | COUNT(*) |
      +------+----------+
      |    1 |        2 |
      +------+----------+
      1 row in set (0.001 sec)
      

      With the table, it works as expected:

      MariaDB [test]> SELECT a, COUNT(*) FROM t;
      ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
      

      Reproducible on all MariaDB versions (5.5-10.5). Not reproducible with MySQL (strangely, even with MySQL 5.5).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sanja Oleksandr Byelkin
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: