Skip to content

Commit

Permalink
MDEV-33889 Read only server throws error when running a create tempor…
Browse files Browse the repository at this point in the history
…ary 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
  • Loading branch information
vuvova committed Apr 16, 2024
1 parent 9b18275 commit 41e7ceb
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
25 changes: 24 additions & 1 deletion mysql-test/main/read_only_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ UNLOCK TABLES;
DROP TABLE t1;
DROP USER test@localhost;
disconnect con1;
echo End of 5.1 tests
# End of 5.1 tests
#
# Bug#33669: Transactional temporary tables do not work under --read-only
#
Expand Down Expand Up @@ -244,3 +244,26 @@ connection default;
SET GLOBAL READ_ONLY = OFF;
DROP USER bug33669@localhost;
DROP DATABASE db1;
# End of 5.5 tests
#
# MDEV-33889 Read only server throws error when running a create temporary table as select statement
#
create table t1(a int) engine=innodb;
create user u1@localhost;
grant insert, select, update, delete, create temporary tables on test.* to u1@localhost;
insert into t1 values (1);
set global read_only=1;
connect u1,localhost,u1;
set default_tmp_storage_engine=innodb;
create temporary table tt1 (a int);
create temporary table tt2 like t1;
create temporary table tt3 as select * from t1;
select * from tt3;
a
1
disconnect u1;
connection default;
drop table t1;
drop user u1@localhost;
set global read_only=0;
# End of 10.5 tests
28 changes: 27 additions & 1 deletion mysql-test/main/read_only_innodb.test
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ DROP USER test@localhost;

disconnect con1;

--echo echo End of 5.1 tests
--echo # End of 5.1 tests

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

--echo # End of 5.5 tests

--echo #
--echo # MDEV-33889 Read only server throws error when running a create temporary table as select statement
--echo #
create table t1(a int) engine=innodb;
create user u1@localhost;
grant insert, select, update, delete, create temporary tables on test.* to u1@localhost;
insert into t1 values (1);
set global read_only=1;

connect u1,localhost,u1;
set default_tmp_storage_engine=innodb;

create temporary table tt1 (a int);
create temporary table tt2 like t1;
create temporary table tt3 as select * from t1;
select * from tt3;
disconnect u1;

connection default;
drop table t1;
drop user u1@localhost;
set global read_only=0;

--echo # End of 10.5 tests
2 changes: 1 addition & 1 deletion mysql-test/suite/galera/r/MDEV-27806.result
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mysqld-bin.000002 # Gtid # # BEGIN GTID #-#-#
mysqld-bin.000002 # Query # # use `test`; CREATE TABLE `ts1` (
`f1` int(11) NOT NULL
)
mysqld-bin.000002 # Xid # # COMMIT /* XID */
mysqld-bin.000002 # Query # # COMMIT
connection node_2;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
Expand Down
1 change: 1 addition & 0 deletions sql/ha_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ int ha_partition::create_partitioning_metadata(const char *path,
partition_element *part;
DBUG_ENTER("ha_partition::create_partitioning_metadata");

mark_trx_read_write();
/*
We need to update total number of parts since we might write the handler
file as part of a partition management command
Expand Down
2 changes: 0 additions & 2 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5251,8 +5251,6 @@ handler::ha_create_partitioning_metadata(const char *name,
DBUG_ASSERT(m_lock_type == F_UNLCK ||
(!old_name && strcmp(name, table_share->path.str)));


mark_trx_read_write();
return create_partitioning_metadata(name, old_name, action_flag);
}

Expand Down

0 comments on commit 41e7ceb

Please sign in to comment.