Skip to content

Commit 5b8308a

Browse files
author
Rohit Kalhans
committed
upmerge from mysql-5.1 branch -> mysql-5.5 branch
2 parents ca9a3a8 + 35d4c18 commit 5b8308a

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

client/mysqlbinlog.cc

+20-1
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
698698
DBUG_ENTER("process_event");
699699
print_event_info->short_form= short_form;
700700
Exit_status retval= OK_CONTINUE;
701+
IO_CACHE *const head= &print_event_info->head_cache;
701702

702703
/*
703704
Format events are not concerned by --offset and such, we always need to
@@ -761,6 +762,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
761762
}
762763
else
763764
ev->print(result_file, print_event_info);
765+
if (head->error == -1)
766+
goto err;
764767
break;
765768

766769
case CREATE_FILE_EVENT:
@@ -812,6 +815,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
812815
output of Append_block_log_event::print is only a comment.
813816
*/
814817
ev->print(result_file, print_event_info);
818+
if (head->error == -1)
819+
goto err;
815820
if ((retval= load_processor.process((Append_block_log_event*) ev)) !=
816821
OK_CONTINUE)
817822
goto end;
@@ -820,6 +825,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
820825
case EXEC_LOAD_EVENT:
821826
{
822827
ev->print(result_file, print_event_info);
828+
if (head->error == -1)
829+
goto err;
823830
Execute_load_log_event *exv= (Execute_load_log_event*)ev;
824831
Create_file_log_event *ce= load_processor.grab_event(exv->file_id);
825832
/*
@@ -849,6 +856,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
849856
print_event_info->common_header_len=
850857
glob_description_event->common_header_len;
851858
ev->print(result_file, print_event_info);
859+
if (head->error == -1)
860+
goto err;
852861
if (!remote_opt)
853862
{
854863
ev->free_temp_buf(); // free memory allocated in dump_local_log_entries
@@ -878,6 +887,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
878887
break;
879888
case BEGIN_LOAD_QUERY_EVENT:
880889
ev->print(result_file, print_event_info);
890+
if (head->error == -1)
891+
goto err;
881892
if ((retval= load_processor.process((Begin_load_query_log_event*) ev)) !=
882893
OK_CONTINUE)
883894
goto end;
@@ -988,6 +999,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
988999
}
9891000
default:
9901001
ev->print(result_file, print_event_info);
1002+
if (head->error == -1)
1003+
goto err;
9911004
}
9921005
}
9931006

@@ -2020,7 +2033,13 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
20202033
end:
20212034
if (fd >= 0)
20222035
my_close(fd, MYF(MY_WME));
2023-
end_io_cache(file);
2036+
/*
2037+
Since the end_io_cache() writes to the
2038+
file errors may happen.
2039+
*/
2040+
if (end_io_cache(file))
2041+
retval= ERROR_STOP;
2042+
20242043
return retval;
20252044
}
20262045

mysys/my_write.c

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
4040
#else
4141
writtenbytes= write(Filedes, Buffer, Count);
4242
#endif
43+
DBUG_EXECUTE_IF("simulate_file_write_error",
44+
{
45+
errno= ENOSPC;
46+
writtenbytes= (size_t) -1;
47+
});
4348
if (writtenbytes == Count)
4449
break;
4550
if (writtenbytes != (size_t) -1)

sql/log_event.cc

+6
Original file line numberDiff line numberDiff line change
@@ -3164,6 +3164,12 @@ void Query_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
31643164
{
31653165
Write_on_release_cache cache(&print_event_info->head_cache, file);
31663166

3167+
/**
3168+
reduce the size of io cache so that the write function is called
3169+
for every call to my_b_write().
3170+
*/
3171+
DBUG_EXECUTE_IF ("simulate_file_write_error",
3172+
{(&cache)->write_pos= (&cache)->write_end- 500;});
31673173
print_query_header(&cache, print_event_info);
31683174
my_b_write(&cache, (uchar*) query, q_len);
31693175
my_b_printf(&cache, "\n%s\n", print_event_info->delimiter);

0 commit comments

Comments
 (0)