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:
@ -135,4 +135,20 @@ SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a);
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #14927: HAVING clause containing constant false conjunct
|
||||
#
|
||||
|
||||
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;
|
||||
SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
|
||||
SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
|
||||
|
||||
EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
|
||||
EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
|
||||
|
||||
DROP table t1;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
Reference in New Issue
Block a user