From: kpetterssonDate: February 1 2008 2:10pm Subject: bk commit into 5.0 tree (thek:1.2594) BUG#33201 Below is the list of changes that have just been committed into a local 5.0 repository of thek. When thek does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2008-02-01 14:10:46+01:00, thek@adventure.(none) +3 -0 Bug#33201 Crash occurs when granting update privilege on one column of a view When issuing a column level grant on a table which require pre-locking the server crashed. The reason behind the crash was that data structures used by the lock api wasn't properly reinitialized in the case of a column level grant. mysql-test/r/grant.result@stripped, 2008-02-01 14:10:44+01:00, thek@adventure.(none) +22 -0 * Added test case mysql-test/t/grant.test@stripped, 2008-02-01 14:10:44+01:00, thek@adventure.(none) +22 -0 * Added test case sql/sql_acl.cc@stripped, 2008-02-01 14:10:44+01:00, thek@adventure.(none) +7 -0 * The lock api is dending on the thd->lex object and this variable needs to be re-initialized when opened with a new set of tables than specified in the original statement. #diff -Nrup a/mysql-test/r/grant.result b/mysql-test/r/grant.result #--- a/mysql-test/r/grant.result 2007-12-07 11:39:36 +01:00 #+++ b/mysql-test/r/grant.result 2008-02-01 14:10:44 +01:00 #@@ -1129,4 +1129,26 @@ DROP USER mysqltest_1@localhost; # DROP DATABASE db27878; # use test; # DROP TABLE t1; #+drop table if exists test; #+Warnings: #+Note 1051 Unknown table 'test' #+drop function if exists test_function; #+Warnings: #+Note 1305 FUNCTION test_function does not exist #+drop view if exists v1; #+Warnings: #+Note 1051 Unknown table 'test.v1' #+create table test (col1 varchar(30)); #+create function test_function() returns varchar(30) #+begin #+declare tmp varchar(30); #+select col1 from test limit 1 into tmp; #+return '1'; #+end| #+create view v1 as select test.* from test where test.col1=test_function(); #+grant update (col1) on v1 to 'greg'; #+revoke all privileges on v1 from 'greg'; #+drop view v1; #+drop table test; #+drop function test_function; # End of 5.0 tests #diff -Nrup a/mysql-test/t/grant.test b/mysql-test/t/grant.test #--- a/mysql-test/t/grant.test 2007-12-07 11:39:36 +01:00 #+++ b/mysql-test/t/grant.test 2008-02-01 14:10:44 +01:00 #@@ -1153,4 +1153,26 @@ DROP DATABASE db27878; # use test; # DROP TABLE t1; # #+# #+# Bug #33201 Crash occurs when granting update privilege on one column of a view #+# #+drop table if exists test; #+drop function if exists test_function; #+drop view if exists v1; #+create table test (col1 varchar(30)); #+delimiter |; #+create function test_function() returns varchar(30) #+begin #+ declare tmp varchar(30); #+ select col1 from test limit 1 into tmp; #+ return '1'; #+end| #+delimiter ;| #+create view v1 as select test.* from test where test.col1=test_function(); #+grant update (col1) on v1 to 'greg'; #+revoke all privileges on v1 from 'greg'; #+drop view v1; #+drop table test; #+drop function test_function; #+ # --echo End of 5.0 tests diff -Nrup a/sql/sql_acl.cc b/sql/sql_acl.cc --- a/sql/sql_acl.cc 2007-12-05 04:07:01 +01:00 +++ b/sql/sql_acl.cc 2008-02-01 14:10:44 +01:00 @@ -2878,6 +2878,12 @@ bool mysql_table_grant(THD *thd, TABLE_L } #endif + /* + The lock api is depending on the thd->lex variable which needs to be + re-initialized. + */ + Query_tables_list backup; + thd->lex->reset_n_backup_query_tables_list(&backup); if (simple_open_n_lock_tables(thd,tables)) { // Should never happen close_thread_tables(thd); /* purecov: deadcode */ @@ -3016,6 +3022,7 @@ bool mysql_table_grant(THD *thd, TABLE_L send_ok(thd); /* Tables are automatically closed */ + thd->lex->restore_backup_query_tables_list(&backup); DBUG_RETURN(result); }