Skip to content

Commit b4f09aa

Browse files
committed
Merge 10.4 into 10.5
2 parents 2a78107 + 4e2ca42 commit b4f09aa

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# MDEV-25334 FTWRL/Backup blocks DDL on temporary tables with binlog
3+
# enabled assertion fails in Diagnostics_area::set_error_status
4+
#
5+
select @@binlog_format;
6+
@@binlog_format
7+
MIXED
8+
connect con1,localhost,root,,;
9+
connection default;
10+
#
11+
# Test 1
12+
#
13+
CREATE TEMPORARY TABLE tmp (a INT);
14+
connection con1;
15+
FLUSH TABLES WITH READ LOCK;
16+
connection default;
17+
SET lock_wait_timeout= 1;
18+
ALTER TABLE tmp;
19+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
20+
connection con1;
21+
unlock tables;
22+
connection default;
23+
drop table tmp;
24+
#
25+
# Test 2 (In statement format to ensure temporary table gets logged)
26+
#
27+
set @@binlog_format=statement;
28+
CREATE TEMPORARY TABLE tmp (a INT);
29+
connection con1;
30+
BACKUP STAGE START;
31+
BACKUP STAGE BLOCK_COMMIT;
32+
connection default;
33+
SET lock_wait_timeout= 1;
34+
ALTER TABLE tmp;
35+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
36+
connection con1;
37+
BACKUP STAGE end;
38+
connection default;
39+
drop table tmp;
40+
disconnect con1;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--source include/have_binlog_format_mixed_or_statement.inc
2+
3+
#
4+
# Tests involving locks and binlog
5+
#
6+
7+
--echo #
8+
--echo # MDEV-25334 FTWRL/Backup blocks DDL on temporary tables with binlog
9+
--echo # enabled assertion fails in Diagnostics_area::set_error_status
10+
--echo #
11+
12+
select @@binlog_format;
13+
--connect (con1,localhost,root,,)
14+
connection default;
15+
16+
--echo #
17+
--echo # Test 1
18+
--echo #
19+
20+
CREATE TEMPORARY TABLE tmp (a INT);
21+
--connection con1
22+
FLUSH TABLES WITH READ LOCK;
23+
--connection default
24+
SET lock_wait_timeout= 1;
25+
--error ER_LOCK_WAIT_TIMEOUT
26+
ALTER TABLE tmp;
27+
--connection con1
28+
unlock tables;
29+
--connection default
30+
drop table tmp;
31+
32+
--echo #
33+
--echo # Test 2 (In statement format to ensure temporary table gets logged)
34+
--echo #
35+
36+
set @@binlog_format=statement;
37+
CREATE TEMPORARY TABLE tmp (a INT);
38+
--connection con1
39+
BACKUP STAGE START;
40+
BACKUP STAGE BLOCK_COMMIT;
41+
--connection default
42+
SET lock_wait_timeout= 1;
43+
--error ER_LOCK_WAIT_TIMEOUT
44+
ALTER TABLE tmp;
45+
--connection con1
46+
BACKUP STAGE end;
47+
--connection default
48+
drop table tmp;
49+
--disconnect con1

sql/sql_table.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10084,7 +10084,8 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
1008410084
If such table exists, there must be a corresponding TABLE_SHARE in
1008510085
THD::all_temp_tables list.
1008610086
*/
10087-
if (thd->find_tmp_table_share(alter_ctx.new_db.str, alter_ctx.new_name.str))
10087+
if (thd->find_tmp_table_share(alter_ctx.new_db.str,
10088+
alter_ctx.new_name.str))
1008810089
{
1008910090
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alter_ctx.new_alias.str);
1009010091
DBUG_RETURN(true);
@@ -10225,6 +10226,17 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
1022510226

1022610227
if (table->s->tmp_table == NO_TMP_TABLE)
1022710228
mysql_audit_alter_table(thd, table_list);
10229+
else if (table_creation_was_logged && mysql_bin_log.is_open())
10230+
{
10231+
/* Protect against MDL error in binary logging */
10232+
MDL_request mdl_request;
10233+
DBUG_ASSERT(!mdl_ticket);
10234+
MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT,
10235+
MDL_TRANSACTION);
10236+
if (thd->mdl_context.acquire_lock(&mdl_request,
10237+
thd->variables.lock_wait_timeout))
10238+
DBUG_RETURN(true);
10239+
}
1022810240

1022910241
THD_STAGE_INFO(thd, stage_setup);
1023010242

0 commit comments

Comments
 (0)