[MDEV-28673] View returns different value for min(year) function Created: 2022-05-26  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: 10.11

Type: Bug Priority: Major
Reporter: Lena Startseva Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: view-protocol

Issue Links:
PartOf
is part of MDEV-27691 make working view-protocol Open
Relates
relates to MDEV-28651 quote(NULL) returns incorrect result ... Closed

 Description   

The view created as:

CREATE TABLE t1(c1 YEAR(4));
INSERT INTO t1 VALUES (1901),(2155),(0000);
CREATE VIEW v1 AS SELECT COUNT(*) AS total_rows, MIN(c1) AS min_value, MAX(c1) FROM t1;
SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;

gives result:

total_rows	min_value	MAX(c1)
3	0000	2155

but view created as:

CREATE TABLE t1(c1 YEAR(4));
INSERT INTO t1 VALUES (1901),(2155),(0000);
CREATE VIEW v2 AS SELECT COUNT(*) AS total_rows, MIN(c1+0) AS min_value, MAX(c1+0) FROM t1;
SELECT * FROM v2;
DROP VIEW v2;
DROP TABLE t1;

gives other result:

total_rows	min_value	MAX(c1+0)
3	0	2155


Generated at Thu Feb 08 10:02:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.