Hi Daogang,
Great work.
Only one comments about refactoring the code.
On Thu, 2010-10-28 at 10:06 +0000, Dao-Gang.Qu@stripped wrote:
> === modified file 'client/mysqlbinlog.cc'
> --- a/client/mysqlbinlog.cc 2010-10-25 13:49:55 +0000
> +++ b/client/mysqlbinlog.cc 2010-10-28 10:05:54 +0000
> @@ -35,6 +35,7 @@
> #include <signal.h>
> #include <my_dir.h>
> #include "log_event.h"
> +#include "log_event_old.h"
> #include "sql_common.h"
> #include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
>
> @@ -730,7 +731,8 @@ Exit_status process_event(PRINT_EVENT_IN
> goto end;
> }
> if (!short_form)
> - fprintf(result_file, "# at %s\n",llstr(pos,ll_buff));
> + my_b_printf(&print_event_info->head_cache,
> + "# at %s\n",llstr(pos,ll_buff));
>
> if (!opt_hexdump)
> print_event_info->hexdump_from= 0; /* Disabled */
> @@ -897,10 +899,6 @@ Exit_status process_event(PRINT_EVENT_IN
> my_free(fname);
> break;
> }
> - case ROWS_QUERY_LOG_EVENT:
> - if (verbose >= 2)
> - ev->print(result_file, print_event_info);
> - break;
> case TABLE_MAP_EVENT:
> {
> Table_map_log_event *map= ((Table_map_log_event *)ev);
> @@ -911,6 +909,7 @@ Exit_status process_event(PRINT_EVENT_IN
> goto end;
> }
> }
> + case ROWS_QUERY_LOG_EVENT:
> case WRITE_ROWS_EVENT:
> case DELETE_ROWS_EVENT:
> case UPDATE_ROWS_EVENT:
> @@ -918,7 +917,7 @@ Exit_status process_event(PRINT_EVENT_IN
> case PRE_GA_DELETE_ROWS_EVENT:
> case PRE_GA_UPDATE_ROWS_EVENT:
> {
> - if (ev_type != TABLE_MAP_EVENT)
> + if (ev_type != TABLE_MAP_EVENT && ev_type != ROWS_QUERY_LOG_EVENT)
> {
> Rows_log_event *e= (Rows_log_event*) ev;
The code check stmt_end should be move to this place.
> Table_map_log_event *ignored_map=
> @@ -981,11 +980,42 @@ Exit_status process_event(PRINT_EVENT_IN
> type_str);
> goto err;
> }
> - /* FALL THROUGH */
> +
> + ev->print(result_file, print_event_info);
> + bool stmt_end= FALSE;
> + if (ev_type == WRITE_ROWS_EVENT ||
> + ev_type == DELETE_ROWS_EVENT ||
> + ev_type == UPDATE_ROWS_EVENT)
> + {
> + Rows_log_event *new_ev= (Rows_log_event*) ev;
> + if (new_ev->get_flags(Rows_log_event::STMT_END_F))
> + stmt_end= TRUE;
> + }
> + else if (ev_type == PRE_GA_WRITE_ROWS_EVENT ||
> + ev_type == PRE_GA_DELETE_ROWS_EVENT ||
> + ev_type == PRE_GA_UPDATE_ROWS_EVENT)
> + {
> + Old_rows_log_event *old_ev= (Old_rows_log_event*) ev;
> + if (old_ev->get_flags(Rows_log_event::STMT_END_F))
> + stmt_end= TRUE;
> + }
> + /* Flush head and body cache to result_file */
> + if (stmt_end)
> + {
> + if
> (copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, result_file)
> ||
> +
> copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, result_file))
> + goto err;
> + goto end;
> + }
> + break;
> }
> default:
> ev->print(result_file, print_event_info);
> }
> + /* Flush head cache to result_file for every event */
> + if (copy_event_cache_to_file_and_reinit(&print_event_info->head_cache,
> + result_file))
> + goto err;
> }
>
> goto end;
> @@
--
Your Sincerely,
Libing Song
==================================
MySQL Replication Team
Software Engineer
Email : Li-Bing.Song@stripped
Skype : libing.song
MSN : slb_database@stripped
Phone : +86 010-6505-4020 ext. 319
Mobile: +86 138-1144-2038
==================================