diff options
author | unknown <acurtis@xiphis.org> | 2005-05-24 15:52:48 +0100 |
---|---|---|
committer | unknown <acurtis@xiphis.org> | 2005-05-24 15:52:48 +0100 |
commit | 879d932ba9b2757b21826b323cca9ae6f70e8b64 (patch) | |
tree | 2e12d887aeb0739e493ddae71187746c1ba9ab09 /sql/sql_repl.cc | |
parent | 0e4afc241205719296c39b0b1b0694d2baaccf21 (diff) | |
parent | 3a23b67566681a5368fd7f7a0c1004863819dc0e (diff) | |
download | mariadb-git-879d932ba9b2757b21826b323cca9ae6f70e8b64.tar.gz |
Merge
mysql-test/r/lock.result:
Auto merged
mysql-test/r/rpl_log.result:
Auto merged
mysql-test/t/lock.test:
Auto merged
mysql-test/r/rpl_rotate_logs.result:
SCCS merged
sql/sql_parse.cc:
SCCS merged
sql/sql_repl.cc:
SCCS merged
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r-- | sql/sql_repl.cc | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 0dcfd985f88..ca67b09fdc8 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1478,6 +1478,11 @@ bool show_binlog_info(THD* thd) bool show_binlogs(THD* thd) { IO_CACHE *index_file; + LOG_INFO cur; + IO_CACHE log; + File file; + const char *errmsg= 0; + MY_STAT stat_area; char fname[FN_REFLEN]; List<Item> field_list; uint length; @@ -1491,21 +1496,43 @@ bool show_binlogs(THD* thd) } field_list.push_back(new Item_empty_string("Log_name", 255)); + field_list.push_back(new Item_return_int("File_size", 20, + MYSQL_TYPE_LONGLONG)); if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_RETURN(TRUE); mysql_bin_log.lock_index(); index_file=mysql_bin_log.get_index_file(); - + + mysql_bin_log.get_current_log(&cur); + int cur_dir_len = dirname_length(cur.log_file_name); + reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 0); /* The file ends with EOF or empty line */ while ((length=my_b_gets(index_file, fname, sizeof(fname))) > 1) { + fname[--length] = '\0'; /* remove the newline */ + protocol->prepare_for_resend(); int dir_len = dirname_length(fname); - /* The -1 is for removing newline from fname */ - protocol->store(fname + dir_len, length-1-dir_len, &my_charset_bin); + protocol->store(fname + dir_len, length-dir_len, &my_charset_bin); + if(!(strncmp(fname+dir_len, cur.log_file_name+cur_dir_len, length-dir_len))) + { + /* this is the active log, use the active position */ + protocol->store((ulonglong) cur.pos); + } else { + /* this is an old log, open it and find the size */ + if ((file=open_binlog(&log, fname+dir_len, &errmsg)) >= 0) + { + protocol->store((ulonglong) my_b_filelength(&log)); + end_io_cache(&log); + my_close(file, MYF(0)); + } else { + /* the file wasn't openable, but 0 is an invalid value anyway */ + protocol->store((ulonglong) 0); + } + } if (protocol->write()) goto err; } |