Skip to content

Commit 15dcb8b

Browse files
committed
Merge 10.4 into 10.5
2 parents 617dee3 + c294443 commit 15dcb8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1364
-76
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ compile_commands.json
561561
# Clion && other JetBrains ides
562562
.idea
563563

564+
.cache/clangd
565+
566+
564567
client/mariadb
565568
client/mariadb-admin
566569
client/mariadb-binlog

cmake/cpack_rpm.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ SET(ignored
128128
"%ignore ${CMAKE_INSTALL_PREFIX}/share/pkgconfig"
129129
)
130130

131-
SET(CPACK_RPM_server_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
131+
SET(CPACK_RPM_server_USER_FILELIST
132+
${ignored}
133+
"%config(noreplace) ${INSTALL_SYSCONF2DIR}/*"
134+
"%config(noreplace) ${INSTALL_SYSCONFDIR}/logrotate.d/mysql"
135+
)
132136
SET(CPACK_RPM_common_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONFDIR}/my.cnf")
133137
SET(CPACK_RPM_shared_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
134138
SET(CPACK_RPM_client_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")

mysql-test/include/not_aix.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#
2+
# suite.pm will make sure that all tests including this file
3+
# will be skipped if run under AIX
4+
#

mysql-test/main/cte_nonrecursive.result

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,61 @@ call p1();
19641964
ERROR 42S22: Unknown column 'a' in 'field list'
19651965
drop procedure p1;
19661966
drop table t1,t2;
1967+
#
1968+
# MDEV-20411: SP containing only one SELECT with WITH clause
1969+
#
1970+
create procedure sp1 ()
1971+
with cte as (select 1 as a) select * from cte;
1972+
call sp1();
1973+
a
1974+
1
1975+
call sp1();
1976+
a
1977+
1
1978+
create table t1 (a int);
1979+
insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
1980+
create procedure sp2 ()
1981+
with cte as (select * from t1) select * from cte;
1982+
call sp2();
1983+
a
1984+
3
1985+
7
1986+
1
1987+
7
1988+
1
1989+
1
1990+
3
1991+
1
1992+
5
1993+
call sp2();
1994+
a
1995+
3
1996+
7
1997+
1
1998+
7
1999+
1
2000+
1
2001+
3
2002+
1
2003+
5
2004+
create procedure sp3 ()
2005+
with cte as (select * from t1 group by a) select * from cte;
2006+
call sp3();
2007+
a
2008+
1
2009+
3
2010+
5
2011+
7
2012+
call sp3();
2013+
a
2014+
1
2015+
3
2016+
5
2017+
7
2018+
drop procedure sp1;
2019+
drop procedure sp2;
2020+
drop procedure sp3;
2021+
drop table t1;
19672022
# End of 10.2 tests
19682023
#
19692024
# MDEV-21673: several references to CTE that uses

mysql-test/main/cte_nonrecursive.test

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,35 @@ drop procedure p1;
14751475

14761476
drop table t1,t2;
14771477

1478+
1479+
--echo #
1480+
--echo # MDEV-20411: SP containing only one SELECT with WITH clause
1481+
--echo #
1482+
1483+
create procedure sp1 ()
1484+
with cte as (select 1 as a) select * from cte;
1485+
call sp1();
1486+
call sp1();
1487+
1488+
create table t1 (a int);
1489+
insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
1490+
1491+
create procedure sp2 ()
1492+
with cte as (select * from t1) select * from cte;
1493+
call sp2();
1494+
call sp2();
1495+
1496+
create procedure sp3 ()
1497+
with cte as (select * from t1 group by a) select * from cte;
1498+
call sp3();
1499+
call sp3();
1500+
1501+
drop procedure sp1;
1502+
drop procedure sp2;
1503+
drop procedure sp3;
1504+
1505+
drop table t1;
1506+
14781507
--echo # End of 10.2 tests
14791508

14801509
--echo #

mysql-test/main/derived_cond_pushdown.result

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10646,6 +10646,208 @@ Warnings:
1064610646
Note 1003 /* select#1 */ select `v2`.`a` AS `a`,`v2`.`f` AS `f`,`v2`.`g` AS `g` from `test`.`v2` where `v2`.`a` = `v2`.`f` and `v2`.`a` = `v2`.`g`
1064710647
drop view v1,v2;
1064810648
drop table t1;
10649+
#
10650+
# MDEV-25969: Condition pushdown into derived table doesn't work if select list uses SP
10651+
#
10652+
create function f1(a int) returns int DETERMINISTIC return (a+1);
10653+
create table t1 (
10654+
pk int primary key,
10655+
a int,
10656+
b int,
10657+
key(a)
10658+
);
10659+
create table t2(a int);
10660+
insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
10661+
create table t3(a int);
10662+
insert into t3 select A.a + B.a* 10 + C.a * 100 from t2 A, t2 B, t2 C;
10663+
insert into t1 select a,a,a from t3;
10664+
create view v1 as
10665+
select
10666+
t1.a as col1,
10667+
f1(t1.b) as col2
10668+
from
10669+
t1;
10670+
create view v2 as
10671+
select
10672+
t1.a as col1,
10673+
f1(t1.b) as col2
10674+
from
10675+
t1;
10676+
create view v3 as
10677+
select col2, col1 from v1
10678+
union all
10679+
select col2, col1 from v2;
10680+
explain select * from v3 where col1=123;
10681+
id select_type table type possible_keys key key_len ref rows Extra
10682+
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where
10683+
2 DERIVED t1 ref a a 5 const 1
10684+
3 UNION t1 ref a a 5 const 1
10685+
# This must use ref accesses for reading table t1, not full scans:
10686+
explain format=json
10687+
select * from v3 where col1=123 and col2=321;
10688+
EXPLAIN
10689+
{
10690+
"query_block": {
10691+
"select_id": 1,
10692+
"table": {
10693+
"table_name": "<derived2>",
10694+
"access_type": "ALL",
10695+
"rows": 2,
10696+
"filtered": 100,
10697+
"attached_condition": "v3.col1 = 123 and v3.col2 = 321",
10698+
"materialized": {
10699+
"query_block": {
10700+
"union_result": {
10701+
"table_name": "<union2,3>",
10702+
"access_type": "ALL",
10703+
"query_specifications": [
10704+
{
10705+
"query_block": {
10706+
"select_id": 2,
10707+
"table": {
10708+
"table_name": "t1",
10709+
"access_type": "ref",
10710+
"possible_keys": ["a"],
10711+
"key": "a",
10712+
"key_length": "5",
10713+
"used_key_parts": ["a"],
10714+
"ref": ["const"],
10715+
"rows": 1,
10716+
"filtered": 100
10717+
}
10718+
}
10719+
},
10720+
{
10721+
"query_block": {
10722+
"select_id": 3,
10723+
"operation": "UNION",
10724+
"table": {
10725+
"table_name": "t1",
10726+
"access_type": "ref",
10727+
"possible_keys": ["a"],
10728+
"key": "a",
10729+
"key_length": "5",
10730+
"used_key_parts": ["a"],
10731+
"ref": ["const"],
10732+
"rows": 1,
10733+
"filtered": 100
10734+
}
10735+
}
10736+
}
10737+
]
10738+
}
10739+
}
10740+
}
10741+
}
10742+
}
10743+
}
10744+
drop function f1;
10745+
drop view v1,v2,v3;
10746+
drop table t1, t2,t3;
10747+
#
10748+
# Another testcase, with pushdown through GROUP BY
10749+
#
10750+
create table t1 (a int, b int);
10751+
insert into t1 values (1,1),(2,2),(3,3);
10752+
create function f1(a int) returns int DETERMINISTIC return (a+1);
10753+
create view v2(a, a2, s) as
10754+
select a, f1(a), sum(b) from t1 group by a, f1(a);
10755+
# Here,
10756+
# "(s+1) > 10" will be pushed into HAVING
10757+
# "a > 1" will be pushed all the way to the table scan on t1
10758+
# "a2>123" will be pushed into HAVING (as it refers to an SP call which
10759+
# prevents pushing it to the WHERE)
10760+
explain format=json
10761+
select * from v2 where (s+1) > 10 AND a > 1 and a2>123;
10762+
EXPLAIN
10763+
{
10764+
"query_block": {
10765+
"select_id": 1,
10766+
"table": {
10767+
"table_name": "<derived2>",
10768+
"access_type": "ALL",
10769+
"rows": 3,
10770+
"filtered": 100,
10771+
"attached_condition": "v2.s + 1 > 10 and v2.a > 1 and v2.a2 > 123",
10772+
"materialized": {
10773+
"query_block": {
10774+
"select_id": 2,
10775+
"having_condition": "s + 1 > 10 and a2 > 123",
10776+
"filesort": {
10777+
"sort_key": "t1.a, f1(t1.a)",
10778+
"temporary_table": {
10779+
"table": {
10780+
"table_name": "t1",
10781+
"access_type": "ALL",
10782+
"rows": 3,
10783+
"filtered": 100,
10784+
"attached_condition": "t1.a > 1"
10785+
}
10786+
}
10787+
}
10788+
}
10789+
}
10790+
}
10791+
}
10792+
}
10793+
# Extra test for 10.4+: Check that this works for pushdown into IN
10794+
# subqueries:
10795+
create table t4 (a int, b int, c decimal);
10796+
insert into t4 select a,a,a from t1;
10797+
# The subquery must be materialized and must have
10798+
# "attached_condition": "t1.a + 1 > 10",
10799+
# "having_condition": "`f1(a)` > 1 and `sum(b)` > 123",
10800+
explain format=json
10801+
select *
10802+
from t4
10803+
where
10804+
(a,b,c) in (select a, f1(a), sum(b) from t1 group by a, f1(a))
10805+
and
10806+
(a+1) > 10 AND b > 1 and c>123;
10807+
EXPLAIN
10808+
{
10809+
"query_block": {
10810+
"select_id": 1,
10811+
"table": {
10812+
"table_name": "t4",
10813+
"access_type": "ALL",
10814+
"rows": 3,
10815+
"filtered": 100,
10816+
"attached_condition": "t4.a + 1 > 10 and t4.b > 1 and t4.c > 123 and t4.a is not null and t4.b is not null and t4.c is not null"
10817+
},
10818+
"table": {
10819+
"table_name": "<subquery2>",
10820+
"access_type": "eq_ref",
10821+
"possible_keys": ["distinct_key"],
10822+
"key": "distinct_key",
10823+
"key_length": "23",
10824+
"used_key_parts": ["a", "f1(a)", "sum(b)"],
10825+
"ref": ["test.t4.a", "test.t4.b", "test.t4.c"],
10826+
"rows": 1,
10827+
"filtered": 100,
10828+
"attached_condition": "t4.c = `<subquery2>`.`sum(b)`",
10829+
"materialized": {
10830+
"unique": 1,
10831+
"query_block": {
10832+
"select_id": 2,
10833+
"having_condition": "`f1(a)` > 1 and `sum(b)` > 123",
10834+
"temporary_table": {
10835+
"table": {
10836+
"table_name": "t1",
10837+
"access_type": "ALL",
10838+
"rows": 3,
10839+
"filtered": 100,
10840+
"attached_condition": "t1.a + 1 > 10"
10841+
}
10842+
}
10843+
}
10844+
}
10845+
}
10846+
}
10847+
}
10848+
drop view v2;
10849+
drop function f1;
10850+
drop table t1, t4;
1064910851
# End of 10.2 tests
1065010852
#
1065110853
# MDEV-14579: pushdown conditions into materialized views/derived tables

0 commit comments

Comments
 (0)