Commit 41e7ceb0 authored by Sergei Golubchik's avatar Sergei Golubchik

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
parent 9b182756
...@@ -70,7 +70,7 @@ UNLOCK TABLES; ...@@ -70,7 +70,7 @@ UNLOCK TABLES;
DROP TABLE t1; DROP TABLE t1;
DROP USER test@localhost; DROP USER test@localhost;
disconnect con1; disconnect con1;
echo End of 5.1 tests # End of 5.1 tests
# #
# Bug#33669: Transactional temporary tables do not work under --read-only # Bug#33669: Transactional temporary tables do not work under --read-only
# #
...@@ -244,3 +244,26 @@ connection default; ...@@ -244,3 +244,26 @@ connection default;
SET GLOBAL READ_ONLY = OFF; SET GLOBAL READ_ONLY = OFF;
DROP USER bug33669@localhost; DROP USER bug33669@localhost;
DROP DATABASE db1; 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
...@@ -103,7 +103,7 @@ DROP USER test@localhost; ...@@ -103,7 +103,7 @@ DROP USER test@localhost;
disconnect con1; disconnect con1;
--echo echo End of 5.1 tests --echo # End of 5.1 tests
--echo # --echo #
--echo # Bug#33669: Transactional temporary tables do not work under --read-only --echo # Bug#33669: Transactional temporary tables do not work under --read-only
...@@ -250,3 +250,29 @@ SET GLOBAL READ_ONLY = OFF; ...@@ -250,3 +250,29 @@ SET GLOBAL READ_ONLY = OFF;
DROP USER bug33669@localhost; DROP USER bug33669@localhost;
DROP DATABASE db1; 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
...@@ -37,7 +37,7 @@ mysqld-bin.000002 # Gtid # # BEGIN GTID #-#-# ...@@ -37,7 +37,7 @@ mysqld-bin.000002 # Gtid # # BEGIN GTID #-#-#
mysqld-bin.000002 # Query # # use `test`; CREATE TABLE `ts1` ( mysqld-bin.000002 # Query # # use `test`; CREATE TABLE `ts1` (
`f1` int(11) NOT NULL `f1` int(11) NOT NULL
) )
mysqld-bin.000002 # Xid # # COMMIT /* XID */ mysqld-bin.000002 # Query # # COMMIT
connection node_2; connection node_2;
include/show_binlog_events.inc include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
......
...@@ -690,6 +690,7 @@ int ha_partition::create_partitioning_metadata(const char *path, ...@@ -690,6 +690,7 @@ int ha_partition::create_partitioning_metadata(const char *path,
partition_element *part; partition_element *part;
DBUG_ENTER("ha_partition::create_partitioning_metadata"); 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 We need to update total number of parts since we might write the handler
file as part of a partition management command file as part of a partition management command
......
...@@ -5251,8 +5251,6 @@ handler::ha_create_partitioning_metadata(const char *name, ...@@ -5251,8 +5251,6 @@ handler::ha_create_partitioning_metadata(const char *name,
DBUG_ASSERT(m_lock_type == F_UNLCK || DBUG_ASSERT(m_lock_type == F_UNLCK ||
(!old_name && strcmp(name, table_share->path.str))); (!old_name && strcmp(name, table_share->path.str)));
mark_trx_read_write();
return create_partitioning_metadata(name, old_name, action_flag); return create_partitioning_metadata(name, old_name, action_flag);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment