Bug #46480 Return values for mysys file API are obscure and undocumented
Submitted: 30 Jul 2009 16:23 Modified: 17 Sep 2009 13:38
Reporter: Marc ALFF Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: General Severity:S1 (Critical)
Version:5.1.38-bzr, mysql-azalea (5.4) OS:Any
Assigned to: Marc ALFF CPU Architecture:Any

[30 Jul 2009 16:23] Marc ALFF
Description:
The documentation (in the source code) for the following API states:

my_fread
========

  RETURN
    (size_t) -1 Error
    #           Number of bytes read

This is wrong.

my_fwrite
=========

  RETURN
    (size_t) -1 Error
    #           Number of bytes written

This is wrong.

my_write
========

There is no documentation at all,
and the return value is non trivial.

This is wrong.

my_pread
========

  RETURN
    (size_t) -1   Error
    #             Number of bytes read

This is wrong.

my_pwrite
=========

  RETURN
    (size_t) -1   Error
    #             Number of bytes read

This is wrong.

Entered as a severity 1 bug, as this cause too much confusion and is a source of bugs. The return value of these api is in fact arcane, and not what a C developper would expect.

Found in 5.4, but most likely exists in all releases.

How to repeat:
Read the code, read the comments.
[30 Jul 2009 17:19] Valeriy Kravchuk
Thank you for the problem report. Verified by code review. I'd at least document what 0 result should mean...

Same problem with 5.1, although only my_fread and my_fwrite are defined there from functions mentioned here.
[17 Sep 2009 13:38] Konstantin Osipov
Marc, you should really fix it in the performance schema code, since you touch it.
The rule at MySQL -- you touch it - you become responsible for it.
Meanwhile, please don't waste the time of the verification team, triage, Serg, Joro, Davi and me.
Thus, closing as won't fix.
Please reopen if you're ready to fix the bug yourself. I will be glad to review the fix when it comes.