On 12/11/06, Sergei Golubchik <serg@stripped> wrote:
>
> 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 ?
I don't think that any of the existing HA_ERR* values represent a generic
error. The values for 5.0 follow.
#define HA_ERR_FIRST 120 /*Copy first error nr.*/
#define HA_ERR_KEY_NOT_FOUND 120 /* Didn't find key on read or update
*/
#define HA_ERR_FOUND_DUPP_KEY 121 /* Dupplicate key on write */
#define HA_ERR_RECORD_CHANGED 123 /* Uppdate with is recoverable */
#define HA_ERR_WRONG_INDEX 124 /* Wrong index given to function */
#define HA_ERR_CRASHED 126 /* Indexfile is crashed */
#define HA_ERR_WRONG_IN_RECORD 127 /* Record-file is crashed */
#define HA_ERR_OUT_OF_MEM 128 /* Record-file is crashed */
#define HA_ERR_NOT_A_TABLE 130 /* not a MYI file - no signature */
#define HA_ERR_WRONG_COMMAND 131 /* Command not supported */
#define HA_ERR_OLD_FILE 132 /* old databasfile */
#define HA_ERR_NO_ACTIVE_RECORD 133 /* No record read in update() */
#define HA_ERR_RECORD_DELETED 134 /* Intern error-code */
#define HA_ERR_RECORD_FILE_FULL 135 /* No more room in file */
#define HA_ERR_INDEX_FILE_FULL 136 /* No more room in file */
#define HA_ERR_END_OF_FILE 137 /* end in next/prev/first/last */
#define HA_ERR_UNSUPPORTED 138 /* unsupported extension used */
#define HA_ERR_TO_BIG_ROW 139 /* Too big row */
#define HA_WRONG_CREATE_OPTION 140 /* Wrong create option */
#define HA_ERR_FOUND_DUPP_UNIQUE 141 /* Dupplicate unique on write */
#define HA_ERR_UNKNOWN_CHARSET 142 /* Can't open charset */
#define HA_ERR_WRONG_MRG_TABLE_DEF 143 /* conflicting MyISAM tables in
MERGE */
#define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed
*/
#define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */
#define HA_ERR_LOCK_WAIT_TIMEOUT 146
#define HA_ERR_LOCK_TABLE_FULL 147
#define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */
#define HA_ERR_LOCK_DEADLOCK 149
#define HA_ERR_CANNOT_ADD_FOREIGN 150 /* Cannot add a foreign key constr.
*/
#define HA_ERR_NO_REFERENCED_ROW 151 /* Cannot add a child row */
#define HA_ERR_ROW_IS_REFERENCED 152 /* Cannot delete a parent row */
#define HA_ERR_NO_SAVEPOINT 153 /* No savepoint with that name */
#define HA_ERR_NON_UNIQUE_BLOCK_SIZE 154 /* Non unique key block size */
#define HA_ERR_NO_SUCH_TABLE 155 /* The table does not exist in engine
*/
#define HA_ERR_TABLE_EXIST 156 /* The table existed in storage engine
*/
#define HA_ERR_NO_CONNECTION 157 /* Could not connect to storage engine
*/
#define HA_ERR_NULL_IN_SPATIAL 158 /* NULLs are not supported in spatial
index */
#define HA_ERR_TABLE_DEF_CHANGED 159 /* The table changed in storage engine
*/
#define HA_ERR_TABLE_NEEDS_UPGRADE 160 /* The table changed in storage
engine */
#define HA_ERR_TABLE_READONLY 161 /* The table is not writable */
#define HA_ERR_AUTOINC_READ_FAILED 162/* Failed to get the next autoinc
value */
#define HA_ERR_AUTOINC_ERANGE 163 /* Failed to set the row autoinc value
*/
#define HA_ERR_LAST 163 /*Copy last error nr.*/
Regards,
> Sergei
>
> --
> __ ___ ___ ____ __
> / |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Senior Software Developer
> /_/ /_/\_, /___/\___\_\___/ Kerpen, Germany
> <___/ www.mysql.com
>
--
Mark Callaghan
mcallaghan@stripped