List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:October 3 2008 2:15pm
Subject:bzr commit into mysql-6.0 branch (davi:2723)
View as plain text  
# At a local mysql-6.0 repository of davi

 2723 Davi Arnaut	2008-10-03
      Rework the backup error handling to remove a dependency on the internals
      and lifetime of MYSQL_ERROR by maintaining a private copy of the error.
modified:
  sql/backup/error.h
  sql/backup/kernel.cc
  sql/backup/logger.cc
  sql/backup/logger.h

per-file messages:
  sql/backup/error.h
    Introduce SAVED_MYSQL_ERROR structure to keep around a copy of a error.
  sql/backup/kernel.cc
    Update to use new struct.
  sql/backup/logger.cc
    Save a copy of the error.
  sql/backup/logger.h
    Only keep the last error.
=== modified file 'sql/backup/error.h'
--- a/sql/backup/error.h	2008-04-08 15:32:47 +0000
+++ b/sql/backup/error.h	2008-10-03 14:15:40 +0000
@@ -3,6 +3,14 @@
 
 namespace util {
 
+/// Used to save messages pushed into the stack
+struct SAVED_MYSQL_ERROR {
+  uint code;
+  MYSQL_ERROR::enum_warning_level level;
+  char *msg;
+};
+
+
 /**
   Report error stored in MYSQL_ERROR structure to a client.
 
@@ -11,7 +19,7 @@ namespace util {
   @returns 0 if error was reported, non-zero otherwise.
  */
 inline
-int report_mysql_error(THD* thd, MYSQL_ERROR *err, int code= 0)
+int report_mysql_error(THD* thd, SAVED_MYSQL_ERROR *err, int code= 0)
 {
   DBUG_ASSERT(err);
 

=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc	2008-10-01 10:14:28 +0000
+++ b/sql/backup/kernel.cc	2008-10-03 14:15:40 +0000
@@ -264,7 +264,7 @@ execute_backup_command(THD *thd, LEX *le
  */
 int send_error(Backup_restore_ctx &log, int error_code, ...)
 {
-  MYSQL_ERROR *error= log.last_saved_error();
+  util::SAVED_MYSQL_ERROR *error= log.last_saved_error();
 
   if (error && !util::report_mysql_error(log.thd(), error, error_code))
   {

=== modified file 'sql/backup/logger.cc'
--- a/sql/backup/logger.cc	2008-08-27 15:48:32 +0000
+++ b/sql/backup/logger.cc	2008-10-03 14:15:40 +0000
@@ -47,8 +47,12 @@ int Logger::write_message(log_level::val
    switch (level) {
    case log_level::ERROR:
      if (m_save_errors)
-       errors.push_front(new MYSQL_ERROR(::current_thd, error_code,
-                                         MYSQL_ERROR::WARN_LEVEL_ERROR, msg));
+     {
+       error.code= error_code;
+       error.level= MYSQL_ERROR::WARN_LEVEL_ERROR;
+       error.msg= sql_strdup(msg);
+     }
+
      sql_print_error(out);
      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                          error_code, msg);

=== modified file 'sql/backup/logger.h'
--- a/sql/backup/logger.h	2008-07-09 18:37:42 +0000
+++ b/sql/backup/logger.h	2008-10-03 14:15:40 +0000
@@ -65,7 +65,7 @@ class Logger
    void save_errors();
    void stop_save_errors();
    void clear_saved_errors();
-   MYSQL_ERROR *last_saved_error();
+   util::SAVED_MYSQL_ERROR *last_saved_error();
 
  protected:
 
@@ -86,8 +86,7 @@ class Logger
   int write_message(log_level::value level , int error_code, const char *msg);
 
  private:
-
-  List<MYSQL_ERROR> errors;  ///< Used to store saved errors.
+  util::SAVED_MYSQL_ERROR error;   ///< Used to store saved errors.
   bool m_save_errors;        ///< Flag telling if errors should be saved.
 };
 
@@ -208,15 +207,15 @@ void Logger::stop_save_errors()
 /// Delete all saved errors to free resources.
 inline
 void Logger::clear_saved_errors()
-{ 
-  errors.delete_elements();
+{
+  memset(&error, 0, sizeof(error));
 }
 
 /// Return a pointer to most recent saved error.
 inline
-MYSQL_ERROR *Logger::last_saved_error()
+util::SAVED_MYSQL_ERROR *Logger::last_saved_error()
 { 
-  return errors.is_empty() ? NULL : errors.head();
+  return error.code ? &error : NULL;
 }
 
 /// Report start of an operation.

Thread
bzr commit into mysql-6.0 branch (davi:2723) Davi Arnaut3 Oct
  • Re: bzr commit into mysql-6.0 branch (davi:2723)Rafal Somla3 Oct