From 1542fffb345693565a32f9a2e6a1eba980aeaaf2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 23:24:45 +0200 Subject: First commit for fixing BUG#1100 "LOAD DATA INFILE is badly filtered by binlog-*-db rules". There will probably be a second final one to merge Dmitri's changes to rpl_log.result and mine. 2 new tests: rpl_loaddata_rule_m : test of logging of LOAD DATA INFILE when the master has binlog-*-db rules, rpl_loaddata_rule_s : test of logging of LOAD DATA INFILE when the slave has binlog-*-db rules and --log-slave-updates. mysql-test/r/rpl_loaddata.result: Test that logging of LOAD DATA INFILE is done on the slave mysql-test/t/rpl_loaddata.test: Test that logging of LOAD DATA is done on the slave sql/log.cc: debug info sql/log_event.cc: * Append_block, Exec_load and Delete_file now have a member 'db' like Create_file. This member is filled by mysql_load(). It is used for filtering by binlog-*-db rules, that's all. It's not written to the binlog, and so can't be read from the binlog. In other words, that's temporary info which is stored in the event and lost when it is written and deleted. * Better error messages in Append_block et al. events. * The slave now logs (log-slave-updates) the Create_file et al. events in mysql_load() (they are not directly copied from the events in the relay log, because this prevented filtering by binlog-*-db rules). Before, mysql_load() in the slave did no logging, now it does the logging, as in any regular thread. sql/log_event.h: New member 'db' for Append_block et al. events. sql/slave.cc: Removed useless code. Why was it useless: - CREATE_FILE_EVENT is not defined in 3.23. It appeared in 4.0. - in queue_old_event(), which is called only if the master is 3.23, we had a case CREATE_FILE_EVENT: so this case can be removed. - this case was the only caller of process_io_create_file() so this function can be removed. sql/sql_load.cc: Pass the db to events, so that they can be well filtered. sql/sql_repl.cc: Pass the db to events so that they can be well filtered. --- sql/slave.cc | 109 ----------------------------------------------------------- 1 file changed, 109 deletions(-) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index 85a9bc0d49e..66a875b158f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -57,7 +57,6 @@ typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE; void skip_load_data_infile(NET* net); static int process_io_rotate(MASTER_INFO* mi, Rotate_log_event* rev); -static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev); static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli); static inline bool io_slave_killed(THD* thd,MASTER_INFO* mi); static inline bool sql_slave_killed(THD* thd,RELAY_LOG_INFO* rli); @@ -2730,102 +2729,6 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ } -static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev) -{ - int error = 1; - ulong num_bytes; - bool cev_not_written; - THD* thd; - NET* net = &mi->mysql->net; - DBUG_ENTER("process_io_create_file"); - - if (unlikely(!cev->is_valid())) - DBUG_RETURN(1); - /* - TODO: fix to honor table rules, not only db rules - */ - if (!db_ok(cev->db, replicate_do_db, replicate_ignore_db)) - { - skip_load_data_infile(net); - DBUG_RETURN(0); - } - DBUG_ASSERT(cev->inited_from_old); - thd = mi->io_thd; - thd->file_id = cev->file_id = mi->file_id++; - thd->server_id = cev->server_id; - cev_not_written = 1; - - if (unlikely(net_request_file(net,cev->fname))) - { - sql_print_error("Slave I/O: failed requesting download of '%s'", - cev->fname); - goto err; - } - - /* - This dummy block is so we could instantiate Append_block_log_event - once and then modify it slightly instead of doing it multiple times - in the loop - */ - { - Append_block_log_event aev(thd,0,0,0); - - for (;;) - { - if (unlikely((num_bytes=my_net_read(net)) == packet_error)) - { - sql_print_error("Network read error downloading '%s' from master", - cev->fname); - goto err; - } - if (unlikely(!num_bytes)) /* eof */ - { - send_ok(net); /* 3.23 master wants it */ - Execute_load_log_event xev(thd,0); - xev.log_pos = mi->master_log_pos; - if (unlikely(mi->rli.relay_log.append(&xev))) - { - sql_print_error("Slave I/O: error writing Exec_load event to \ -relay log"); - goto err; - } - mi->rli.relay_log.harvest_bytes_written(&mi->rli.log_space_total); - break; - } - if (unlikely(cev_not_written)) - { - cev->block = (char*)net->read_pos; - cev->block_len = num_bytes; - cev->log_pos = mi->master_log_pos; - if (unlikely(mi->rli.relay_log.append(cev))) - { - sql_print_error("Slave I/O: error writing Create_file event to \ -relay log"); - goto err; - } - cev_not_written=0; - mi->rli.relay_log.harvest_bytes_written(&mi->rli.log_space_total); - } - else - { - aev.block = (char*)net->read_pos; - aev.block_len = num_bytes; - aev.log_pos = mi->master_log_pos; - if (unlikely(mi->rli.relay_log.append(&aev))) - { - sql_print_error("Slave I/O: error writing Append_block event to \ -relay log"); - goto err; - } - mi->rli.relay_log.harvest_bytes_written(&mi->rli.log_space_total) ; - } - } - } - error=0; -err: - DBUG_RETURN(error); -} - /* Start using a new binary log on the master @@ -2929,18 +2832,6 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf, mi->ignore_stop_event=1; inc_pos= 0; break; - case CREATE_FILE_EVENT: - { - /* We come here when and only when tmp_buf != 0 */ - DBUG_ASSERT(tmp_buf); - int error = process_io_create_file(mi,(Create_file_log_event*)ev); - delete ev; - mi->master_log_pos += event_len; - DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); - pthread_mutex_unlock(&mi->data_lock); - my_free((char*)tmp_buf, MYF(0)); - DBUG_RETURN(error); - } default: mi->ignore_stop_event=0; inc_pos= event_len; -- cgit v1.2.1