List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:December 12 2006 5:12am
Subject:Re: Request for guidelines on return values from handler.h methods
View as plain text  
Hi!

On Dec 11, Mark Callaghan wrote:

> Are there guidelines on how methods in handler.h should indicate
> errors?  handler.h in 5.1 is a little better about this than 4.0
> because there are default implementation for many of the methods that
> distinguish between those that use HA_ADMIN* values and those that use
> HA_ERR* values. But the rules are frequently broken and difficult to
> infer from the various handler implementations. ha_innodb.cc usually
> returns and HA_ERR* value but occasionally returns -1 or +1.
> ha_berkeley.cc is similar.
> 
> So, my questions are:
> 1) excluding the admin methods that return HA_ADMIN, what should be
> returned on error (always an HA_ERR* value, -1, +1)?

Without examining all methods one by one, I'd recommend to return
HA_ERR* in all cases; obviously excluding methods that are supposed to
return a meaningful number like min_record_length() or
records_in_range().

> 2) should my_errno always be set before returning an error?

Preferrably, yes

> 3) can a generic error tag be added to HA_ERR* so that neither -1 nor
> +1 are used?

Are HA_ERR* constants good enough ?

Regards,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  MySQL AB, Senior Software Developer
/_/  /_/\_, /___/\___\_\___/  Kerpen, Germany
       <___/  www.mysql.com
Thread
Request for guidelines on return values from handler.h methodsMark Callaghan12 Dec
  • Re: Request for guidelines on return values from handler.h methodsSergei Golubchik12 Dec
    • Re: Request for guidelines on return values from handler.h methodsMark Callaghan12 Dec
      • Re: Request for guidelines on return values from handler.h methodsSergei Golubchik20 Dec
        • Re: Request for guidelines on return values from handler.h methodsSergei Golubchik30 Jan