From: Date: June 30 2008 3:22am Subject: [patch 04/10] WL4271 Encrypted online backup: pass encryption information to backup kernel, return ER_NOT_SUPPORTED_YET List-Archive: http://lists.mysql.com/internals/35764 Message-Id: <20080630012611.512394896@flamingspork.com> --- mysql-test/r/backup_encrypted_syntax_basic.result | 12 +++------ mysql-test/t/backup_encrypted_syntax_basic.test | 10 ++++---- sql/backup/backup_kernel.h | 7 ++++- sql/backup/kernel.cc | 27 ++++++++++++++++++---- 4 files changed, 38 insertions(+), 18 deletions(-) Index: stew-encrypted-backup/mysql-test/r/backup_encrypted_syntax_basic.result =================================================================== --- stew-encrypted-backup.orig/mysql-test/r/backup_encrypted_syntax_basic.result 2008-06-26 02:49:46.018621982 +1000 +++ stew-encrypted-backup/mysql-test/r/backup_encrypted_syntax_basic.result 2008-06-26 15:32:04.199842759 +1000 @@ -2,17 +2,13 @@ BACKUP DATABASE test TO 'test.ba'; backup_id 1 BACKUP DATABASE test TO 'test1.ba' ENCRYPTION_ALGORITHM=foo; -backup_id -2 +ERROR 42000: This version of MySQL doesn't yet support 'foo' BACKUP DATABASE test TO 'test2.ba' ENCRYPTION_ALGORITHM=aes; -backup_id -3 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use BACKUP DATABASE test TO 'test3.ba' ENCRYPTION_ALGORITHM=aes ENCRYPTION_KEYSIZE=128; -backup_id -4 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use BACKUP DATABASE test TO 'test4.ba' ENCRYPTION_ALGORITHM=aes ENCRYPTION_KEYSIZE=128 PASSWORD='pants'; backup_id 5 BACKUP DATABASE test TO 'test5.ba' ENCRYPTION_ALGORITHM=aes ENCRYPTION_KEYSIZE=128 ENCRYPTION_KEYFILE='foo.key'; -backup_id -6 +ERROR 42000: This version of MySQL doesn't yet support 'Encryption with keyfile' Index: stew-encrypted-backup/mysql-test/t/backup_encrypted_syntax_basic.test =================================================================== --- stew-encrypted-backup.orig/mysql-test/t/backup_encrypted_syntax_basic.test 2008-06-26 02:49:46.053791951 +1000 +++ stew-encrypted-backup/mysql-test/t/backup_encrypted_syntax_basic.test 2008-06-26 15:32:04.319836216 +1000 @@ -1,17 +1,17 @@ --source include/not_embedded.inc BACKUP DATABASE test TO 'test.ba'; +--error 1235 BACKUP DATABASE test TO 'test1.ba' ENCRYPTION_ALGORITHM=foo; +--error 1235 BACKUP DATABASE test TO 'test2.ba' ENCRYPTION_ALGORITHM=aes; +--error 1235 BACKUP DATABASE test TO 'test3.ba' ENCRYPTION_ALGORITHM=aes ENCRYPTION_KEYSIZE=128; +--error 1235 BACKUP DATABASE test TO 'test4.ba' ENCRYPTION_ALGORITHM=aes ENCRYPTION_KEYSIZE=128 PASSWORD='pants'; +--error 1235 BACKUP DATABASE test TO 'test5.ba' ENCRYPTION_ALGORITHM=aes ENCRYPTION_KEYSIZE=128 ENCRYPTION_KEYFILE='foo.key'; --remove_file $MYSQLTEST_VARDIR/master-data/test.ba ---remove_file $MYSQLTEST_VARDIR/master-data/test1.ba ---remove_file $MYSQLTEST_VARDIR/master-data/test2.ba ---remove_file $MYSQLTEST_VARDIR/master-data/test3.ba ---remove_file $MYSQLTEST_VARDIR/master-data/test4.ba ---remove_file $MYSQLTEST_VARDIR/master-data/test5.ba Index: stew-encrypted-backup/sql/backup/backup_kernel.h =================================================================== --- stew-encrypted-backup.orig/sql/backup/backup_kernel.h 2008-06-26 02:33:17.371617799 +1000 +++ stew-encrypted-backup/sql/backup/backup_kernel.h 2008-06-26 15:32:04.047836810 +1000 @@ -66,7 +66,12 @@ class Backup_restore_ctx: public backup: bool is_valid() const; ulonglong op_id() const; - Backup_info* prepare_for_backup(LEX_STRING location, const char*, bool); + Backup_info* prepare_for_backup(LEX_STRING location, const char*, bool, + LEX_STRING encryption_algorithm, + ulong encryption_keysize, + LEX_STRING encryption_keyfile, + LEX_STRING encryption_password); + Restore_info* prepare_for_restore(LEX_STRING location, const char*); int do_backup(); Index: stew-encrypted-backup/sql/backup/kernel.cc =================================================================== --- stew-encrypted-backup.orig/sql/backup/kernel.cc 2008-06-26 02:33:17.438619193 +1000 +++ stew-encrypted-backup/sql/backup/kernel.cc 2008-06-26 15:32:04.715858869 +1000 @@ -143,8 +143,11 @@ execute_backup_command(THD *thd, LEX *le // prepare for backup operation Backup_info *info= context.prepare_for_backup(lex->backup_dir, thd->query, - lex->backup_compression); - // reports errors + lex->backup_compression, + lex->encryption_algorithm, + lex->encryption_keysize, + lex->encryption_keyfile, + lex->encryption_password); if (!info || !info->is_valid()) DBUG_RETURN(send_error(context, ER_BACKUP_BACKUP_PREPARE)); @@ -462,7 +465,11 @@ int Backup_restore_ctx::prepare(LEX_STRI */ Backup_info* Backup_restore_ctx::prepare_for_backup(LEX_STRING location, const char *query, - bool with_compression) + bool with_compression, + LEX_STRING encryption_algorithm, + ulong encryption_keysize, + LEX_STRING encryption_keyfile, + LEX_STRING encryption_password) { using namespace backup; @@ -486,7 +493,19 @@ Backup_restore_ctx::prepare_for_backup(L return NULL; backup::String path(location); - + backup::String encryption_algorithm_str(encryption_algorithm); + backup::String encryption_keyfile_str(encryption_keyfile); + backup::String encryption_password_str(encryption_password); + + if(encryption_algorithm_str.ptr() + || encryption_keyfile_str.ptr() + || encryption_password_str.ptr() + || encryption_keysize) + { + fatal_error(ER_NOT_SUPPORTED_YET, "Encrypted Backup"); + return NULL; + } + /* Open output stream. */ -- Stewart Smith