[MDEV-9452] Different data types for AVG(enum_field) and AVG(COALESCE(enum_field)) Created: 2016-01-22  Updated: 2019-11-18

Status: Open
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.0, 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None

Epic Link: Data type cleanups

 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.


Generated at Thu Feb 08 07:34:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.