Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.4.5, 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
-
MariaDB Docker (Bionic) on Ubuntu Linux 18.04
Description
Summary: The following query returns an entry ('1'), even if there is no matching columns.
CREATE SCHEMA A ; |
CREATE TABLE A.B ( C SMALLINT) ; |
INSERT INTO A.B VALUES (2); |
CREATE TABLE A.D ( E SMALLINT) ; |
SELECT 1 FROM (A.B LEFT OUTER JOIN (SELECT 2 AS G FROM A.D) I ON TRUE ) WHERE B.C = I.G ; |
I expect that an empty result set is returned because no query matches the given Condition. Postgres 11 doesn't return anything, which is correct.
MySQL 8.0.16 is also affected, I'm not sure about other mariadb or mysql versions.
Attachments
Issue Links
- relates to
-
MDEV-6892 WHERE does not apply
-
- Closed
-
Thanks! I repeated on 5.5-10.4. Also the same on Mysql 5.7.26, but Mysql 5.6.40 retured the correct result
MariaDB [test]> create table t1 (c smallint) ;
Query OK, 0 rows affected (0.040 sec)
MariaDB [test]> insert into t1 values (2);
Query OK, 1 row affected (0.010 sec)
MariaDB [test]> create table t2 (e smallint) ;
Query OK, 0 rows affected (0.031 sec)
MariaDB [test]> select 1 from (t1 left join (select 2 as g from t2) dt on true) where t1.c = dt.g ;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.001 sec)
MariaDB [test]> explain extended select 1 from (t1 left join (select 2 as g from t2) dt on true) where t1.c = dt.g ;
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------------------------------------------+
| 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 1 | 100.00 | Using where |
| 1 | SIMPLE | t2 | ALL | NULL | NULL | NULL | NULL | 1 | 100.00 | Using where; Using join buffer (flat, BNL join) |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------------------------------------------+
2 rows in set, 1 warning (0.000 sec)
Note (Code 1003): select 1 AS `1` from `test`.`t1` left join (`test`.`t2`) on(1) where `test`.`t1`.`c` = 2