diff options
author | unknown <guilhem@mysql.com> | 2004-06-30 15:41:35 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2004-06-30 15:41:35 +0200 |
commit | 62a6733e4ea237bec13e0e8c5c636d7a23343afe (patch) | |
tree | 266085d0bf706ef4ec7ed9774b1d7026fac6b137 /sql/log_event.cc | |
parent | 82472a06f3734c359a5876995443873b71daa2e4 (diff) | |
download | mariadb-git-62a6733e4ea237bec13e0e8c5c636d7a23343afe.tar.gz |
Fix for BUG#4326 "Replicated LOAD DATA INFILE show nothing in
processlist on slave":
we now report in SHOW PROCESSLIST that we are writing to the temp
files or loading the table. When we are writing to the tmp file:
| 3 | system user | | | Connect | 6 | Making temp file /tmp/SQL_LOAD-2-1-2.data |
and when we are actually loading the .data temp file into the table:
| 3 | system user | | test | Connect | 2 | | LOAD DATA INFILE '/tmp/SQL_LOAD-2-1-2.data' INTO TABLE `t` <...> |
sql/log_event.cc:
Replication of LOAD DATA INFILE:
we now report in SHOW PROCESSLIST that we are creating
the temp files or loading the table.
Plus removing a line which had a comment "should not be needed"
and a guarding assertion which we have never heard fail (and logic
says it should not fail).
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r-- | sql/log_event.cc | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc index f94056694cc..3e1544adf14 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1968,10 +1968,10 @@ end: int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, bool use_rli_only_for_errors) { + char *load_data_query= 0; init_sql_alloc(&thd->mem_root, thd->variables.query_alloc_block_size, 0); thd->db= (char*) rewrite_db(db); DBUG_ASSERT(thd->query == 0); - thd->query = 0; // Should not be needed clear_all_errors(thd, rli); if (!use_rli_only_for_errors) @@ -2024,6 +2024,19 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, { char llbuff[22]; enum enum_duplicates handle_dup; + /* + Make a simplified LOAD DATA INFILE query, for the information of the + user in SHOW PROCESSLIST. Note that db is known in the 'db' column. + */ + if ((load_data_query= (char *) my_alloca(18 + strlen(fname) + 14 + + strlen(tables.real_name) + 8))) + { + thd->query_length= (uint)(strxmov(load_data_query, + "LOAD DATA INFILE '", fname, + "' INTO TABLE `", tables.real_name, + "` <...>", NullS) - load_data_query); + thd->query= load_data_query; + } if (sql_ex.opt_flags & REPLACE_FLAG) handle_dup= DUP_REPLACE; else if (sql_ex.opt_flags & IGNORE_FLAG) @@ -2103,8 +2116,14 @@ Slave: load data infile on table '%s' at log position %s in log \ } thd->net.vio = 0; - thd->db= 0; // prevent db from being freed + VOID(pthread_mutex_lock(&LOCK_thread_count)); + thd->db= 0; + thd->query= 0; + thd->query_length= 0; + VOID(pthread_mutex_unlock(&LOCK_thread_count)); close_thread_tables(thd); + if (load_data_query) + my_afree(load_data_query); if (thd->query_error) { /* this err/sql_errno code is copy-paste from send_error() */ @@ -2326,7 +2345,7 @@ int Slave_log_event::exec_event(struct st_relay_log_info* rli) int Create_file_log_event::exec_event(struct st_relay_log_info* rli) { - char fname_buf[FN_REFLEN+10]; + char proc_info[17+FN_REFLEN+10], *fname_buf= proc_info+17; char *p; int fd = -1; IO_CACHE file; @@ -2335,6 +2354,8 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli) bzero((char*)&file, sizeof(file)); p = slave_load_file_stem(fname_buf, file_id, server_id); strmov(p, ".info"); // strmov takes less code than memcpy + strnmov(proc_info, "Making temp file ", 17); // no end 0 + thd->proc_info= proc_info; if ((fd = my_open(fname_buf, O_WRONLY|O_CREAT|O_BINARY|O_TRUNC, MYF(MY_WME))) < 0 || init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0, @@ -2376,6 +2397,7 @@ err: end_io_cache(&file); if (fd >= 0) my_close(fd, MYF(0)); + thd->proc_info= 0; return error ? 1 : Log_event::exec_event(rli); } @@ -2392,12 +2414,14 @@ int Delete_file_log_event::exec_event(struct st_relay_log_info* rli) int Append_block_log_event::exec_event(struct st_relay_log_info* rli) { - char fname[FN_REFLEN+10]; + char proc_info[17+FN_REFLEN+10], *fname= proc_info+17; char *p= slave_load_file_stem(fname, file_id, server_id); int fd; int error = 1; memcpy(p, ".data", 6); + strnmov(proc_info, "Making temp file ", 17); // no end 0 + thd->proc_info= proc_info; if ((fd = my_open(fname, O_WRONLY|O_APPEND|O_BINARY, MYF(MY_WME))) < 0) { slave_print_error(rli,my_errno, "Error in Append_block event: could not open file '%s'", fname); @@ -2413,6 +2437,7 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli) err: if (fd >= 0) my_close(fd, MYF(0)); + thd->proc_info= 0; return error ? error : Log_event::exec_event(rli); } |