Loading client/client_priv.h +1 −1 Original line number Diff line number Diff line Loading @@ -51,5 +51,5 @@ enum options_client OPT_TRIGGERS, OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_SSL_VERIFY_SERVER_CERT, OPT_DEBUG_INFO OPT_DEBUG_INFO, OPT_ERROR_LOG_FILE }; client/mysqlbinlog.cc +11 −4 Original line number Diff line number Diff line Loading @@ -1042,7 +1042,7 @@ static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, uint logname_len; NET* net; int error= 0; my_off_t old_off= start_position_mot; my_off_t old_off= min(start_position_mot, BIN_LOG_HEADER_SIZE); char fname[FN_REFLEN+1]; DBUG_ENTER("dump_remote_log_entries"); Loading Loading @@ -1195,8 +1195,15 @@ could be out of memory"); } /* Let's adjust offset for remote log as for local log to produce similar text. similar text and to have --stop-position to work identically. Exception - the server sends Format_description_log_event in the beginning of the dump, and only after it the event from start_position. Let the old_off reflect it. */ if (old_off < start_position_mot) old_off= start_position_mot; else old_off+= len-1; } Loading client/mysqldump.c +22 −2 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ static char *opt_password=0,*current_user=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0, *where=0, *order_by=0, *opt_compatible_mode_str= 0, *err_ptr= 0; *err_ptr= 0, *log_error_file= NULL; static char **defaults_argv= 0; static char compatible_mode_normal_str[255]; static ulong opt_compatible_mode= 0; Loading @@ -117,6 +118,8 @@ static int first_error=0; static DYNAMIC_STRING extended_row; #include <sslopt-vars.h> FILE *md_result_file= 0; FILE *stderror_file=0; #ifdef HAVE_SMEM static char *shared_memory_base_name=0; #endif Loading Loading @@ -293,6 +296,9 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0, 0}, {"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables, (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.", (gptr*) &log_error_file, (gptr*) &log_error_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-data", OPT_MASTER_DATA, "This causes the binary log position and filename to be appended to the " "output. If equal to 1, will print it as a CHANGE MASTER command; if equal" Loading Loading @@ -3694,6 +3700,16 @@ int main(int argc, char **argv) free_resources(0); exit(exit_code); } if (log_error_file) { if(!(stderror_file= freopen(log_error_file, "a+", stderr))) { free_resources(0); exit(EX_MYSQLERR); } } if (connect_to_db(current_host, current_user, opt_password)) { free_resources(0); Loading Loading @@ -3746,5 +3762,9 @@ int main(int argc, char **argv) if (!path) write_footer(md_result_file); free_resources(); if (stderror_file) fclose(stderror_file); return(first_error); } /* main */ mysql-test/r/grant.result +47 −0 Original line number Diff line number Diff line Loading @@ -972,4 +972,51 @@ REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij123456789 ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) GRANT PROCESS ON * TO user@localhost; ERROR 3D000: No database selected DROP DATABASE IF EXISTS mysqltest1; DROP DATABASE IF EXISTS mysqltest2; DROP DATABASE IF EXISTS mysqltest3; DROP DATABASE IF EXISTS mysqltest4; CREATE DATABASE mysqltest1; CREATE DATABASE mysqltest2; CREATE DATABASE mysqltest3; CREATE DATABASE mysqltest4; CREATE PROCEDURE mysqltest1.p_def() SQL SECURITY DEFINER SELECT 1; CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER SELECT 1; CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER RETURN 1; CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER RETURN 1; GRANT EXECUTE ON PROCEDURE mysqltest1.p_def TO mysqltest_1@localhost; GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost; GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost; GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost; GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost; ---> connection: bug9504_con1 use mysqltest1; use mysqltest2; use mysqltest3; use mysqltest4; use test; CALL mysqltest1.p_def(); 1 1 CALL mysqltest2.p_inv(); 1 1 SELECT mysqltest3.f_def(); mysqltest3.f_def() 1 SELECT mysqltest4.f_inv(); mysqltest4.f_inv() 1 ---> connection: default DROP DATABASE mysqltest1; DROP DATABASE mysqltest2; DROP DATABASE mysqltest3; DROP DATABASE mysqltest4; DROP USER mysqltest_1@localhost; End of 5.0 tests mysql-test/r/information_schema_db.result +69 −2 Original line number Diff line number Diff line Loading @@ -106,16 +106,82 @@ use testdb_1; create table t1 (f1 char(4)); create view v1 as select f1 from t1; grant insert on v1 to testdb_2@localhost; create view v5 as select f1 from t1; grant show view on v5 to testdb_2@localhost; create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1; ERROR 42000: Access denied; you need the SUPER privilege for this operation use testdb_1; create view v6 as select f1 from t1; grant show view on v6 to testdb_2@localhost; create table t2 (f1 char(4)); create definer=`no_such_user`@`no_such_host` view v7 as select * from t2; Warnings: Note 1449 There is no 'no_such_user'@'no_such_host' registered show fields from testdb_1.v6; Field Type Null Key Default Extra f1 char(4) YES NULL show create view testdb_1.v6; View Create View v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t1`.`f1` AS `f1` from `t1` show create view testdb_1.v7; View Create View v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2` Warnings: Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them show fields from testdb_1.v7; Field Type Null Key Default Extra f1 null YES NULL Warnings: Note 1449 There is no 'no_such_user'@'no_such_host' registered create table t3 (f1 char(4), f2 char(4)); create view v3 as select f1,f2 from t3; grant insert(f1), insert(f2) on v3 to testdb_2@localhost; create view v2 as select f1 from testdb_1.v1; create view v4 as select f1,f2 from testdb_1.v3; show fields from testdb_1.v5; Field Type Null Key Default Extra f1 char(4) YES NULL show create view testdb_1.v5; View Create View v5 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_1`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v5` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1` show fields from testdb_1.v6; Field Type Null Key Default Extra f1 char(4) YES NULL show create view testdb_1.v6; View Create View v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1` show fields from testdb_1.v7; Field Type Null Key Default Extra f1 null YES NULL Warnings: Note 1449 There is no 'no_such_user'@'no_such_host' registered show create view testdb_1.v7; View Create View v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2` Warnings: Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them revoke insert(f1) on v3 from testdb_2@localhost; revoke show view on v5 from testdb_2@localhost; use testdb_1; revoke show view on v6 from testdb_2@localhost; show fields from testdb_1.v5; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5' show create view testdb_1.v5; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5' show fields from testdb_1.v6; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6' show create view testdb_1.v6; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6' show fields from testdb_1.v7; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7' show create view testdb_1.v7; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7' show create view v4; ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table show fields from v4; ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table Field Type Null Key Default Extra f1 null YES NULL f2 char(4) YES NULL show fields from v2; Field Type Null Key Default Extra f1 char(4) YES NULL Loading @@ -140,6 +206,7 @@ where a.table_name = 'testdb_1.v1'; view_definition select * from v2; ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them use test; drop view testdb_1.v1, v2, testdb_1.v3, v4; drop database testdb_1; drop user testdb_1@localhost; Loading Loading
client/client_priv.h +1 −1 Original line number Diff line number Diff line Loading @@ -51,5 +51,5 @@ enum options_client OPT_TRIGGERS, OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_SSL_VERIFY_SERVER_CERT, OPT_DEBUG_INFO OPT_DEBUG_INFO, OPT_ERROR_LOG_FILE };
client/mysqlbinlog.cc +11 −4 Original line number Diff line number Diff line Loading @@ -1042,7 +1042,7 @@ static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, uint logname_len; NET* net; int error= 0; my_off_t old_off= start_position_mot; my_off_t old_off= min(start_position_mot, BIN_LOG_HEADER_SIZE); char fname[FN_REFLEN+1]; DBUG_ENTER("dump_remote_log_entries"); Loading Loading @@ -1195,8 +1195,15 @@ could be out of memory"); } /* Let's adjust offset for remote log as for local log to produce similar text. similar text and to have --stop-position to work identically. Exception - the server sends Format_description_log_event in the beginning of the dump, and only after it the event from start_position. Let the old_off reflect it. */ if (old_off < start_position_mot) old_off= start_position_mot; else old_off+= len-1; } Loading
client/mysqldump.c +22 −2 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ static char *opt_password=0,*current_user=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0, *where=0, *order_by=0, *opt_compatible_mode_str= 0, *err_ptr= 0; *err_ptr= 0, *log_error_file= NULL; static char **defaults_argv= 0; static char compatible_mode_normal_str[255]; static ulong opt_compatible_mode= 0; Loading @@ -117,6 +118,8 @@ static int first_error=0; static DYNAMIC_STRING extended_row; #include <sslopt-vars.h> FILE *md_result_file= 0; FILE *stderror_file=0; #ifdef HAVE_SMEM static char *shared_memory_base_name=0; #endif Loading Loading @@ -293,6 +296,9 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0, 0}, {"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables, (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.", (gptr*) &log_error_file, (gptr*) &log_error_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-data", OPT_MASTER_DATA, "This causes the binary log position and filename to be appended to the " "output. If equal to 1, will print it as a CHANGE MASTER command; if equal" Loading Loading @@ -3694,6 +3700,16 @@ int main(int argc, char **argv) free_resources(0); exit(exit_code); } if (log_error_file) { if(!(stderror_file= freopen(log_error_file, "a+", stderr))) { free_resources(0); exit(EX_MYSQLERR); } } if (connect_to_db(current_host, current_user, opt_password)) { free_resources(0); Loading Loading @@ -3746,5 +3762,9 @@ int main(int argc, char **argv) if (!path) write_footer(md_result_file); free_resources(); if (stderror_file) fclose(stderror_file); return(first_error); } /* main */
mysql-test/r/grant.result +47 −0 Original line number Diff line number Diff line Loading @@ -972,4 +972,51 @@ REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij123456789 ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) GRANT PROCESS ON * TO user@localhost; ERROR 3D000: No database selected DROP DATABASE IF EXISTS mysqltest1; DROP DATABASE IF EXISTS mysqltest2; DROP DATABASE IF EXISTS mysqltest3; DROP DATABASE IF EXISTS mysqltest4; CREATE DATABASE mysqltest1; CREATE DATABASE mysqltest2; CREATE DATABASE mysqltest3; CREATE DATABASE mysqltest4; CREATE PROCEDURE mysqltest1.p_def() SQL SECURITY DEFINER SELECT 1; CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER SELECT 1; CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER RETURN 1; CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER RETURN 1; GRANT EXECUTE ON PROCEDURE mysqltest1.p_def TO mysqltest_1@localhost; GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost; GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost; GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost; GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost; ---> connection: bug9504_con1 use mysqltest1; use mysqltest2; use mysqltest3; use mysqltest4; use test; CALL mysqltest1.p_def(); 1 1 CALL mysqltest2.p_inv(); 1 1 SELECT mysqltest3.f_def(); mysqltest3.f_def() 1 SELECT mysqltest4.f_inv(); mysqltest4.f_inv() 1 ---> connection: default DROP DATABASE mysqltest1; DROP DATABASE mysqltest2; DROP DATABASE mysqltest3; DROP DATABASE mysqltest4; DROP USER mysqltest_1@localhost; End of 5.0 tests
mysql-test/r/information_schema_db.result +69 −2 Original line number Diff line number Diff line Loading @@ -106,16 +106,82 @@ use testdb_1; create table t1 (f1 char(4)); create view v1 as select f1 from t1; grant insert on v1 to testdb_2@localhost; create view v5 as select f1 from t1; grant show view on v5 to testdb_2@localhost; create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1; ERROR 42000: Access denied; you need the SUPER privilege for this operation use testdb_1; create view v6 as select f1 from t1; grant show view on v6 to testdb_2@localhost; create table t2 (f1 char(4)); create definer=`no_such_user`@`no_such_host` view v7 as select * from t2; Warnings: Note 1449 There is no 'no_such_user'@'no_such_host' registered show fields from testdb_1.v6; Field Type Null Key Default Extra f1 char(4) YES NULL show create view testdb_1.v6; View Create View v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t1`.`f1` AS `f1` from `t1` show create view testdb_1.v7; View Create View v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2` Warnings: Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them show fields from testdb_1.v7; Field Type Null Key Default Extra f1 null YES NULL Warnings: Note 1449 There is no 'no_such_user'@'no_such_host' registered create table t3 (f1 char(4), f2 char(4)); create view v3 as select f1,f2 from t3; grant insert(f1), insert(f2) on v3 to testdb_2@localhost; create view v2 as select f1 from testdb_1.v1; create view v4 as select f1,f2 from testdb_1.v3; show fields from testdb_1.v5; Field Type Null Key Default Extra f1 char(4) YES NULL show create view testdb_1.v5; View Create View v5 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_1`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v5` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1` show fields from testdb_1.v6; Field Type Null Key Default Extra f1 char(4) YES NULL show create view testdb_1.v6; View Create View v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1` show fields from testdb_1.v7; Field Type Null Key Default Extra f1 null YES NULL Warnings: Note 1449 There is no 'no_such_user'@'no_such_host' registered show create view testdb_1.v7; View Create View v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2` Warnings: Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them revoke insert(f1) on v3 from testdb_2@localhost; revoke show view on v5 from testdb_2@localhost; use testdb_1; revoke show view on v6 from testdb_2@localhost; show fields from testdb_1.v5; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5' show create view testdb_1.v5; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5' show fields from testdb_1.v6; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6' show create view testdb_1.v6; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6' show fields from testdb_1.v7; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7' show create view testdb_1.v7; ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7' show create view v4; ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table show fields from v4; ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table Field Type Null Key Default Extra f1 null YES NULL f2 char(4) YES NULL show fields from v2; Field Type Null Key Default Extra f1 char(4) YES NULL Loading @@ -140,6 +206,7 @@ where a.table_name = 'testdb_1.v1'; view_definition select * from v2; ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them use test; drop view testdb_1.v1, v2, testdb_1.v3, v4; drop database testdb_1; drop user testdb_1@localhost; Loading