Skip to content

Commit 5489ce0

Browse files
committed
Merge 10.4 into 10.5
2 parents ebb15f9 + 70e788b commit 5489ce0

14 files changed

+249
-110
lines changed

cmake/install_macros.cmake

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,20 @@ IF(WIN32)
182182
SET(SIGNTOOL_PARAMETERS
183183
/a /t http://timestamp.globalsign.com/?signature=sha2
184184
CACHE STRING "parameters for signtool (list)")
185-
FIND_PROGRAM(SIGNTOOL_EXECUTABLE signtool
186-
PATHS "$ENV{ProgramFiles}/Microsoft SDKs/Windows/v7.0A/bin"
187-
"$ENV{ProgramFiles}/Windows Kits/8.0/bin/x86"
188-
"$ENV{ProgramFiles}/Windows Kits/8.1/bin/x86"
189-
)
190185
IF(NOT SIGNTOOL_EXECUTABLE)
191-
MESSAGE(FATAL_ERROR
192-
"signtool is not found. Signing executables not possible")
186+
FILE(GLOB path_list
187+
"$ENV{ProgramFiles} (x86)/Windows Kits/*/bin/*/x64"
188+
"$ENV{ProgramFiles} (x86)/Windows Kits/*/App Certification Kit"
189+
)
190+
FIND_PROGRAM(SIGNTOOL_EXECUTABLE signtool
191+
PATHS ${path_list}
192+
)
193+
IF(NOT SIGNTOOL_EXECUTABLE)
194+
MESSAGE(FATAL_ERROR
195+
"signtool is not found. Signing executables not possible")
196+
ENDIF()
197+
MARK_AS_ADVANCED(SIGNTOOL_EXECUTABLE SIGNTOOL_PARAMETERS)
193198
ENDIF()
194-
MARK_AS_ADVANCED(SIGNTOOL_EXECUTABLE SIGNTOOL_PARAMETERS)
195199
ENDIF()
196200
ENDIF()
197201

mysql-test/main/cte_nonrecursive.result

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,6 +2086,56 @@ a b a b
20862086
1 3 1 3
20872087
drop procedure sp;
20882088
drop table t1;
2089+
#
2090+
# MDEV-26825: query with two usage of CTE that refers to another CTE
2091+
# with stored function using a base table.
2092+
#
2093+
create table t1 (id int primary key);
2094+
insert into t1 values
2095+
(1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
2096+
create function f(in_id int) returns integer
2097+
return (select id from t1 where t1.id = in_id);
2098+
with c1 as (select id from t1 where f(id)=id group by id),
2099+
c2 as (select id from c1 as pt group by id)
2100+
select id from c2 as s1 union select id from c2 as s2;
2101+
id
2102+
1
2103+
2
2104+
3
2105+
4
2106+
5
2107+
6
2108+
7
2109+
8
2110+
9
2111+
10
2112+
with c1 as (select id from t1 as r where f(id)=id group by id),
2113+
c2 as (select id from c1 as pt group by id)
2114+
select id from c2 as s1 union select id from c2 as s2;
2115+
id
2116+
1
2117+
2
2118+
3
2119+
4
2120+
5
2121+
6
2122+
7
2123+
8
2124+
9
2125+
10
2126+
create function g() returns int return (select count(*) from t1);
2127+
create procedure sp1()
2128+
with c1 as (select id from t1 a where g() > 10),
2129+
c2 as (select id from c1)
2130+
select id from c2 as s1 union select id from c2 as s2;
2131+
call sp1();
2132+
id
2133+
call sp1();
2134+
id
2135+
drop procedure sp1;
2136+
drop function g;
2137+
drop function f;
2138+
drop table t1;
20892139
# End of 10.2 tests
20902140
#
20912141
# MDEV-21673: several references to CTE that uses

mysql-test/main/cte_nonrecursive.test

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,42 @@ call sp();
15541554
drop procedure sp;
15551555
drop table t1;
15561556

1557+
--echo #
1558+
--echo # MDEV-26825: query with two usage of CTE that refers to another CTE
1559+
--echo # with stored function using a base table.
1560+
--echo #
1561+
1562+
create table t1 (id int primary key);
1563+
insert into t1 values
1564+
(1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
1565+
1566+
create function f(in_id int) returns integer
1567+
return (select id from t1 where t1.id = in_id);
1568+
1569+
with c1 as (select id from t1 where f(id)=id group by id),
1570+
c2 as (select id from c1 as pt group by id)
1571+
select id from c2 as s1 union select id from c2 as s2;
1572+
1573+
with c1 as (select id from t1 as r where f(id)=id group by id),
1574+
c2 as (select id from c1 as pt group by id)
1575+
select id from c2 as s1 union select id from c2 as s2;
1576+
1577+
create function g() returns int return (select count(*) from t1);
1578+
create procedure sp1()
1579+
1580+
with c1 as (select id from t1 a where g() > 10),
1581+
c2 as (select id from c1)
1582+
select id from c2 as s1 union select id from c2 as s2;
1583+
1584+
call sp1();
1585+
call sp1();
1586+
1587+
drop procedure sp1;
1588+
drop function g;
1589+
1590+
drop function f;
1591+
drop table t1;
1592+
15571593
--echo # End of 10.2 tests
15581594

15591595
--echo #
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
call mtr.add_suppression("InnoDB: .*: Page 0 at offset 0 looks corrupted");
2+
call mtr.add_suppression("Index for table 'dst' is corrupt; try to repair it");
3+
call mtr.add_suppression("Page for tablespace .* is index page with id .* but that index is not found from configuration file");
4+
CREATE TABLE src (pk INT PRIMARY KEY, value INT) ENGINE=INNODB;
5+
INSERT INTO src VALUES (1, 1), (2, 2), (3, 3);
6+
FLUSH TABLES src FOR EXPORT;
7+
UNLOCK TABLES;
8+
DROP TABLE src;
9+
CREATE TABLE dst (pk INT PRIMARY KEY, value INT) ENGINE=INNODB;
10+
ALTER TABLE dst DISCARD TABLESPACE;
11+
ALTER TABLE dst IMPORT TABLESPACE;
12+
ERROR HY000: Index for table 'dst' is corrupt; try to repair it
13+
DROP TABLE dst;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[crc32]
2+
innodb-checksum-algorithm=crc32
3+
[none]
4+
innodb-checksum-algorithm=none
5+
[innodb]
6+
innodb-checksum-algorithm=innodb
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--innodb-encrypt-tables=1
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--source include/have_innodb.inc
2+
--source include/have_example_key_management_plugin.inc
3+
4+
call mtr.add_suppression("InnoDB: .*: Page 0 at offset 0 looks corrupted");
5+
call mtr.add_suppression("Index for table 'dst' is corrupt; try to repair it");
6+
call mtr.add_suppression("Page for tablespace .* is index page with id .* but that index is not found from configuration file");
7+
8+
let MYSQLD_DATADIR = `SELECT @@datadir`;
9+
10+
11+
CREATE TABLE src (pk INT PRIMARY KEY, value INT) ENGINE=INNODB;
12+
INSERT INTO src VALUES (1, 1), (2, 2), (3, 3);
13+
14+
FLUSH TABLES src FOR EXPORT;
15+
16+
--copy_file $MYSQLD_DATADIR/test/src.ibd $MYSQLD_DATADIR/test/tmp.ibd
17+
--copy_file $MYSQLD_DATADIR/test/src.cfg $MYSQLD_DATADIR/test/tmp.cfg
18+
19+
perl;
20+
use strict;
21+
die unless open(FILE, "+<$ENV{MYSQLD_DATADIR}/test/tmp.ibd");
22+
binmode FILE;
23+
die unless seek(FILE, 3 * 16384 + 26, 0);
24+
print FILE pack("N", 0x00000000);
25+
close(FILE);
26+
EOF
27+
28+
UNLOCK TABLES;
29+
30+
DROP TABLE src;
31+
32+
CREATE TABLE dst (pk INT PRIMARY KEY, value INT) ENGINE=INNODB;
33+
ALTER TABLE dst DISCARD TABLESPACE;
34+
35+
--copy_file $MYSQLD_DATADIR/test/tmp.ibd $MYSQLD_DATADIR/test/dst.ibd
36+
--copy_file $MYSQLD_DATADIR/test/tmp.cfg $MYSQLD_DATADIR/test/dst.cfg
37+
38+
--error ER_NOT_KEYFILE
39+
ALTER TABLE dst IMPORT TABLESPACE;
40+
41+
DROP TABLE dst;
42+
43+
--remove_file $MYSQLD_DATADIR/test/tmp.ibd
44+
--remove_file $MYSQLD_DATADIR/test/tmp.cfg

mysql-test/suite/innodb/r/instant_alter_debug.result

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,11 @@ DELETE FROM t1;
207207
connection ddl;
208208
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged';
209209
ALTER TABLE t1 FORCE;
210+
connection default;
211+
SET DEBUG_SYNC = 'now WAIT_FOR copied';
210212
connection stop_purge;
211213
COMMIT;
212214
connection default;
213-
SET DEBUG_SYNC = 'now WAIT_FOR copied';
214215
InnoDB 1 transactions not purged
215216
INSERT INTO t1 SET a=1;
216217
INSERT INTO t1 SET a=2,b=3,c=4;
@@ -230,9 +231,9 @@ DELETE FROM t1;
230231
connection ddl;
231232
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged';
232233
ALTER TABLE t1 ADD COLUMN b INT NOT NULL DEFAULT 2 AFTER a, FORCE;
233-
disconnect stop_purge;
234234
connection default;
235235
SET DEBUG_SYNC = 'now WAIT_FOR copied';
236+
disconnect stop_purge;
236237
InnoDB 1 transactions not purged
237238
INSERT INTO t1 SET a=1;
238239
INSERT INTO t1 SET a=2,c=4;

mysql-test/suite/innodb/t/instant_alter_debug.test

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ connection ddl;
237237
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged';
238238
send ALTER TABLE t1 FORCE;
239239

240+
connection default;
241+
SET DEBUG_SYNC = 'now WAIT_FOR copied';
240242
connection stop_purge;
241243
COMMIT;
242-
243244
connection default;
244-
SET DEBUG_SYNC = 'now WAIT_FOR copied';
245245
let $wait_all_purged = 1;
246246
--source include/wait_all_purged.inc
247247
let $wait_all_purged = 0;
@@ -266,10 +266,9 @@ connection ddl;
266266
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged';
267267
send ALTER TABLE t1 ADD COLUMN b INT NOT NULL DEFAULT 2 AFTER a, FORCE;
268268

269-
disconnect stop_purge;
270-
271269
connection default;
272270
SET DEBUG_SYNC = 'now WAIT_FOR copied';
271+
disconnect stop_purge;
273272
let $wait_all_purged = 1;
274273
--source include/wait_all_purged.inc
275274
let $wait_all_purged = 0;

sql/sql_cte.cc

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,15 @@ st_select_lex_unit *With_element::clone_parsed_spec(LEX *old_lex,
10481048
lex_start(thd);
10491049
lex->clone_spec_offset= unparsed_spec_offset;
10501050
lex->with_cte_resolution= true;
1051+
/*
1052+
There's no need to add SPs/SFs referenced in the clone to the global
1053+
list of the SPs/SFs used in the query as they were added when the first
1054+
reference to the cloned CTE was parsed. Yet the recursive call of the
1055+
parser must to know that they were already included into the list.
1056+
*/
1057+
lex->sroutines= old_lex->sroutines;
1058+
lex->sroutines_list_own_last= old_lex->sroutines_list_own_last;
1059+
lex->sroutines_list_own_elements= old_lex->sroutines_list_own_elements;
10511060

10521061
/*
10531062
The specification of a CTE is to be parsed as a regular query.
@@ -1092,6 +1101,29 @@ st_select_lex_unit *With_element::clone_parsed_spec(LEX *old_lex,
10921101
if (parse_status)
10931102
goto err;
10941103

1104+
/*
1105+
The unit of the specification that just has been parsed is included
1106+
as a slave of the select that contained in its from list the table
1107+
reference for which the unit has been created.
1108+
*/
1109+
lex->unit.include_down(with_table->select_lex);
1110+
lex->unit.set_slave(with_select);
1111+
lex->unit.cloned_from= spec;
1112+
1113+
/*
1114+
Now all references to the CTE defined outside of the cloned specification
1115+
has to be resolved. Additionally if old_lex->only_cte_resolution == false
1116+
for the table references that has not been resolved requests for mdl_locks
1117+
has to be set.
1118+
*/
1119+
lex->only_cte_resolution= old_lex->only_cte_resolution;
1120+
if (lex->resolve_references_to_cte(lex->query_tables,
1121+
lex->query_tables_last))
1122+
{
1123+
res= NULL;
1124+
goto err;
1125+
}
1126+
10951127
/*
10961128
The global chain of TABLE_LIST objects created for the specification that
10971129
just has been parsed is added to such chain that contains the reference
@@ -1116,32 +1148,11 @@ st_select_lex_unit *With_element::clone_parsed_spec(LEX *old_lex,
11161148
old_lex->query_tables_last= lex->query_tables_last;
11171149
}
11181150
}
1151+
old_lex->sroutines_list_own_last= lex->sroutines_list_own_last;
1152+
old_lex->sroutines_list_own_elements= lex->sroutines_list_own_elements;
11191153
res= &lex->unit;
11201154
res->with_element= this;
11211155

1122-
/*
1123-
The unit of the specification that just has been parsed is included
1124-
as a slave of the select that contained in its from list the table
1125-
reference for which the unit has been created.
1126-
*/
1127-
lex->unit.include_down(with_table->select_lex);
1128-
lex->unit.set_slave(with_select);
1129-
lex->unit.cloned_from= spec;
1130-
1131-
/*
1132-
Now all references to the CTE defined outside of the cloned specification
1133-
has to be resolved. Additionally if old_lex->only_cte_resolution == false
1134-
for the table references that has not been resolved requests for mdl_locks
1135-
has to be set.
1136-
*/
1137-
lex->only_cte_resolution= old_lex->only_cte_resolution;
1138-
if (lex->resolve_references_to_cte(lex->query_tables,
1139-
lex->query_tables_last))
1140-
{
1141-
res= NULL;
1142-
goto err;
1143-
}
1144-
11451156
last_clone_select= lex->all_selects_list;
11461157
while (last_clone_select->next_select_in_list())
11471158
last_clone_select= last_clone_select->next_select_in_list();

0 commit comments

Comments
 (0)