Bug#21215 mysqldump creating incomplete backups without warning

 - Add call to 'safe_exit' function when db query fails.
parent 9f78d779
......@@ -872,6 +872,7 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res,
{
my_printf_error(0, "Couldn't execute '%s': %s (%d)", MYF(0),
query, mysql_error(mysql_con), mysql_errno(mysql_con));
safe_exit(EX_MYSQLERR);
return 1;
}
return 0;
......
......@@ -2867,3 +2867,19 @@ drop view nasishnasifu;
drop database mysqldump_views;
drop table mysqldump_tables.basetable;
drop database mysqldump_tables;
use test;
create user mysqltest_1;
create table t1(a int, b varchar(34));
mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need the RELOAD privilege for this operation (1227)
mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need the RELOAD privilege for this operation (1227)
grant RELOAD on *.* to mysqltest_1@localhost;
mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227)
mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227)
grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000003', MASTER_LOG_POS=3784;
CREATE TABLE `t1` (
`a` int(11) default NULL,
`b` varchar(34) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
drop table t1;
drop user mysqltest_1;
......@@ -1228,3 +1228,43 @@ drop view nasishnasifu;
drop database mysqldump_views;
drop table mysqldump_tables.basetable;
drop database mysqldump_tables;
#
# Bug#21215 mysqldump creating incomplete backups without warning
#
use test;
# Create user without sufficient privs to perform the requested operation
create user mysqltest_1;
create table t1(a int, b varchar(34));
# Execute mysqldump, will fail on FLUSH TABLES
--error 2
--exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1
# Execute mysqldump, will fail on FLUSH TABLES
# use --force, should no affect behaviour
--error 2
--exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1
# Add RELOAD grants
grant RELOAD on *.* to mysqltest_1@localhost;
# Execute mysqldump, will fail on SHOW MASTER STATUS
--error 2
--exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1
# Execute mysqldump, will fail on SHOW MASTER STATUS.
# use --force, should not alter behaviour
--error 2
--exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1
# Add REPLICATION CLIENT grants
grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
# Execute mysqldump, should now succeed
--exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1
# Clean up
drop table t1;
drop user mysqltest_1;
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