Skip to content

Commit 41e7ceb

Browse files
committed
MDEV-33889 Read only server throws error when running a create temporary table as select statement
create_partitioning_metadata() should only mark transaction r/w if it actually did anything (that is, the table is partitioned). otherwise it's a no-op, called even for temporary tables and it shouldn't do anything at all
1 parent 9b18275 commit 41e7ceb

File tree

5 files changed

+53
-5
lines changed

5 files changed

+53
-5
lines changed

mysql-test/main/read_only_innodb.result

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ UNLOCK TABLES;
7070
DROP TABLE t1;
7171
DROP USER test@localhost;
7272
disconnect con1;
73-
echo End of 5.1 tests
73+
# End of 5.1 tests
7474
#
7575
# Bug#33669: Transactional temporary tables do not work under --read-only
7676
#
@@ -244,3 +244,26 @@ connection default;
244244
SET GLOBAL READ_ONLY = OFF;
245245
DROP USER bug33669@localhost;
246246
DROP DATABASE db1;
247+
# End of 5.5 tests
248+
#
249+
# MDEV-33889 Read only server throws error when running a create temporary table as select statement
250+
#
251+
create table t1(a int) engine=innodb;
252+
create user u1@localhost;
253+
grant insert, select, update, delete, create temporary tables on test.* to u1@localhost;
254+
insert into t1 values (1);
255+
set global read_only=1;
256+
connect u1,localhost,u1;
257+
set default_tmp_storage_engine=innodb;
258+
create temporary table tt1 (a int);
259+
create temporary table tt2 like t1;
260+
create temporary table tt3 as select * from t1;
261+
select * from tt3;
262+
a
263+
1
264+
disconnect u1;
265+
connection default;
266+
drop table t1;
267+
drop user u1@localhost;
268+
set global read_only=0;
269+
# End of 10.5 tests

mysql-test/main/read_only_innodb.test

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ DROP USER test@localhost;
103103

104104
disconnect con1;
105105

106-
--echo echo End of 5.1 tests
106+
--echo # End of 5.1 tests
107107

108108
--echo #
109109
--echo # Bug#33669: Transactional temporary tables do not work under --read-only
@@ -250,3 +250,29 @@ SET GLOBAL READ_ONLY = OFF;
250250
DROP USER bug33669@localhost;
251251
DROP DATABASE db1;
252252

253+
--echo # End of 5.5 tests
254+
255+
--echo #
256+
--echo # MDEV-33889 Read only server throws error when running a create temporary table as select statement
257+
--echo #
258+
create table t1(a int) engine=innodb;
259+
create user u1@localhost;
260+
grant insert, select, update, delete, create temporary tables on test.* to u1@localhost;
261+
insert into t1 values (1);
262+
set global read_only=1;
263+
264+
connect u1,localhost,u1;
265+
set default_tmp_storage_engine=innodb;
266+
267+
create temporary table tt1 (a int);
268+
create temporary table tt2 like t1;
269+
create temporary table tt3 as select * from t1;
270+
select * from tt3;
271+
disconnect u1;
272+
273+
connection default;
274+
drop table t1;
275+
drop user u1@localhost;
276+
set global read_only=0;
277+
278+
--echo # End of 10.5 tests

mysql-test/suite/galera/r/MDEV-27806.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mysqld-bin.000002 # Gtid # # BEGIN GTID #-#-#
3737
mysqld-bin.000002 # Query # # use `test`; CREATE TABLE `ts1` (
3838
`f1` int(11) NOT NULL
3939
)
40-
mysqld-bin.000002 #Xid# # COMMIT /* XID */
40+
mysqld-bin.000002 #Query# # COMMIT
4141
connection node_2;
4242
include/show_binlog_events.inc
4343
Log_name Pos Event_type Server_id End_log_pos Info

sql/ha_partition.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ int ha_partition::create_partitioning_metadata(const char *path,
690690
partition_element *part;
691691
DBUG_ENTER("ha_partition::create_partitioning_metadata");
692692

693+
mark_trx_read_write();
693694
/*
694695
We need to update total number of parts since we might write the handler
695696
file as part of a partition management command

sql/handler.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5251,8 +5251,6 @@ handler::ha_create_partitioning_metadata(const char *name,
52515251
DBUG_ASSERT(m_lock_type == F_UNLCK ||
52525252
(!old_name && strcmp(name, table_share->path.str)));
52535253

5254-
5255-
mark_trx_read_write();
52565254
return create_partitioning_metadata(name, old_name, action_flag);
52575255
}
52585256

0 commit comments

Comments
 (0)