summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <lars@mysql.com>2005-05-19 12:59:46 +0200
committerunknown <lars@mysql.com>2005-05-19 12:59:46 +0200
commit9364130a1a55cbe0d3db01fe0b58f722d8683ee1 (patch)
tree73f9a2b0f979edfefee9966b591e80afb8ed3fdb /sql
parent27378545f9d9265e4dc9bec00e560f717457a8e7 (diff)
parente439e7c649132351c7807a15ff76917d0a6d7280 (diff)
downloadmariadb-git-9364130a1a55cbe0d3db01fe0b58f722d8683ee1.tar.gz
Merge mysql.com:/home/bkroot/mysql-4.1 into mysql.com:/home/bk/c4944-4.1
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_repl.cc33
1 files changed, 30 insertions, 3 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index d02bb5ff0a3..24b78bc9a3d 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1337,6 +1337,11 @@ int show_binlog_info(THD* thd)
int 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;
@@ -1351,20 +1356,42 @@ int 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, 1))
DBUG_RETURN(1);
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;
}