From 1ddb4722f4194691564396da05b09fe783d5b5de Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Nov 2007 19:09:40 +0100 Subject: Bug#16470 crash on grant if old grant tables Loading 4.1 into 5.0 or 5.1 failed silently because procs_priv table missing. This caused the server to crash on any attempt to store new grants because of uninitialized structures. This patch breaks up the grant loading function into two phases to allow for procs_priv table to fail with an warning instead of crashing the server. mysql-test/r/grant.result: Test case mysql-test/t/grant.test: Test case making sure that FLUSH PRIVILEGES doesn't crash the server if procs_priv is removed. sql/sql_acl.cc: - Refactored grant_reload into two phases: 1. open and lock tables_priv and columns_priv tables, read the data, close tables. 2. open and lock procs_priv, read data, close table. Since the tables are independant of each other there will be no race conditions and it will be possible to handle situations where the procs_priv table isn't present. - Refactored the helper function grant_load into new grant_load (without procs_priv table) and grant_load_procs_priv. sql/sql_parse.cc: - Changed comment style to doxygen style. --- mysql-test/t/grant.test | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mysql-test/t/grant.test') diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index e33712e1ebf..8e060ef5ca9 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1274,3 +1274,23 @@ drop user юзер_юзер@localhost; --error ER_WRONG_STRING_LENGTH grant select on test.* to очень_длинный_юзер@localhost; set names default; + + +# +# Bug #16470 crash on grant if old grant tables +# +--echo FLUSH PRIVILEGES without procs_priv table. +RENAME TABLE mysql.procs_priv TO mysql.procs_gone; +FLUSH PRIVILEGES; +--echo Assigning privileges without procs_priv table. +CREATE DATABASE mysqltest1; +CREATE PROCEDURE mysqltest1.test() SQL SECURITY DEFINER + SELECT 1; +--error ER_NO_SUCH_TABLE +GRANT EXECUTE ON FUNCTION mysqltest1.test TO mysqltest_1@localhost; +GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost; +CALL mysqltest1.test(); +DROP DATABASE mysqltest1; +RENAME TABLE mysql.procs_gone TO mysql.procs_priv; +FLUSH PRIVILEGES; + -- cgit v1.2.1