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

Different data types for AVG(enum_field) and AVG(COALESCE(enum_field))

    Details

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

      Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (f1 enum('1','2','3','4','5')) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (1),(2);
      DROP TABLE IF EXISTS t2;
      CREATE TABLE t2 AS SELECT AVG(f1),AVG(COALESCE(f1)) FROM t1;
      SHOW CREATE TABLE t2;
      

      returns

      +-------+---------------------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                                |
      +-------+---------------------------------------------------------------------------------------------------------------------------------------------+
      | t2    | CREATE TABLE `t2` (
        `AVG(f1)` decimal(5,4) DEFAULT NULL,
        `AVG(COALESCE(f1))` double DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+---------------------------------------------------------------------------------------------------------------------------------------------+
      

      Perhaps it should create columns of the same type.
      It's not clear what type it should be. ENUM is a special kind of string. But it has INT-alike behavior in some cases.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: