[MDEV-12861] FIRST_VALUE() does not preserve the exact data type Created: 2017-05-22  Updated: 2017-05-27  Resolved: 2017-05-27

Status: Closed
Project: MariaDB Server
Component/s: Data types, Optimizer - Window functions
Affects Version/s: 10.2, 10.3
Fix Version/s: 10.3.1

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: datatype

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
Relates
relates to MDEV-12617 CASE and CASE-alike hybrid functions ... Closed

 Description   

CREATE OR REPLACE TABLE t1 (a INT, b INT, c FLOAT);
INSERT INTO t1 VALUES (1,1,1),(1,2,2),(2,1,1),(2,2,2);
CREATE OR REPLACE TABLE t2 AS SELECT a, FIRST_VALUE(b) OVER(), FIRST_VALUE(c) OVER() FROM t1 GROUP BY a;
SHOW CREATE TABLE t2;

+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                            |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `FIRST_VALUE(b) OVER()` bigint(11) DEFAULT NULL,
  `FIRST_VALUE(c) OVER()` double DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Notice:

  • INT(11) became BIGINT(11)
  • FLOAT became DOUBLE


 Comments   
Comment by Alexander Barkov [ 2017-05-27 ]

Recent changes in Type_handler fixed this problem. Adding tests only.

Pushed into bb-10.2-ext

Generated at Thu Feb 08 08:01:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.