Rafal,
Thanks for following up my requests and many of many suggestions.
Patch approved.
--
Øystein
Rafal Somla wrote:
> #At file:///ext/mysql/bzr/backup/bug40303/
>
> 2738 Rafal Somla 2008-11-20
> BUG#40303 (Backup: Wrong error send to client if several errors reported)
> BUG#40304 (Backup: Errors reported during BACKUP show as warnings on the
> error stack)
>
> Before: Errors reported using backup::Logger class could be saved and in
> case several errors are reported, the last one was sent to client as an
> error reply from BACKUP/RESTORE command.
>
> After: Errors reported with backup::Logger are reported to the server
> using my_printf_error(..) function. This function pushes error on the
> error stack (unles told otherwise) and stores the first reported error
> so that it is send to the client.
>
> Additionally.
>
> - Function log_error(..) is moved to the Logger class.
>
> - Code is changed to consistently use Logger::report/log_error() for error
> reporting.
>
> - Semantics of Backup_restore_ctx::fatal_error() has been changed to
> discourage its use as an error reporting facility. Now it is an internal helper
>
> method which moves the context object into error state. It is used only by the
>
> class methods and it is made private. The idea is that context object should
> move into error state only as a result of executing one of its methods (not
> externally).
>
> - Improved error reporting in few places.
> modified:
> mysql-test/suite/backup/r/backup_errors.result
> mysql-test/suite/backup/r/backup_views.result
> mysql-test/suite/backup/t/backup_errors.test
> mysql-test/suite/backup/t/backup_myisam1.test
> mysql-test/suite/backup/t/backup_views.test
> sql/backup/backup_info.cc
> sql/backup/backup_info.h
> sql/backup/backup_kernel.h
> sql/backup/data_backup.cc
> sql/backup/image_info.cc
> sql/backup/image_info.h
> sql/backup/kernel.cc
> sql/backup/logger.cc
> sql/backup/logger.h
> sql/backup/restore_info.h
> sql/share/errmsg.txt
>
> per-file messages:
> mysql-test/suite/backup/t/backup_errors.test
> Add SHOW WARNINGS to see what is pushed on the error stack in case of errors.
> mysql-test/suite/backup/t/backup_myisam1.test
> Update the test, taking into account that after this patch failed BACKUP does not
>
> leave the unfinished backup image file around.
> mysql-test/suite/backup/t/backup_views.test
> Update the test taking into account that now RESTORE returns the first
> error reported.
> sql/backup/backup_info.cc
> - Use m_log.report_error(...) for error reporting.
> - Use the m_thd member instead of refering to a context class instance.
> sql/backup/backup_info.h
> - Instead of storing a reference to a complete Backup_restore_ctx instance,
> store only what is needed: a Logger instance and a THD handle.
> - Make constructor private.
> sql/backup/backup_kernel.h
> - Move log_error(..) method to the Logger class.
> - Make fatal_error(...) private and change its semantics. Now it only moves
> context
> object to an error state, but it does not report any errors - Logger methods
> should
> be used for reporting them.
> sql/backup/data_backup.cc
> - Use Logger instance for reporting errors.
> - Report few errors not logged previously (e.g. when (un)block_commits(..)
> fails).
> - Remove cancel_backup() calls as this is done in Backup_restore_ctx::close()
> called from destructor.
> - Inside Backup_pump class: log errors only if logger is set.
> - Fix the shutdown logic in restore_table_data(..). Drivers need to be correctly
>
> de-initialized by a call to ->end() during normal operation or ->cacnel()
> in case
> of interruption.
> sql/backup/image_info.h
> Introduced MAX_SNAP_COUNT symbolic constant.
> sql/backup/kernel.cc
> - Use explicit calls to report/log_error(..) for error logging - now
> fatal_error(..)
> does not log anything.
> - Simplified send_error(..) implementation - now it does not have to look for
> the
> last error reported. The first reported error is automatically stored by the
> server and send to the client.
> - Move error reporting context preparations to Logger::init(..).
> - To clarify the code, calls to s->next_chunk() have been moved to wrapper
> functions read_header(..), read_catalog(..) and read_meta_data(..) where they
> really belong.
> sql/backup/logger.cc
> - Remove code saving reported errors.
> - Use my_printf_error(..) instead of push_warning_printf(..) for
> reporting errors to the server core. This has the side effect of
> storing the first reported error so that it is sent to the client.
> sql/backup/logger.h
> - Add log_error(..) method moved here from Backup_restore_ctx.
> - Remove methods for saving reported errors - not needed any more because the
> first reported error is remembered by the server core.
> - Add error_reported() method.
> - Add error context cleanup (on server level) to init() method, instead of doing
> it inside Backup_restore_ctx class.
> sql/backup/restore_info.h
> - Only store what is needed: reference to Logger and THD handle.
> - Made constructor private.
> sql/share/errmsg.txt
> Add error message for reporting problems during validity point
> creation.