From eb5cdca66fac397d7224f78b1304892914150aa0 Mon Sep 17 00:00:00 2001 From: "thek@adventure.(none)" <> Date: Tue, 25 Mar 2008 12:52:55 +0100 Subject: [PATCH 1/2] Bug#33275 Server crash when creating temporary table mysql.user When creating a temporary table that uses the same name as the mysql privs table the server would crash on FLUSH PRIVILEGES. This patches corrects the problem by setting a flag to ignore any temporary table when trying to reload the privileges. --- mysql-test/r/grant.result | 6 ++++++ mysql-test/t/grant.test | 7 +++++++ sql/sql_acl.cc | 5 ++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index e27ef64af43..8a89a9dc264 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1129,4 +1129,10 @@ DROP USER mysqltest_1@localhost; DROP DATABASE db27878; use test; DROP TABLE t1; +# +# Bug#33275 Server crash when creating temporary table mysql.user +# +CREATE TEMPORARY TABLE mysql.user (id INT); +FLUSH PRIVILEGES; +DROP TABLE mysql.user; End of 5.0 tests diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index ed95d90c8f8..93c416133e8 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1153,4 +1153,11 @@ DROP DATABASE db27878; use test; DROP TABLE t1; +--echo # +--echo # Bug#33275 Server crash when creating temporary table mysql.user +--echo # +CREATE TEMPORARY TABLE mysql.user (id INT); +FLUSH PRIVILEGES; +DROP TABLE mysql.user; + --echo End of 5.0 tests diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 8fdd054eb39..64b1e699289 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -558,6 +558,8 @@ my_bool acl_reload(THD *thd) tables[0].next_local= tables[0].next_global= tables+1; tables[1].next_local= tables[1].next_global= tables+2; tables[0].lock_type=tables[1].lock_type=tables[2].lock_type=TL_READ; + tables[0].skip_temporary= tables[1].skip_temporary= + tables[2].skip_temporary= TRUE; if (simple_open_n_lock_tables(thd, tables)) { @@ -3528,7 +3530,8 @@ my_bool grant_reload(THD *thd) tables[0].next_local= tables[0].next_global= tables+1; tables[1].next_local= tables[1].next_global= tables+2; tables[0].lock_type= tables[1].lock_type= tables[2].lock_type= TL_READ; - + tables[0].skip_temporary= tables[1].skip_temporary= + tables[2].skip_temporary= TRUE; /* To avoid deadlocks we should obtain table locks before obtaining LOCK_grant rwlock. From c3d51823103e0a9ef1dfcbeb815e5b8073f2558d Mon Sep 17 00:00:00 2001 From: "thek@adventure.(none)" <> Date: Wed, 26 Mar 2008 14:03:01 +0100 Subject: [PATCH 2/2] Corrected result-file merge error. --- mysql-test/r/grant.result | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index c157e1d4706..b91f2016a9e 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1218,6 +1218,12 @@ DROP USER mysqltest_1@localhost; DROP DATABASE db27878; use test; DROP TABLE t1; +# +# Bug#33275 Server crash when creating temporary table mysql.user +# +CREATE TEMPORARY TABLE mysql.user (id INT); +FLUSH PRIVILEGES; +DROP TABLE mysql.user; drop table if exists test; Warnings: Note 1051 Unknown table 'test'