Bug #22222 stream buffers not always flushed
Submitted: 10 Sep 2006 9:12 Modified: 5 Dec 2007 18:55
Reporter: Georg Richter Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.0, 4.1, 5.0, 5.1 OS:Windows (Windows)
Assigned to: Assigned Account CPU Architecture:Any
Tags: wtf

[10 Sep 2006 9:12] Georg Richter
When a windows program crashes or stops (assert) Windows doesn't flush the buffer.
So often error log doesn't contain all information.

From MSDN docu:

Files opened using the stream routines are buffered by default. The stdout and stderr functions are flushed whenever they are full or, if you are writing to a character device, after each library call. If a program terminates abnormally, output buffers may not be flushed, resulting in loss of data. Use fflush or _flushall to ensure that the buffer associated with a specified file or all open buffers are flushed to the operating system, which can cache data before writing it to disk. The commit-to-disk feature ensures that the flushed buffer contents are not lost in the event of a system failure.

How to repeat:

Suggested fix:
Add fflush(stderr) or provide an own error handling function
[11 Sep 2006 10:35] Valeriy Kravchuk
Thank you for a bug report. Verified just as described. take a look at the code, and you'll find error reoprting perfoormed in the following way (quote is from mysqladmin.cc):

    if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
      fprintf(stderr, "Unknown option to protocol: %s\n", argument);

So, fflush() should be added (in case of Windows, at least).