#At file:///C:/source/bzr/mysql-6.0-wl-4927/ based on revid:charles.bell@stripped
2810 Chuck Bell 2009-05-12
WL#4927 : Disable MySQL Backup in 6.0 Trees
The MySQL Backup system must be disabled by default in the 6.0
trees prior to the 5.4 cloneoff. Users must be able to use
the backup and restore operations if they start the server
with the --new startup option.
This patch changes the commands to require the server option
--new. Thus, users can still use backup iff they start their
server with --new.
added:
mysql-test/r/backup_disabled.result
mysql-test/suite/backup/combinations
mysql-test/suite/backup_extra/combinations
mysql-test/t/backup_disabled.test
modified:
mysql-test/suite/backup_engines/combinations
mysql-test/suite/backup_ptr/combinations
sql/share/errmsg.txt
sql/sql_parse.cc
per-file messages:
mysql-test/r/backup_disabled.result
New result file.
mysql-test/suite/backup/combinations
New combinations file that permits the backup test suite to
run in pushbuild.
mysql-test/suite/backup_engines/combinations
Added --new option to server startup options.
Removed '--' so that combinations file matches format
used in other backup suite combination files.
mysql-test/suite/backup_extra/combinations
New combinations file that permits the backup test suite to
run in pushbuild.
mysql-test/suite/backup_ptr/combinations
Added --new option to server startup options.
mysql-test/t/backup_disabled.test
New test to ensure backup is disabled by default.
sql/share/errmsg.txt
New error message for disabled backup system.
sql/sql_parse.cc
Added gate to test to see if --new option was set at server
startup. If not, commands result in an error.
=== added file 'mysql-test/r/backup_disabled.result'
--- a/mysql-test/r/backup_disabled.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/backup_disabled.result 2009-05-12 19:53:21 +0000
@@ -0,0 +1,24 @@
+#
+# Create some database
+#
+DROP DATABASE IF EXISTS db1;
+CREATE DATABASE db1;
+#
+# Attempt to run a backup.
+#
+BACKUP DATABASE db1 to 'bup_db1.bak';
+ERROR HY000: The MySQL Backup system is disabled in this release. Use --new on server startup to enable.
+#
+# Attempt to run a backup test command.
+#
+BACKUP_TEST aflac;
+ERROR HY000: The MySQL Backup system is disabled in this release. Use --new on server startup to enable.
+#
+# Attempt to run a restore
+#
+RESTORE FROM 'bup_db1.bak';
+ERROR HY000: The MySQL Backup system is disabled in this release. Use --new on server startup to enable.
+#
+# Cleanup
+#
+DROP DATABASE db1;
=== added file 'mysql-test/suite/backup/combinations'
--- a/mysql-test/suite/backup/combinations 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/combinations 2009-05-12 19:53:21 +0000
@@ -0,0 +1,2 @@
+[ENABLED]
+--new
=== modified file 'mysql-test/suite/backup_engines/combinations'
--- a/mysql-test/suite/backup_engines/combinations 2009-03-05 20:05:02 +0000
+++ b/mysql-test/suite/backup_engines/combinations 2009-05-12 19:53:21 +0000
@@ -1,21 +1,28 @@
[myisam]
---default-storage-engine=myisam
+default-storage-engine=myisam
+new
[falcon]
---default-storage-engine=falcon
+default-storage-engine=falcon
+new
[memory]
---default-storage-engine=memory
+default-storage-engine=memory
+new
[innodb]
---innodb=1
---default-storage-engine=innodb
+innodb=1
+default-storage-engine=innodb
+new
[csv]
---default-storage-engine=csv
+default-storage-engine=csv
+new
[blackhole]
---default-storage-engine=blackhole
+default-storage-engine=blackhole
+new
[archive]
---default-storage-engine=archive
+default-storage-engine=archive
+new
=== added file 'mysql-test/suite/backup_extra/combinations'
--- a/mysql-test/suite/backup_extra/combinations 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_extra/combinations 2009-05-12 19:53:21 +0000
@@ -0,0 +1,2 @@
+[ENABLED]
+--new
=== modified file 'mysql-test/suite/backup_ptr/combinations'
--- a/mysql-test/suite/backup_ptr/combinations 2009-03-05 20:51:14 +0000
+++ b/mysql-test/suite/backup_ptr/combinations 2009-05-12 19:53:21 +0000
@@ -1,8 +1,11 @@
[row]
binlog-format=row
+new
[stmt]
binlog-format=statement
+new
[mix]
binlog-format=mixed
+new
=== added file 'mysql-test/t/backup_disabled.test'
--- a/mysql-test/t/backup_disabled.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/backup_disabled.test 2009-05-12 19:53:21 +0000
@@ -0,0 +1,49 @@
+#
+# This tests that backup and restore commands are disabled in the
+# server by default.
+#
+# Note: All backup tests and suites will run as normal using the
+# --new server startup option
+#
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+
+--echo #
+--echo # Create some database
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+
+let $MYSQLD_BACKUPDIR= `select @@backupdir`;
+
+CREATE DATABASE db1;
+
+--echo #
+--echo # Attempt to run a backup.
+--echo #
+--error ER_BACKUP_NOT_ENABLED
+BACKUP DATABASE db1 to 'bup_db1.bak';
+
+--echo #
+--echo # Attempt to run a backup test command.
+--echo #
+--error ER_BACKUP_NOT_ENABLED
+BACKUP_TEST aflac;
+
+--echo #
+--echo # Attempt to run a restore
+--echo #
+--error ER_BACKUP_NOT_ENABLED
+RESTORE FROM 'bup_db1.bak';
+
+--echo #
+--echo # Cleanup
+--echo #
+
+DROP DATABASE db1;
+
+--error 0,1
+--remove_file $MYSQLD_BACKUPDIR/bup_db1.bak
+
=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt 2009-04-24 14:55:53 +0000
+++ b/sql/share/errmsg.txt 2009-05-12 19:53:21 +0000
@@ -6514,3 +6514,5 @@ ER_PATH_LENGTH
eng "The path specified for %.64s is too long."
ER_BACKUP_INTERRUPTED
eng "Operation has been interrupted."
+ER_BACKUP_NOT_ENABLED
+ eng "The MySQL Backup system is disabled in this release. Use --new on server startup to enable."
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2009-04-22 22:12:25 +0000
+++ b/sql/sql_parse.cc 2009-05-12 19:53:21 +0000
@@ -2369,12 +2369,20 @@ mysql_execute_command(THD *thd)
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "BACKUP");
goto error;
#else
- /*
- Note: execute_backup_test_command() sends a correct response to the client
- (either ok, result set or error message).
- */
- if (execute_backup_test_command(thd, &lex->db_list))
+ if (global_system_variables.new_mode)
+ {
+ /*
+ Note: execute_backup_test_command() sends a correct response to the client
+ (either ok, result set or error message).
+ */
+ if (execute_backup_test_command(thd, &lex->db_list))
+ goto error;
+ }
+ else
+ {
+ my_error(ER_BACKUP_NOT_ENABLED, MYF(0));
goto error;
+ }
break;
#endif
#endif
@@ -2390,76 +2398,84 @@ mysql_execute_command(THD *thd)
goto error;
#else
{
- /*
- Stack the 'backup_in_progress' variable. If this is run inside
- backup/restore, it will probably fail. But then we need to
- return to the former value.
- */
- int saved_backup_in_progress= thd->backup_in_progress;
- thd->backup_in_progress= lex->sql_command;
+ if (global_system_variables.new_mode)
+ {
+ /*
+ Stack the 'backup_in_progress' variable. If this is run inside
+ backup/restore, it will probably fail. But then we need to
+ return to the former value.
+ */
+ int saved_backup_in_progress= thd->backup_in_progress;
+ thd->backup_in_progress= lex->sql_command;
- /*
- Reset warnings for BACKUP and RESTORE commands. Note: this will
- cause problems if BACKUP/RESTORE is allowed inside stored
- routines and events. In that case, warnings should not be
- cleared.
- */
- thd->warning_info->opt_clear_warning_info(thd->query_id);
+ /*
+ Reset warnings for BACKUP and RESTORE commands. Note: this will
+ cause problems if BACKUP/RESTORE is allowed inside stored
+ routines and events. In that case, warnings should not be
+ cleared.
+ */
+ thd->warning_info->opt_clear_warning_info(thd->query_id);
- /*
- Create a string from the backupdir system variable and pass
- to backup system.
- */
- String backupdir;
+ /*
+ Create a string from the backupdir system variable and pass
+ to backup system.
+ */
+ String backupdir;
- backupdir.alloc(sys_var_backupdir.value_length);
- backupdir.set_ascii(sys_var_backupdir.value,
- sys_var_backupdir.value_length);
- backupdir.length(sys_var_backupdir.value_length);
+ backupdir.alloc(sys_var_backupdir.value_length);
+ backupdir.set_ascii(sys_var_backupdir.value,
+ sys_var_backupdir.value_length);
+ backupdir.length(sys_var_backupdir.value_length);
- /* Used to specify if RESTORE should overwrite existing db with same name */
- bool overwrite_restore= false;
+ /* Used to specify if RESTORE should overwrite existing db with same name */
+ bool overwrite_restore= false;
- /* Used to specify if RESTORE should skup writing the gap event. */
- bool skip_gap_event= false;
+ /* Used to specify if RESTORE should skup writing the gap event. */
+ bool skip_gap_event= false;
- List<Item> lit= lex->value_list;
- Item *it= 0;
+ List<Item> lit= lex->value_list;
+ Item *it= 0;
- // value list only set for RESTORE in sql_yacc.yy, no error checking of
- // item necessary for backup
- while (lit.elements)
- {
- it= lit.pop();
- /*
- it is OK to only emulate fix_fields, because we need only
- value of constant
- */
- it->quick_fix_field();
- int val= (int)it->val_int();
+ // value list only set for RESTORE in sql_yacc.yy, no error checking of
+ // item necessary for backup
+ while (lit.elements)
+ {
+ it= lit.pop();
+ /*
+ it is OK to only emulate fix_fields, because we need only
+ value of constant
+ */
+ it->quick_fix_field();
+ int val= (int)it->val_int();
+ /*
+ Check options.
+ */
+ switch (val) {
+ /* OVERWRITE option */
+ case 1:
+ overwrite_restore= true;
+ break;
+ /* SKIP GAP EVENT option */
+ case 2:
+ skip_gap_event= true;
+ break;
+ }
+ }
/*
- Check options.
+ Note: execute_backup_command() sends a correct response to the client
+ (either ok, result set or error message).
*/
- switch (val) {
- /* OVERWRITE option */
- case 1:
- overwrite_restore= true;
- break;
- /* SKIP GAP EVENT option */
- case 2:
- skip_gap_event= true;
- break;
- }
+ res= execute_backup_command(thd, lex, &backupdir, overwrite_restore,
+ skip_gap_event);
+ thd->backup_in_progress= saved_backup_in_progress;
+ if (res)
+ goto error;
}
- /*
- Note: execute_backup_command() sends a correct response to the client
- (either ok, result set or error message).
- */
- res= execute_backup_command(thd, lex, &backupdir, overwrite_restore,
- skip_gap_event);
- thd->backup_in_progress= saved_backup_in_progress;
- if (res)
+ else
+ {
+ my_error(ER_BACKUP_NOT_ENABLED, MYF(0));
goto error;
+ }
break;
}
#endif