--- mysql-5.1.49/client/mysqlbinlog.cc 2010-07-09 14:34:53.000000000 +0200 +++ mysql-5.1.49.dgryski/client/mysqlbinlog.cc 2011-10-13 14:59:28.000000000 +0200 @@ -71,6 +71,8 @@ static enum_base64_output_mode opt_base64_output_mode= BASE64_OUTPUT_UNSPEC; static const char *opt_base64_output_mode_str= NullS; static const char* database= 0; +static const char* tables = 0; /* "Table1,Table2,Table3,..." */ +static const char **table_names = 0; /* ["Table1", "Table2", "Table3", ... ] */ static my_bool force_opt= 0, short_form= 0, remote_opt= 0; static my_bool debug_info_flag, debug_check_flag; static my_bool force_if_open_opt= 1; @@ -620,6 +622,37 @@ /** + Indicates whether the given table should be filtered out, + according to the --tables=X option. + + @param log_tblname Name of table. + + @return nonzero if the table with the given name should be + filtered out, 0 otherwise. +*/ + +static bool shall_skip_table(const char *log_tblname) { + + const char **p = table_names; + + if (!table_names) { + /* no tables to filter */ + return 0; + } + + while(*p) { + if (strcmp(log_tblname, *p) == 0) { + return 0; + } + p++; + } + + /* We didn't find the table in our list -- filter it. */ + return 1; +} + + +/** Prints the given event in base64 format. The header is printed to the head cache and the body is printed to @@ -881,7 +914,7 @@ case TABLE_MAP_EVENT: { Table_map_log_event *map= ((Table_map_log_event *)ev); - if (shall_skip_database(map->get_db_name())) + if (shall_skip_database(map->get_db_name()) || shall_skip_table(map->get_table_name())) { print_event_info->m_table_map_ignored.set_table(map->get_table_id(), map); destroy_evt= FALSE; @@ -1126,6 +1159,9 @@ &stop_position, &stop_position, 0, GET_ULL, REQUIRED_ARG, (ulonglong)(~(my_off_t)0), BIN_LOG_HEADER_SIZE, (ulonglong)(~(my_off_t)0), 0, 0, 0}, + {"tables", 0, "List entries for just these tables", + &tables, &tables, 0, GET_STR_ALLOC, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, {"to-last-log", 't', "Requires -R. Will not stop at the end of the \ requested binlog but rather continue printing until the end of the last \ binlog of the MySQL server. If you send the output to the same MySQL server, \ @@ -2034,6 +2070,29 @@ if (opt_base64_output_mode == BASE64_OUTPUT_UNSPEC) opt_base64_output_mode= BASE64_OUTPUT_AUTO; + if (tables) + { + char *p = (char *)tables; + + int count = 0; + + while (*p) + { + if (*p == ',') + count++; + p++; + } + + count+=2; // for last element + sentinel + table_names = (const char **)malloc(sizeof(char *) * count ); + p = (char *)tables; + count = 0; + while(table_names[count] = strsep(&p, ",")) + { + count++; + } + } + my_set_max_open_files(open_files_limit); MY_TMPDIR tmpdir;