Commit d5a6fa7e authored by unknown's avatar unknown

Fixed problem with non-synchronous error lists

  in perror and handler descriptors (BUG#25177)
Fixed problem of masking mysql error by system
  error in perror (BUG#23028)


extra/perror.c:
  Used common handlers error list.
  Fixed BUG#23028 ignoring mysql error in case of
  OS and mysql error codes overlapping.
include/my_base.h:
  Added errors of maria engine.
  Fixed incorrect comment in #define (can be cause of
  seriouse problems)
include/my_handler.h:
  Added ability to be included into C++ code.
mysys/my_handler.c:
  Error texts moved to the separate files.
mysys/my_handler_errors.h:
  New BitKeeper file ``mysys/my_handler_errors.h''
parent 1d9f9abc
......@@ -13,9 +13,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Return error-text for system error messages and nisam messages */
/* Return error-text for system error messages and handler messages */
#define PERROR_VERSION "2.10"
#define PERROR_VERSION "2.11"
#include <my_global.h>
#include <my_sys.h>
......@@ -30,6 +30,9 @@
static my_bool verbose, print_all_codes;
#include "../include/my_base.h"
#include "../mysys/my_handler_errors.h"
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
static my_bool ndb_code;
static char ndb_string[1024];
......@@ -82,36 +85,6 @@ typedef struct ha_errors {
static HA_ERRORS ha_errlist[]=
{
{ 120,"Didn't find key on read or update" },
{ 121,"Duplicate key on write or update" },
{ 123,"Someone has changed the row since it was read (while the table was locked to prevent it)" },
{ 124,"Wrong index given to function" },
{ 126,"Index file is crashed" },
{ 127,"Record-file is crashed" },
{ 128,"Out of memory" },
{ 130,"Incorrect file format" },
{ 131,"Command not supported by database" },
{ 132,"Old database file" },
{ 133,"No record read before update" },
{ 134,"Record was already deleted (or record file crashed)" },
{ 135,"No more room in record file" },
{ 136,"No more room in index file" },
{ 137,"No more records (read after end of file)" },
{ 138,"Unsupported extension used for table" },
{ 139,"Too big row"},
{ 140,"Wrong create options"},
{ 141,"Duplicate unique key or constraint on write or update"},
{ 142,"Unknown character set used"},
{ 143,"Conflicting table definitions in sub-tables of MERGE table"},
{ 144,"Table is crashed and last repair failed"},
{ 145,"Table was marked as crashed and should be repaired"},
{ 146,"Lock timed out; Retry transaction"},
{ 147,"Lock table is full; Restart program with a larger locktable"},
{ 148,"Updates are not allowed under a read only transactions"},
{ 149,"Lock deadlock; Retry transaction"},
{ 150,"Foreign key constraint is incorrectly formed"},
{ 151,"Cannot add a child row"},
{ 152,"Cannot delete a parent row"},
{ -30999, "DB_INCOMPLETE: Sync didn't finish"},
{ -30998, "DB_KEYEMPTY: Key/data deleted or never created"},
{ -30997, "DB_KEYEXIST: The key/data pair already exists"},
......@@ -193,6 +166,17 @@ static const char *get_ha_error_msg(int code)
{
HA_ERRORS *ha_err_ptr;
/*
If you got compilation error here about compile_time_assert array, check
that every HA_ERR_xxx constant has a corresponding error message in
handler_error_messages[] list (check mysys/ma_handler_errors.h and
include/my_base.h).
*/
compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
HA_ERR_LAST + 1);
if (code >= HA_ERR_FIRST && code <= HA_ERR_LAST)
return handler_error_messages[code - HA_ERR_FIRST];
for (ha_err_ptr=ha_errlist ; ha_err_ptr->errcode ;ha_err_ptr++)
if (ha_err_ptr->errcode == code)
return ha_err_ptr->msg;
......@@ -210,6 +194,8 @@ int main(int argc,char *argv[])
if (get_options(&argc,&argv))
exit(1);
my_handler_error_register();
error=0;
#ifdef HAVE_SYS_ERRLIST
if (print_all_codes)
......@@ -290,29 +276,24 @@ int main(int argc,char *argv[])
(const uchar*) "Unknown Error", 13) &&
(!unknown_error || strcmp(msg, unknown_error)))
{
found=1;
found= 1;
if (verbose)
printf("OS error code %3d: %s\n",code,msg);
printf("OS error code %3d: %s\n", code, msg);
else
puts(msg);
}
if (!found)
if ((msg= get_ha_error_msg(code)))
{
/* Error message still not found, look in handler error codes */
if (!(msg=get_ha_error_msg(code)))
{
fprintf(stderr,"Illegal error code: %d\n",code);
error=1;
}
found= 1;
if (verbose)
printf("MySQL error code %3d: %s\n", code, msg);
else
{
found= 1;
if (verbose)
printf("MySQL error code %3d: %s\n",code,msg);
else
puts(msg);
}
puts(msg);
}
if (!found)
{
fprintf(stderr,"Illegal error code: %d\n", code);
error= 1;
}
}
}
......
......@@ -375,6 +375,7 @@ enum ha_base_keytype {
#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_INTERNAL_ERROR 122 /* Internal error */
#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 */
......@@ -411,8 +412,8 @@ enum ha_base_keytype {
/* NULLs are not supported in spatial index */
#define HA_ERR_NULL_IN_SPATIAL 158
#define HA_ERR_TABLE_DEF_CHANGED 159 /* The table changed in storage engine */
#define HA_ERR_NO_PARTITION_FOUND 160 /* There's no partition in table for
given value */
/* There's no partition in table for given value */
#define HA_ERR_NO_PARTITION_FOUND 160
#define HA_ERR_RBR_LOGGING_FAILED 161 /* Row-based binlogging of row failed */
#define HA_ERR_DROP_INDEX_FK 162 /* Index needed in foreign key constr */
/*
......@@ -437,7 +438,10 @@ enum ha_base_keytype {
#define HA_ERR_NEW_FILE 172 /* New file format */
#define HA_ERR_ROWS_EVENT_APPLY 173 /* The event could not be processed
no other hanlder error happened */
#define HA_ERR_LAST 173 /* Copy of last error nr */
#define HA_ERR_INITIALIZATION 174 /* Error during initialization */
#define HA_ERR_FILE_TOO_SHORT 175 /* File too short */
#define HA_ERR_WRONG_CRC 176 /* Wrong CRC on page */
#define HA_ERR_LAST 176 /* Copy of last error nr */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
......
......@@ -19,6 +19,9 @@
#define _my_handler_h
#include "myisampack.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
There is a hard limit for the maximum number of keys as there are only
......@@ -118,5 +121,8 @@ extern void my_handler_error_unregister(void);
this amount of bytes.
*/
#define portable_sizeof_char_ptr 8
#ifdef __cplusplus
}
#endif
#endif /* _my_handler_h */
......@@ -21,6 +21,8 @@
#include <my_handler.h>
#include <my_sys.h>
#include "my_handler_errors.h"
int ha_compare_text(CHARSET_INFO *charset_info, uchar *a, uint a_length,
uchar *b, uint b_length, my_bool part_key,
my_bool skip_end_space)
......@@ -565,48 +567,6 @@ HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
}
/*
Errors a handler can give you
*/
static const char *handler_error_messages[]=
{
"Didn't find key on read or update",
"Duplicate key on write or update",
"Undefined handler error 122",
"Someone has changed the row since it was read (while the table was locked to prevent it)",
"Wrong index given to function",
"Undefined handler error 125",
"Index file is crashed",
"Record file is crashed",
"Out of memory in engine",
"Undefined handler error 129",
"Incorrect file format",
"Command not supported by database",
"Old database file",
"No record read before update",
"Record was already deleted (or record file crashed)",
"No more room in record file",
"No more room in index file",
"No more records (read after end of file)",
"Unsupported extension used for table",
"Too big row",
"Wrong create options",
"Duplicate unique key or constraint on write or update",
"Unknown character set used in table",
"Conflicting table definitions in sub-tables of MERGE table",
"Table is crashed and last repair failed",
"Table was marked as crashed and should be repaired",
"Lock timed out; Retry transaction",
"Lock table is full; Restart program with a larger locktable",
"Updates are not allowed under a read only transactions",
"Lock deadlock; Retry transaction",
"Foreign key constraint is incorrectly formed",
"Cannot add a child row",
"Cannot delete a parent row",
"Unknown handler error"
};
/*
Register handler error messages for usage with my_error()
......@@ -619,6 +579,14 @@ static const char *handler_error_messages[]=
void my_handler_error_register(void)
{
/*
If you got compilation error here about compile_time_assert array, check
that every HA_ERR_xxx constant has a corresponding error message in
handler_error_messages[] list (check mysys/ma_handler_errors.h and
include/my_base.h).
*/
compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
HA_ERR_LAST + 1);
my_error_register(handler_error_messages, HA_ERR_FIRST,
HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
}
......
/*
Errors a handler can give you
*/
static const char *handler_error_messages[]=
{
"Didn't find key on read or update",
"Duplicate key on write or update",
"Internal (unspecified) error in handler",
"Someone has changed the row since it was read (while the table was locked to prevent it)",
"Wrong index given to function",
"Undefined handler error 125",
"Index file is crashed",
"Record file is crashed",
"Out of memory in engine",
"Undefined handler error 129",
"Incorrect file format",
"Command not supported by database",
"Old database file",
"No record read before update",
"Record was already deleted (or record file crashed)",
"No more room in record file",
"No more room in index file",
"No more records (read after end of file)",
"Unsupported extension used for table",
"Too big row",
"Wrong create options",
"Duplicate unique key or constraint on write or update",
"Unknown character set used in table",
"Conflicting table definitions in sub-tables of MERGE table",
"Table is crashed and last repair failed",
"Table was marked as crashed and should be repaired",
"Lock timed out; Retry transaction",
"Lock table is full; Restart program with a larger locktable",
"Updates are not allowed under a read only transactions",
"Lock deadlock; Retry transaction",
"Foreign key constraint is incorrectly formed",
"Cannot add a child row",
"Cannot delete a parent row",
"No savepoint with that name",
"Non unique key block size",
"The table does not exist in engine",
"The table already existed in storage engine",
"Could not connect to storage engine",
"Unexpected null pointer found when using spatial index",
"The table changed in storage engine",
"There's no partition in table for the given value",
"Row-based binlogging of row failed",
"Index needed in foreign key constraint",
"Upholding foreign key constraints would lead to a duplicate key error in "
"some other table",
"Table needs to be upgraded before it can be used",
"Table is read only",
"Failed to get next auto increment value",
"Failed to set row auto increment value",
"Unknown (generic) error from engine",
"Record is the same",
"It is not possible to log this statement",
"The event was corrupt, leading to illegal data being read",
"The table is of a new format not supported by this version",
"The event could not be processed no other hanlder error happened",
"Got a fatal error during initialzaction of handler",
"File to short; Expected more data in file",
"Read page with wrong checksum"
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment