Skip to content

Commit 625a150

Browse files
committed
Merge 10.5 into 10.6
2 parents 10a368d + 6e9b421 commit 625a150

34 files changed

+494
-236
lines changed

extra/mariabackup/backup_copy.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,8 +1939,10 @@ copy_back()
19391939
snprintf(filename, sizeof filename, "%s/%s101", dst_dir,
19401940
LOG_FILE_NAME_PREFIX);
19411941
unlink(filename);
1942-
} else if (!(ret = copy_or_move_file(ds_tmp, LOG_FILE_NAME, LOG_FILE_NAME,
1943-
dst_dir, 1))) {
1942+
}
1943+
1944+
if (!(ret = copy_or_move_file(ds_tmp, LOG_FILE_NAME, LOG_FILE_NAME,
1945+
dst_dir, 1))) {
19441946
goto cleanup;
19451947
}
19461948
ds_destroy(ds_tmp);

extra/mariabackup/xtrabackup.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4723,7 +4723,10 @@ static bool xtrabackup_backup_func()
47234723
goto fail;
47244724
}
47254725

4726-
log_sys.create();
4726+
if (!log_sys.create()) {
4727+
msg("Error: cannot initialize log subsystem");
4728+
goto fail;
4729+
}
47274730
log_sys.log.create();
47284731
log_sys.log.open_file(get_log_file_path());
47294732

@@ -6144,8 +6147,10 @@ static bool xtrabackup_prepare_func(char** argv)
61446147
goto error_cleanup;
61456148
}
61466149

6150+
if (!log_sys.create()) {
6151+
goto error_cleanup;
6152+
}
61476153
recv_sys.create();
6148-
log_sys.create();
61496154
recv_sys.recovery_on = true;
61506155

61516156
xb_fil_io_init();

mysql-test/main/having.result

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,5 +906,54 @@ SELECT * FROM t HAVING f = 'foo';
906906
f
907907
DROP TABLE t;
908908
#
909+
# MDEV-29731 Crash when HAVING in a correlated subquery references
910+
# columns in the outer query
911+
#
912+
CREATE TABLE t (a INT, b INT);
913+
SELECT 1 FROM t
914+
WHERE b = (SELECT 1 FROM t GROUP BY a HAVING b = a+1);
915+
1
916+
DROP TABLE t;
917+
CREATE TABLE t (a INT, b INT, c INT);
918+
SELECT 1 FROM t
919+
WHERE (b,c) = (SELECT 1,1 FROM t GROUP BY a HAVING b = a+1 and c = a-1);
920+
1
921+
DROP TABLE t;
922+
CREATE TABLE t (a TEXT, b INT UNIQUE);
923+
SELECT 1 FROM t
924+
WHERE b IN (SELECT 1 FROM t
925+
GROUP BY '', a
926+
HAVING (CASE b WHEN 1 +'' THEN 3 ELSE a END)
927+
ORDER BY b)
928+
GROUP BY b HAVING b = 1;
929+
1
930+
Warnings:
931+
Warning 1292 Truncated incorrect DOUBLE value: ''
932+
DROP TABLE t;
933+
CREATE TABLE t (a INT, b CHAR KEY UNIQUE);
934+
CREATE VIEW v AS SELECT * FROM t WHERE a LIKE '' GROUP BY b HAVING a > a;
935+
SELECT * FROM v AS v1 NATURAL JOIN v AS v5 NATURAL JOIN v
936+
WHERE a LIKE '' AND b IN (SELECT a FROM t
937+
WHERE a LIKE ''
938+
GROUP BY a
939+
HAVING b LIKE (b < +1 OR a > 1) >= b);
940+
a b
941+
DROP VIEW v;
942+
DROP TABLE t;
943+
EXECUTE IMMEDIATE 'SELECT LEAD(c) OVER (ORDER BY c)
944+
FROM (SELECT 0 AS c) AS a NATURAL JOIN (SELECT 0 AS c) AS b;';
945+
LEAD(c) OVER (ORDER BY c)
946+
NULL
947+
CREATE TABLE t (a INT);
948+
UPDATE t SET a = ''
949+
WHERE 1 IN (SELECT * FROM
950+
(SELECT * FROM
951+
(SELECT * FROM t AS v5 NATURAL JOIN t AS v4 NATURAL JOIN t) AS v3
952+
NATURAL JOIN t
953+
GROUP BY a) AS v2
954+
WHERE (0, a) IN ((0,-1),(+1,0))
955+
ORDER BY 1+AVG(a) OVER (ORDER BY a)) ORDER BY a;
956+
DROP TABLE t;
957+
#
909958
# End of 10.4 tests
910959
#

mysql-test/main/having.test

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,53 @@ DROP TABLE t1,t2;
950950
CREATE TABLE t (f VARCHAR(512));
951951
INSERT INTO t VALUES ('a'),('b');
952952
SELECT * FROM t HAVING f = 'foo';
953+
DROP TABLE t;
954+
955+
--echo #
956+
--echo # MDEV-29731 Crash when HAVING in a correlated subquery references
957+
--echo # columns in the outer query
958+
--echo #
959+
CREATE TABLE t (a INT, b INT);
960+
SELECT 1 FROM t
961+
WHERE b = (SELECT 1 FROM t GROUP BY a HAVING b = a+1);
962+
DROP TABLE t;
963+
964+
CREATE TABLE t (a INT, b INT, c INT);
965+
SELECT 1 FROM t
966+
WHERE (b,c) = (SELECT 1,1 FROM t GROUP BY a HAVING b = a+1 and c = a-1);
967+
DROP TABLE t;
968+
969+
CREATE TABLE t (a TEXT, b INT UNIQUE);
970+
SELECT 1 FROM t
971+
WHERE b IN (SELECT 1 FROM t
972+
GROUP BY '', a
973+
HAVING (CASE b WHEN 1 +'' THEN 3 ELSE a END)
974+
ORDER BY b)
975+
GROUP BY b HAVING b = 1;
976+
DROP TABLE t;
977+
978+
CREATE TABLE t (a INT, b CHAR KEY UNIQUE);
979+
CREATE VIEW v AS SELECT * FROM t WHERE a LIKE '' GROUP BY b HAVING a > a;
980+
SELECT * FROM v AS v1 NATURAL JOIN v AS v5 NATURAL JOIN v
981+
WHERE a LIKE '' AND b IN (SELECT a FROM t
982+
WHERE a LIKE ''
983+
GROUP BY a
984+
HAVING b LIKE (b < +1 OR a > 1) >= b);
985+
DROP VIEW v;
986+
DROP TABLE t;
953987

954-
# Cleanup
988+
EXECUTE IMMEDIATE 'SELECT LEAD(c) OVER (ORDER BY c)
989+
FROM (SELECT 0 AS c) AS a NATURAL JOIN (SELECT 0 AS c) AS b;';
990+
991+
CREATE TABLE t (a INT);
992+
UPDATE t SET a = ''
993+
WHERE 1 IN (SELECT * FROM
994+
(SELECT * FROM
995+
(SELECT * FROM t AS v5 NATURAL JOIN t AS v4 NATURAL JOIN t) AS v3
996+
NATURAL JOIN t
997+
GROUP BY a) AS v2
998+
WHERE (0, a) IN ((0,-1),(+1,0))
999+
ORDER BY 1+AVG(a) OVER (ORDER BY a)) ORDER BY a;
9551000
DROP TABLE t;
9561001

9571002
--echo #

mysql-test/main/log_slow.result

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ start_time timestamp(6) NO current_timestamp(6) on update current_timestamp(6)
5353
user_host mediumtext NO NULL
5454
query_time time(6) NO NULL
5555
lock_time time(6) NO NULL
56-
rows_sent int(11) NO NULL
57-
rows_examined int(11) NO NULL
56+
rows_sent bigint(20) unsigned NO NULL
57+
rows_examined bigint(20) unsigned NO NULL
5858
db varchar(512) NO NULL
5959
last_insert_id int(11) NO NULL
6060
insert_id int(11) NO NULL
6161
server_id int(10) unsigned NO NULL
6262
sql_text mediumtext NO NULL
6363
thread_id bigint(21) unsigned NO NULL
64-
rows_affected int(11) NO NULL
64+
rows_affected bigint(20) unsigned NO NULL
6565
flush slow logs;
6666
set long_query_time=0.1;
6767
set log_slow_filter='';
@@ -134,3 +134,54 @@ drop table t;
134134
#
135135
# End of 10.3 tests
136136
#
137+
#
138+
# MDEV-31742: incorrect examined rows in case of stored function usage
139+
#
140+
CREATE TABLE `tab_MDEV_30820` (
141+
`ID` int(11) NOT NULL AUTO_INCREMENT,
142+
`NAME_F` varchar(50) DEFAULT NULL,
143+
PRIMARY KEY (`ID`)
144+
);
145+
CREATE TABLE `tab2` (
146+
`ID` int(11) NOT NULL AUTO_INCREMENT,
147+
`TAB1_ID` int(11) DEFAULT NULL,
148+
PRIMARY KEY (`id`)
149+
);
150+
CREATE FUNCTION `get_zero`() RETURNS int(11)
151+
BEGIN
152+
RETURN(0) ;
153+
END
154+
//
155+
for i in 1..100 do insert into tab_MDEV_30820 values (i,'qwerty'); end for ; //
156+
for i in 1..1000 do insert into tab2 values (i,i+300); end for ; //
157+
SET @old_slow_query_log= @@global.slow_query_log;
158+
SET @old_log_output= @@global.log_output;
159+
SET @old_long_query_time= @@long_query_time;
160+
SET GLOBAL log_output= "TABLE";
161+
SET GLOBAL slow_query_log= ON;
162+
SET SESSION slow_query_log=ON;
163+
SET SESSION long_query_time= 0;
164+
SELECT 0 as zero, (SELECT ID FROM tab2 where tab2.TAB1_ID =
165+
tab_MDEV_30820.ID ORDER BY 1 LIMIT 1 ) AS F1 FROM tab_MDEV_30820 ORDER BY 2 DESC LIMIT 2;
166+
zero F1
167+
0 NULL
168+
0 NULL
169+
SELECT get_zero() as zero, (SELECT ID FROM tab2 where tab2.TAB1_ID =
170+
tab_MDEV_30820.ID ORDER BY 1 LIMIT 1) AS F1 FROM tab_MDEV_30820 ORDER BY 2 DESC LIMIT 2;
171+
zero F1
172+
0 NULL
173+
0 NULL
174+
# should be the same rows_examined
175+
SELECT rows_examined FROM mysql.slow_log WHERE sql_text LIKE '%SELECT%tab_MDEV_30820%';
176+
rows_examined
177+
100202
178+
100202
179+
SET @@long_query_time= @old_long_query_time;
180+
SET @@global.log_output= @old_log_output;
181+
SET @@global.slow_query_log= @old_slow_query_log;
182+
SET SESSION slow_query_log=default;
183+
drop table tab_MDEV_30820, tab2;
184+
drop function get_zero;
185+
#
186+
# End of 10.4 tests
187+
#

mysql-test/main/log_slow.test

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,68 @@ drop table t;
121121
--echo #
122122
--echo # End of 10.3 tests
123123
--echo #
124+
125+
126+
--echo #
127+
--echo # MDEV-31742: incorrect examined rows in case of stored function usage
128+
--echo #
129+
130+
131+
CREATE TABLE `tab_MDEV_30820` (
132+
`ID` int(11) NOT NULL AUTO_INCREMENT,
133+
`NAME_F` varchar(50) DEFAULT NULL,
134+
PRIMARY KEY (`ID`)
135+
);
136+
137+
CREATE TABLE `tab2` (
138+
`ID` int(11) NOT NULL AUTO_INCREMENT,
139+
`TAB1_ID` int(11) DEFAULT NULL,
140+
PRIMARY KEY (`id`)
141+
);
142+
143+
--disable_ps2_protocol
144+
145+
--delimiter //
146+
CREATE FUNCTION `get_zero`() RETURNS int(11)
147+
BEGIN
148+
RETURN(0) ;
149+
END
150+
//
151+
152+
for i in 1..100 do insert into tab_MDEV_30820 values (i,'qwerty'); end for ; //
153+
for i in 1..1000 do insert into tab2 values (i,i+300); end for ; //
154+
155+
--delimiter ;
156+
157+
SET @old_slow_query_log= @@global.slow_query_log;
158+
SET @old_log_output= @@global.log_output;
159+
SET @old_long_query_time= @@long_query_time;
160+
SET GLOBAL log_output= "TABLE";
161+
SET GLOBAL slow_query_log= ON;
162+
163+
SET SESSION slow_query_log=ON;
164+
SET SESSION long_query_time= 0;
165+
166+
SELECT 0 as zero, (SELECT ID FROM tab2 where tab2.TAB1_ID =
167+
tab_MDEV_30820.ID ORDER BY 1 LIMIT 1 ) AS F1 FROM tab_MDEV_30820 ORDER BY 2 DESC LIMIT 2;
168+
169+
SELECT get_zero() as zero, (SELECT ID FROM tab2 where tab2.TAB1_ID =
170+
tab_MDEV_30820.ID ORDER BY 1 LIMIT 1) AS F1 FROM tab_MDEV_30820 ORDER BY 2 DESC LIMIT 2;
171+
172+
--echo # should be the same rows_examined
173+
SELECT rows_examined FROM mysql.slow_log WHERE sql_text LIKE '%SELECT%tab_MDEV_30820%';
174+
175+
## Reset to initial values
176+
SET @@long_query_time= @old_long_query_time;
177+
SET @@global.log_output= @old_log_output;
178+
SET @@global.slow_query_log= @old_slow_query_log;
179+
SET SESSION slow_query_log=default;
180+
181+
drop table tab_MDEV_30820, tab2;
182+
drop function get_zero;
183+
184+
--enable_ps2_protocol
185+
186+
--echo #
187+
--echo # End of 10.4 tests
188+
--echo #

mysql-test/main/log_slow_debug.result

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,32 @@ SET @@global.slow_query_log= @org_slow_query_log;
280280
SET @@global.log_output= @org_log_output;
281281
SET @@global.log_slow_admin_statements= @org_log_slow_admin_statements;
282282
DROP PROCEDURE show_slow_log;
283+
#
284+
# MDEV-30820: slow log Rows_examined out of range
285+
#
286+
CREATE TABLE `tab_MDEV_30820` (
287+
`ID` int(11) NOT NULL AUTO_INCREMENT,
288+
`A` int(11),
289+
PRIMARY KEY(ID)
290+
);
291+
insert into tab_MDEV_30820 values (null, 0),(null, 0);
292+
SET @old_slow_query_log= @@global.slow_query_log;
293+
SET @old_log_output= @@global.log_output;
294+
SET @old_long_query_time= @@long_query_time;
295+
SET @old_dbug= @@GLOBAL.debug_dbug;
296+
SET GLOBAL log_output= "TABLE";
297+
SET GLOBAL slow_query_log= ON;
298+
SET SESSION long_query_time= 0;
299+
SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows";
300+
SELECT * FROM tab_MDEV_30820 ORDER BY 1;
301+
ID A
302+
1 0
303+
2 0
304+
SET GLOBAL debug_dbug=@old_dbug;
305+
SET @@long_query_time= @old_long_query_time;
306+
SET @@global.log_output= @old_log_output;
307+
SET @@global.slow_query_log= @old_slow_query_log;
308+
drop table tab_MDEV_30820;
309+
#
310+
# End of 10.4 test
311+
#

mysql-test/main/log_slow_debug.test

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,41 @@ SET @@global.slow_query_log= @org_slow_query_log;
159159
SET @@global.log_output= @org_log_output;
160160
SET @@global.log_slow_admin_statements= @org_log_slow_admin_statements;
161161
DROP PROCEDURE show_slow_log;
162+
163+
164+
--echo #
165+
--echo # MDEV-30820: slow log Rows_examined out of range
166+
--echo #
167+
168+
CREATE TABLE `tab_MDEV_30820` (
169+
`ID` int(11) NOT NULL AUTO_INCREMENT,
170+
`A` int(11),
171+
PRIMARY KEY(ID)
172+
);
173+
174+
insert into tab_MDEV_30820 values (null, 0),(null, 0);
175+
176+
SET @old_slow_query_log= @@global.slow_query_log;
177+
SET @old_log_output= @@global.log_output;
178+
SET @old_long_query_time= @@long_query_time;
179+
SET @old_dbug= @@GLOBAL.debug_dbug;
180+
SET GLOBAL log_output= "TABLE";
181+
182+
SET GLOBAL slow_query_log= ON;
183+
SET SESSION long_query_time= 0;
184+
185+
SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows";
186+
SELECT * FROM tab_MDEV_30820 ORDER BY 1;
187+
SET GLOBAL debug_dbug=@old_dbug;
188+
189+
190+
## Reset to initial values
191+
SET @@long_query_time= @old_long_query_time;
192+
SET @@global.log_output= @old_log_output;
193+
SET @@global.slow_query_log= @old_slow_query_log;
194+
195+
drop table tab_MDEV_30820;
196+
197+
--echo #
198+
--echo # End of 10.4 test
199+
--echo #

0 commit comments

Comments
 (0)