From: Date: November 28 2008 10:11am Subject: bzr commit into mysql-6.0-backup branch (Rafal.Somla:2736) Bug#40307 List-Archive: http://lists.mysql.com/commits/60127 X-Bug: 40307 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///ext/mysql/bzr/backup/bug40307/ 2736 Rafal Somla 2008-11-28 BUG#40307 - Backup: The list of databases processed by BACKUP/RESTORE not logged. After this patch, the trace from BACKUP/RESTOE commands left in server's error log (master.err) will look as follows: [Note] Backup: Starting backup process [Note] Backup: Backing up NN database(s) [Note] Backup: Backup completed [Note] Restore: Starting restore process [Note] Restore: Restoring NN database(s) [Note] Restore: Restore completed This way DBA can find out which databases are affected by the operation. Database list is reported in Logger::report_stats_pre() which is called after initializing backup/restore catalogue and before performing backup of table data. modified: sql/backup/kernel.cc sql/backup/logger.cc sql/share/errmsg.txt per-file messages: sql/backup/kernel.cc Remove messages which are replaced by the ones written in Logger::report_stats_pre(). sql/backup/logger.cc Compose list of databases in the backup/restore catalogue and report it. sql/share/errmsg.txt Added messages for reporting database list in error log, so that they can be internationalized. === modified file 'sql/backup/kernel.cc' --- a/sql/backup/kernel.cc 2008-11-25 17:44:19 +0000 +++ b/sql/backup/kernel.cc 2008-11-28 09:11:11 +0000 @@ -177,15 +177,9 @@ execute_backup_command(THD *thd, LEX *le // select objects to backup if (lex->db_list.is_empty()) - { - context.write_message(log_level::INFO, "Backing up all databases"); res= info->add_all_dbs(); // backup all databases - } else - { - context.write_message(log_level::INFO, "Backing up selected databases"); res= info->add_dbs(lex->db_list); // backup databases specified by user - } info->close(); // close catalogue after filling it with objects to backup === modified file 'sql/backup/logger.cc' --- a/sql/backup/logger.cc 2008-11-25 17:44:19 +0000 +++ b/sql/backup/logger.cc 2008-11-28 09:11:11 +0000 @@ -155,6 +155,43 @@ void Logger::report_stats_pre(const Imag { DBUG_ASSERT(m_state == RUNNING); backup_log->num_objects(info.table_count()); + // Compose list of databases. + + Image_info::Db_iterator *it= info.get_dbs(); + Image_info::Obj *db; + Image_info::Obj::describe_buf name_buf; + String dbs; + + while((db= (*it)++)) + { + if (!dbs.is_empty()) + dbs.append(","); + const size_t len= strnlen(db->describe(name_buf), sizeof(name_buf)); + /* + If appending next database name would create too long string, append + ellipsis instead and break the loop. + + The length limit 220-4 is computed as follows. The placeholder for + database list in ER_BACKUP_BACKUP/RESTORE_DBS has maximum width 220 from + which we subtract 4 for ",...", which should fit if the loop iterates + once more. + + The width 220 for database list placeholder is chosen so that a complete + message fits into 256 characters. + */ + if (dbs.length() + len > 220-4) + { + dbs.append("..."); + break; + } + dbs.append(name_buf); + } + + // Log the databases. + + report_error(log_level::INFO, m_type == BACKUP ? ER_BACKUP_BACKUP_DBS + : ER_BACKUP_RESTORE_DBS, + info.db_count(), dbs.c_ptr()); } /** === modified file 'sql/share/errmsg.txt' --- a/sql/share/errmsg.txt 2008-11-26 10:05:19 +0000 +++ b/sql/share/errmsg.txt 2008-11-28 09:11:11 +0000 @@ -6438,3 +6438,7 @@ ER_QUERY_CACHE_DISABLED eng "Query cache is disabled; restart the server with query_cache_type=1 to enable it" ER_BACKUP_UNEXPECTED_DATA eng "Backup image contains no tables, but table data was found in it" +ER_BACKUP_BACKUP_DBS + eng "Backing up %u database(s) %.220s" +ER_BACKUP_RESTORE_DBS + eng "Restoring %u database(s) %.220s"