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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.0, 10.1, 10.2, 10.3, 10.4
    • 10.4
    • Data types
    • 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

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.