1

A minimal example for MariaDB (reproduced with with 10.2 and latest):

DROP TABLE IF EXISTS t;
CREATE TABLE t
(
 id int unsigned not null,
 value int unsigned null
);
INSERT INTO t
values (1, null);
CREATE OR REPLACE VIEW v
as
select 1 as id,
 ifnull(null, 999) as value
from t
;
select *,
 MIN(t.value) over (PARTITION BY t.id) as min_t,
 MIN(v.value) over (PARTITION BY t.id) as min_v
from t
 left join v
 on t.id > v.id
;

It returns

id value id value min_t min_v
1 null null null null 999

bit I would expect it to return

id value id value min_t min_v
1 null null null null null <-- null instead of 999

because there is only a single row and it has value = null in the window for MIN function. Sure, it is backed by a ifnull() in view's select, but the resulting set has null from a left join with no corresponding row, so it shouldn't be handled by ifnull() in the view, right?

Can this be considered a bug?

MySQL sqlfiddle example comparing using a view vs using nested selects. Nested selects produce the result I expect, using view doesn't.

Comparing to other RDBMS:

Oracle example: both ways work as I expect.

PostgreSQL example: both ways work as I expect.

asked Mar 4, 2020 at 20:02
4
  • Looks like a bug. Commented Mar 4, 2020 at 20:39
  • Have you tested with the latest version? Try on dbfiddle.uk that has MYSQL 8 and Maria 10.4 Commented Mar 4, 2020 at 20:58
  • @ypercubeTM Thanks for the suggestion. MySQL 8 works properly. MariaDB 10.3 has incorrect behavior, and MariaDB 10.4 (latest) just fails to execute the query. I ran the query in a MariaDB 10.4.12 docker container, and there is still incorrect behavior. Commented Mar 4, 2020 at 21:08
  • I suggest you should send a bug report to MariaDB list then. And feel free to self answer here that this is a bug. Commented Mar 4, 2020 at 21:12

1 Answer 1

1

Reported this as a bug to MariaDB bug tracker:

https://jira.mariadb.org/browse/MDEV-21874

answered Mar 4, 2020 at 21:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.