~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to extra/perror.c

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
/* Return error-text for system error messages and nisam messages */
 
16
/* Return error-text for system error messages and handler messages */
17
17
 
18
 
#define PERROR_VERSION "2.10"
 
18
#define PERROR_VERSION "2.11"
19
19
 
20
20
#include <my_global.h>
21
21
#include <my_sys.h>
30
30
 
31
31
static my_bool verbose, print_all_codes;
32
32
 
 
33
#include "../include/my_base.h"
 
34
#include "../mysys/my_handler_errors.h"
 
35
#include "../include/my_handler.h"
 
36
 
33
37
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
34
38
static my_bool ndb_code;
35
39
static char ndb_string[1024];
82
86
 
83
87
static HA_ERRORS ha_errlist[]=
84
88
{
85
 
  { 120,"Didn't find key on read or update" },
86
 
  { 121,"Duplicate key on write or update" },
87
 
  { 123,"Someone has changed the row since it was read (while the table was locked to prevent it)" },
88
 
  { 124,"Wrong index given to function" },
89
 
  { 126,"Index file is crashed" },
90
 
  { 127,"Record-file is crashed" },
91
 
  { 128,"Out of memory" },
92
 
  { 130,"Incorrect file format" },
93
 
  { 131,"Command not supported by database" },
94
 
  { 132,"Old database file" },
95
 
  { 133,"No record read before update" },
96
 
  { 134,"Record was already deleted (or record file crashed)" },
97
 
  { 135,"No more room in record file" },
98
 
  { 136,"No more room in index file" },
99
 
  { 137,"No more records (read after end of file)" },
100
 
  { 138,"Unsupported extension used for table" },
101
 
  { 139,"Too big row"},
102
 
  { 140,"Wrong create options"},
103
 
  { 141,"Duplicate unique key or constraint on write or update"},
104
 
  { 142,"Unknown character set used"},
105
 
  { 143,"Conflicting table definitions in sub-tables of MERGE table"},
106
 
  { 144,"Table is crashed and last repair failed"},
107
 
  { 145,"Table was marked as crashed and should be repaired"},
108
 
  { 146,"Lock timed out; Retry transaction"},
109
 
  { 147,"Lock table is full;  Restart program with a larger locktable"},
110
 
  { 148,"Updates are not allowed under a read only transactions"},
111
 
  { 149,"Lock deadlock; Retry transaction"},
112
 
  { 150,"Foreign key constraint is incorrectly formed"},
113
 
  { 151,"Cannot add a child row"},
114
 
  { 152,"Cannot delete a parent row"},
115
89
  { -30999, "DB_INCOMPLETE: Sync didn't finish"},
116
90
  { -30998, "DB_KEYEMPTY: Key/data deleted or never created"},
117
91
  { -30997, "DB_KEYEXIST: The key/data pair already exists"},
193
167
{
194
168
  HA_ERRORS *ha_err_ptr;
195
169
 
 
170
  /*
 
171
    If you got compilation error here about compile_time_assert array, check
 
172
    that every HA_ERR_xxx constant has a corresponding error message in
 
173
    handler_error_messages[] list (check mysys/ma_handler_errors.h and
 
174
    include/my_base.h).
 
175
  */
 
176
  compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
 
177
                      HA_ERR_LAST + 1);
 
178
  if (code >= HA_ERR_FIRST && code <= HA_ERR_LAST)
 
179
    return handler_error_messages[code - HA_ERR_FIRST];
 
180
 
196
181
  for (ha_err_ptr=ha_errlist ; ha_err_ptr->errcode ;ha_err_ptr++)
197
182
    if (ha_err_ptr->errcode == code)
198
183
      return ha_err_ptr->msg;
210
195
  if (get_options(&argc,&argv))
211
196
    exit(1);
212
197
 
 
198
  my_handler_error_register();
 
199
 
213
200
  error=0;
214
201
#ifdef HAVE_SYS_ERRLIST
215
202
  if (print_all_codes)
290
277
                       (const uchar*) "Unknown Error", 13) &&
291
278
          (!unknown_error || strcmp(msg, unknown_error)))
292
279
      {
293
 
        found=1;
 
280
        found= 1;
294
281
        if (verbose)
295
 
          printf("OS error code %3d:  %s\n",code,msg);
 
282
          printf("OS error code %3d:  %s\n", code, msg);
296
283
        else
297
284
          puts(msg);
298
285
      }
299
 
 
 
286
      if ((msg= get_ha_error_msg(code)))
 
287
      {
 
288
        found= 1;
 
289
        if (verbose)
 
290
          printf("MySQL error code %3d: %s\n", code, msg);
 
291
        else
 
292
          puts(msg);
 
293
      }
300
294
      if (!found)
301
295
      {
302
 
        /* Error message still not found, look in handler error codes */
303
 
        if (!(msg=get_ha_error_msg(code)))
304
 
        {
305
 
          fprintf(stderr,"Illegal error code: %d\n",code);
306
 
          error=1;
307
 
        }
308
 
        else
309
 
        {
310
 
          found= 1;
311
 
          if (verbose)
312
 
            printf("MySQL error code %3d: %s\n",code,msg);
313
 
          else
314
 
            puts(msg);
315
 
        }
 
296
        fprintf(stderr,"Illegal error code: %d\n", code);
 
297
        error= 1;
316
298
      }
317
299
    }
318
300
  }