Details
Description
Consider the below: it shows how changing const table to non-const will change the resultset. This is a bug.
create table t11 (a int primary key, b int); |
insert into t11 values (1,1),(2,2); |
|
|
create table t10 (a int, b int, c int); |
insert into t10 values (10, NULL, NULL), (10, NULL, NULL); |
|
|
MariaDB [j12]> explain select t11.b, max(t10.b) from t10, t11 where t10.c<1 and t11.a=2; |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+ |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+ |
| 1 | SIMPLE | t11 | const | PRIMARY | PRIMARY | 4 | const | 1 | | |
| 1 | SIMPLE | t10 | ALL | NULL | NULL | NULL | NULL | 2 | Using where | |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+ |
2 rows in set (2.63 sec) |
|
|
MariaDB [j12]> select t11.b, max(t10.b) from t10, t11 where t10.c<1 and t11.a=2; |
+------+------------+ |
| b | max(t10.b) | |
+------+------------+ |
| 2 | NULL | |
+------+------------+ |
1 row in set (3.31 sec) |
MariaDB [j12]> alter table t11 drop primary key; |
Query OK, 2 rows affected (0.01 sec) |
Records: 2 Duplicates: 0 Warnings: 0
|
|
|
MariaDB [j12]> select t11.b, max(t10.b) from t10, t11 where t10.c<1 and t11.a=2; |
+------+------------+ |
| b | max(t10.b) | |
+------+------------+ |
| NULL | NULL | |
+------+------------+ |
1 row in set (3.66 sec) |
The bug can be repeated on current mysql-5.1