Skip to content

Commit

Permalink
Merge 10.5 into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Jul 2, 2021
2 parents 315380a + 7792628 commit 0ad8a82
Show file tree
Hide file tree
Showing 52 changed files with 1,429 additions and 104 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ compile_commands.json
# Clion && other JetBrains ides
.idea

.cache/clangd


client/mariadb
client/mariadb-admin
client/mariadb-binlog
Expand Down
6 changes: 5 additions & 1 deletion cmake/cpack_rpm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ SET(ignored
"%ignore ${CMAKE_INSTALL_PREFIX}/share/pkgconfig"
)

SET(CPACK_RPM_server_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
SET(CPACK_RPM_server_USER_FILELIST
${ignored}
"%config(noreplace) ${INSTALL_SYSCONF2DIR}/*"
"%config(noreplace) ${INSTALL_SYSCONFDIR}/logrotate.d/mysql"
)
SET(CPACK_RPM_common_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONFDIR}/my.cnf")
SET(CPACK_RPM_shared_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
SET(CPACK_RPM_client_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
Expand Down
2 changes: 1 addition & 1 deletion cmake/submodules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
RESULT_VARIABLE update_result)
ELSE()
MESSAGE(STATUS "Updating submodules")
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive --depth=1
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE update_result)
ENDIF()
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/include/not_aix.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#
# suite.pm will make sure that all tests including this file
# will be skipped if run under AIX
#
55 changes: 55 additions & 0 deletions mysql-test/main/cte_nonrecursive.result
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,61 @@ call p1();
ERROR 42S22: Unknown column 'a' in 'field list'
drop procedure p1;
drop table t1,t2;
#
# MDEV-20411: SP containing only one SELECT with WITH clause
#
create procedure sp1 ()
with cte as (select 1 as a) select * from cte;
call sp1();
a
1
call sp1();
a
1
create table t1 (a int);
insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
create procedure sp2 ()
with cte as (select * from t1) select * from cte;
call sp2();
a
3
7
1
7
1
1
3
1
5
call sp2();
a
3
7
1
7
1
1
3
1
5
create procedure sp3 ()
with cte as (select * from t1 group by a) select * from cte;
call sp3();
a
1
3
5
7
call sp3();
a
1
3
5
7
drop procedure sp1;
drop procedure sp2;
drop procedure sp3;
drop table t1;
# End of 10.2 tests
#
# MDEV-21673: several references to CTE that uses
Expand Down
29 changes: 29 additions & 0 deletions mysql-test/main/cte_nonrecursive.test
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,35 @@ drop procedure p1;

drop table t1,t2;


--echo #
--echo # MDEV-20411: SP containing only one SELECT with WITH clause
--echo #

create procedure sp1 ()
with cte as (select 1 as a) select * from cte;
call sp1();
call sp1();

create table t1 (a int);
insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);

create procedure sp2 ()
with cte as (select * from t1) select * from cte;
call sp2();
call sp2();

create procedure sp3 ()
with cte as (select * from t1 group by a) select * from cte;
call sp3();
call sp3();

drop procedure sp1;
drop procedure sp2;
drop procedure sp3;

drop table t1;

--echo # End of 10.2 tests

--echo #
Expand Down
202 changes: 202 additions & 0 deletions mysql-test/main/derived_cond_pushdown.result
Original file line number Diff line number Diff line change
Expand Up @@ -10646,6 +10646,208 @@ Warnings:
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`
drop view v1,v2;
drop table t1;
#
# MDEV-25969: Condition pushdown into derived table doesn't work if select list uses SP
#
create function f1(a int) returns int DETERMINISTIC return (a+1);
create table t1 (
pk int primary key,
a int,
b int,
key(a)
);
create table t2(a int);
insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t3(a int);
insert into t3 select A.a + B.a* 10 + C.a * 100 from t2 A, t2 B, t2 C;
insert into t1 select a,a,a from t3;
create view v1 as
select
t1.a as col1,
f1(t1.b) as col2
from
t1;
create view v2 as
select
t1.a as col1,
f1(t1.b) as col2
from
t1;
create view v3 as
select col2, col1 from v1
union all
select col2, col1 from v2;
explain select * from v3 where col1=123;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where
2 DERIVED t1 ref a a 5 const 1
3 UNION t1 ref a a 5 const 1
# This must use ref accesses for reading table t1, not full scans:
explain format=json
select * from v3 where col1=123 and col2=321;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "<derived2>",
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "v3.col1 = 123 and v3.col2 = 321",
"materialized": {
"query_block": {
"union_result": {
"table_name": "<union2,3>",
"access_type": "ALL",
"query_specifications": [
{
"query_block": {
"select_id": 2,
"table": {
"table_name": "t1",
"access_type": "ref",
"possible_keys": ["a"],
"key": "a",
"key_length": "5",
"used_key_parts": ["a"],
"ref": ["const"],
"rows": 1,
"filtered": 100
}
}
},
{
"query_block": {
"select_id": 3,
"operation": "UNION",
"table": {
"table_name": "t1",
"access_type": "ref",
"possible_keys": ["a"],
"key": "a",
"key_length": "5",
"used_key_parts": ["a"],
"ref": ["const"],
"rows": 1,
"filtered": 100
}
}
}
]
}
}
}
}
}
}
drop function f1;
drop view v1,v2,v3;
drop table t1, t2,t3;
#
# Another testcase, with pushdown through GROUP BY
#
create table t1 (a int, b int);
insert into t1 values (1,1),(2,2),(3,3);
create function f1(a int) returns int DETERMINISTIC return (a+1);
create view v2(a, a2, s) as
select a, f1(a), sum(b) from t1 group by a, f1(a);
# Here,
# "(s+1) > 10" will be pushed into HAVING
# "a > 1" will be pushed all the way to the table scan on t1
# "a2>123" will be pushed into HAVING (as it refers to an SP call which
# prevents pushing it to the WHERE)
explain format=json
select * from v2 where (s+1) > 10 AND a > 1 and a2>123;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "<derived2>",
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "v2.s + 1 > 10 and v2.a > 1 and v2.a2 > 123",
"materialized": {
"query_block": {
"select_id": 2,
"having_condition": "s + 1 > 10 and a2 > 123",
"filesort": {
"sort_key": "t1.a, f1(t1.a)",
"temporary_table": {
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "t1.a > 1"
}
}
}
}
}
}
}
}
# Extra test for 10.4+: Check that this works for pushdown into IN
# subqueries:
create table t4 (a int, b int, c decimal);
insert into t4 select a,a,a from t1;
# The subquery must be materialized and must have
# "attached_condition": "t1.a + 1 > 10",
# "having_condition": "`f1(a)` > 1 and `sum(b)` > 123",
explain format=json
select *
from t4
where
(a,b,c) in (select a, f1(a), sum(b) from t1 group by a, f1(a))
and
(a+1) > 10 AND b > 1 and c>123;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t4",
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"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"
},
"table": {
"table_name": "<subquery2>",
"access_type": "eq_ref",
"possible_keys": ["distinct_key"],
"key": "distinct_key",
"key_length": "23",
"used_key_parts": ["a", "f1(a)", "sum(b)"],
"ref": ["test.t4.a", "test.t4.b", "test.t4.c"],
"rows": 1,
"filtered": 100,
"attached_condition": "t4.c = `<subquery2>`.`sum(b)`",
"materialized": {
"unique": 1,
"query_block": {
"select_id": 2,
"having_condition": "`f1(a)` > 1 and `sum(b)` > 123",
"temporary_table": {
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "t1.a + 1 > 10"
}
}
}
}
}
}
}
drop view v2;
drop function f1;
drop table t1, t4;
# End of 10.2 tests
#
# MDEV-14579: pushdown conditions into materialized views/derived tables
Expand Down
Loading

0 comments on commit 0ad8a82

Please sign in to comment.