Commit c78c1fe5 authored by Sujatha Sivakumar's avatar Sujatha Sivakumar

Bug#14324766:PARTIALLY WRITTEN INSERT STATEMENT IN BINLOG

NO ERRORS REPORTED
      
Problem:
=======
Errors from my_b_fill are ignored. MYSQL_BIN_LOG::write_cache
code assumes that 0 returned from my_b_fill always means
end-of-cache, but that is incorrect. It can result in error
and the error is ignored. Other callers of my_b_fill don't
check for error: my_b_copy_to_file, maybe my_b_gets.
      
Fix:
===
An error handler is already present to check the "cache"
error that is reported during "MYSQL_BIN_LOG::write_cache"
call. Hence error handlers are added for "my_b_copy_to_file"
and "my_b_gets".
During my_b_fill() function call, when the cache read fails
info->error= -1 is set. Hence a check for "info->error"
is added for the above to callers upon their return.
parent 9d7f333a
/* /*
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -66,6 +66,8 @@ my_b_copy_to_file(IO_CACHE *cache, FILE *file) ...@@ -66,6 +66,8 @@ my_b_copy_to_file(IO_CACHE *cache, FILE *file)
DBUG_RETURN(1); DBUG_RETURN(1);
cache->read_pos= cache->read_end; cache->read_pos= cache->read_end;
} while ((bytes_in_cache= my_b_fill(cache))); } while ((bytes_in_cache= my_b_fill(cache)));
if(cache->error == -1)
DBUG_RETURN(1);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -215,6 +217,8 @@ size_t my_b_fill(IO_CACHE *info) ...@@ -215,6 +217,8 @@ size_t my_b_fill(IO_CACHE *info)
info->error= 0; info->error= 0;
return 0; /* EOF */ return 0; /* EOF */
} }
DBUG_EXECUTE_IF ("simulate_my_b_fill_error",
{DBUG_SET("+d,simulate_file_read_error");});
if ((length= my_read(info->file,info->buffer,max_length, if ((length= my_read(info->file,info->buffer,max_length,
info->myflags)) == (size_t) -1) info->myflags)) == (size_t) -1)
{ {
......
/* Copyright (c) 2000-2002, 2004, 2006, 2007 MySQL AB /* Copyright (c) 2000-2002, 2004, 2006, 2007, 2013 MySQL AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -44,8 +44,18 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags) ...@@ -44,8 +44,18 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
for (;;) for (;;)
{ {
errno= 0; /* Linux doesn't reset this */ errno= 0; /* Linux doesn't reset this */
if ((readbytes= read(Filedes, Buffer, (uint) Count)) != Count) if (DBUG_EVALUATE_IF("simulate_file_read_error", 1, 0) ||
(readbytes= read(Filedes, Buffer, (uint) Count)) != Count)
{ {
DBUG_EXECUTE_IF ("simulate_file_read_error",
{
errno= ENOSPC;
readbytes= (size_t) -1;
DBUG_SET("-d,simulate_file_read_error");
DBUG_SET("-d,simulate_my_b_fill_error");
});
my_errno= errno ? errno : -1; my_errno= errno ? errno : -1;
DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d", DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d",
(int) readbytes, (ulong) Count, Filedes, (int) readbytes, (ulong) Count, Filedes,
......
...@@ -9196,6 +9196,8 @@ Write_rows_log_event::do_exec_row(const Relay_log_info *const rli) ...@@ -9196,6 +9196,8 @@ Write_rows_log_event::do_exec_row(const Relay_log_info *const rli)
#ifdef MYSQL_CLIENT #ifdef MYSQL_CLIENT
void Write_rows_log_event::print(FILE *file, PRINT_EVENT_INFO* print_event_info) void Write_rows_log_event::print(FILE *file, PRINT_EVENT_INFO* print_event_info)
{ {
DBUG_EXECUTE_IF("simulate_cache_read_error",
{DBUG_SET("+d,simulate_my_b_fill_error");});
Rows_log_event::print_helper(file, print_event_info, "Write_rows"); Rows_log_event::print_helper(file, print_event_info, "Write_rows");
} }
#endif #endif
......
...@@ -1732,6 +1732,8 @@ bool show_binlogs(THD* thd) ...@@ -1732,6 +1732,8 @@ bool show_binlogs(THD* thd)
if (protocol->write()) if (protocol->write())
goto err; goto err;
} }
if(index_file->error == -1)
goto err;
mysql_bin_log.unlock_index(); mysql_bin_log.unlock_index();
my_eof(thd); my_eof(thd);
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment