Merge 10.4 into 10.5

This commit is contained in:
Marko Mäkelä 2019-12-27 21:17:16 +02:00
commit 8cc15c036d
87 changed files with 1404 additions and 1031 deletions

View file

@ -3642,6 +3642,87 @@ x
foo
drop table t1;
#
# MDEV-16579: Wrong result of query using DISTINCT COUNT(*) OVER (*)
#
CREATE TABLE t1 (i int) ;
INSERT INTO t1 VALUES (1),(0),(1),(2),(0),(1),(2),(1),(2);
SELECT DISTINCT COUNT(*) OVER (), MOD(MIN(i),2) FROM t1 GROUP BY i ;
COUNT(*) OVER () MOD(MIN(i),2)
3 0
3 1
drop table t1;
#
# MDEV-21318: Wrong results with window functions and implicit grouping
#
CREATE TABLE t1 (a INT);
#
# With empty const table
# The expected result here is 1, NULL
#
explain
SELECT row_number() over(), sum(1) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 Const row not found; Using temporary
SELECT row_number() over(), sum(1) FROM t1;
row_number() over() sum(1)
1 NULL
insert into t1 values (2);
#
# Const table has 1 row, but still impossible where
# The expected result here is 1, NULL
#
EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where 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 WHERE noticed after reading const tables
SELECT row_number() over(), sum(1) FROM t1 where a=1;
row_number() over() sum(1)
1 NULL
#
# Impossible HAVING
# Empty result is expected
#
EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0;
row_number() over() sum(1)
#
# const table has 1 row, no impossible where
# The expected result here is 1, 2
#
EXPLAIN SELECT row_number() over(), sum(a) FROM t1 where a=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary
SELECT row_number() over(), sum(a) FROM t1 where a=2;
row_number() over() sum(a)
1 2
drop table t1;
#
# Impossible Where
#
create table t1(a int);
insert into t1 values (1);
#
# Expected result is NULL, 0, NULL
#
EXPLAIN SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
MAX(a) OVER () COUNT(a) abs(a)
NULL 0 NULL
#
# Expected result is 1, 0, NULL
#
EXPLAIN
SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
MAX(1) OVER () COUNT(a) abs(a)
1 0 NULL
drop table t1;
#
# End of 10.2 tests
#
#