mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
FIxed bug #14927.
A query with a group by and having clauses could return a wrong result set if the having condition contained a constant conjunct evaluated to FALSE. It happened because the pushdown condition for table with grouping columns lost its constant conjuncts. Pushdown conditions are always built by the function make_cond_for_table that ignores constant conjuncts. This is apparently not correct when constant false conjuncts are present.
This commit is contained in:
@ -141,3 +141,20 @@ SUM(a)
|
||||
6
|
||||
4
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (1), (2), (1), (3), (2), (1);
|
||||
SELECT a FROM t1 GROUP BY a HAVING a > 1;
|
||||
a
|
||||
2
|
||||
3
|
||||
SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
|
||||
a
|
||||
SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
|
||||
x a
|
||||
EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
DROP table t1;
|
||||
|
Reference in New Issue
Block a user