~drizzle-trunk/drizzle/development

547 by Monty Taylor
Moved handler_error_messages array out of header file. Moved associated
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
#include <drizzled/base.h>
548 by Monty Taylor
Moved my_handler to myisam, which is where it actually belongs.
21
#include <storage/myisam/my_handler.h>
547 by Monty Taylor
Moved handler_error_messages array out of header file. Moved associated
22
538 by Monty Taylor
Moved gettext.h into drizzled in anticipation of the new client lib.
23
#include <drizzled/gettext.h>
1 by brian
clean slate
24
25
/*
26
  Errors a handler can give you
27
*/
28
29
static const char *handler_error_messages[]=
30
{
31
  /* HA_ERR_KEY_NOT_FOUND */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
32
  N_("Didn't find key on read or update"),
1 by brian
clean slate
33
  /* HA_ERR_FOUND_DUPP_KEY */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
34
  N_("Duplicate key on write or update"),
1 by brian
clean slate
35
  /* HA_ERR_INTERNAL_ERROR */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
36
  N_("Internal (unspecified) error in handler"),
1 by brian
clean slate
37
  /* HA_ERR_RECORD_CHANGED */
547 by Monty Taylor
Moved handler_error_messages array out of header file. Moved associated
38
  N_("Someone has changed the row since it was read (while the table "
39
     "was locked to prevent it)"),
1 by brian
clean slate
40
  /* HA_ERR_WRONG_INDEX */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
41
  N_("Wrong index given to function"),
1 by brian
clean slate
42
  /* empty */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
43
  N_("Undefined handler error 125"),
1 by brian
clean slate
44
  /* HA_ERR_CRASHED */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
45
  N_("Index file is crashed"),
1 by brian
clean slate
46
  /* HA_ERR_WRONG_IN_RECORD */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
47
  N_("Record file is crashed"),
1 by brian
clean slate
48
  /* HA_ERR_OUT_OF_MEM */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
49
  N_("Out of memory in engine"),
1 by brian
clean slate
50
  /* empty */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
51
  N_("Undefined handler error 129"),
1 by brian
clean slate
52
  /* HA_ERR_NOT_A_TABLE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
53
  N_("Incorrect file format"),
1 by brian
clean slate
54
  /* HA_ERR_WRONG_COMMAND */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
55
  N_("Command not supported by database"),
1 by brian
clean slate
56
  /* HA_ERR_OLD_FILE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
57
  N_("Old database file"),
1 by brian
clean slate
58
  /* HA_ERR_NO_ACTIVE_RECORD */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
59
  N_("No record read before update"),
1 by brian
clean slate
60
  /* HA_ERR_RECORD_DELETED */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
61
  N_("Record was already deleted (or record file crashed)"),
1 by brian
clean slate
62
  /* HA_ERR_RECORD_FILE_FULL */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
63
  N_("No more room in record file"),
1 by brian
clean slate
64
  /* HA_ERR_INDEX_FILE_FULL */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
65
  N_("No more room in index file"),
1 by brian
clean slate
66
  /* HA_ERR_END_OF_FILE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
67
  N_("No more records (read after end of file)"),
1 by brian
clean slate
68
  /* HA_ERR_UNSUPPORTED */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
69
  N_("Unsupported extension used for table"),
1 by brian
clean slate
70
  /* HA_ERR_TO_BIG_ROW */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
71
  N_("Too big row"),
1 by brian
clean slate
72
  /* HA_WRONG_CREATE_OPTION */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
73
  N_("Wrong create options"),
1 by brian
clean slate
74
  /* HA_ERR_FOUND_DUPP_UNIQUE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
75
  N_("Duplicate unique key or constraint on write or update"),
1 by brian
clean slate
76
  /* HA_ERR_UNKNOWN_CHARSET */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
77
  N_("Unknown character set used in table"),
1 by brian
clean slate
78
  /* HA_ERR_WRONG_MRG_TABLE_DEF */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
79
  N_("Conflicting table definitions in sub-tables of MERGE table"),
1 by brian
clean slate
80
  /* HA_ERR_CRASHED_ON_REPAIR */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
81
  N_("Table is crashed and last repair failed"),
1 by brian
clean slate
82
  /* HA_ERR_CRASHED_ON_USAGE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
83
  N_("Table was marked as crashed and should be repaired"),
1 by brian
clean slate
84
  /* HA_ERR_LOCK_WAIT_TIMEOUT */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
85
  N_("Lock timed out; Retry transaction"),
1 by brian
clean slate
86
  /* HA_ERR_LOCK_TABLE_FULL */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
87
  N_("Lock table is full;  Restart program with a larger locktable"),
1 by brian
clean slate
88
  /* HA_ERR_READ_ONLY_TRANSACTION */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
89
  N_("Updates are not allowed under a read only transactions"),
1 by brian
clean slate
90
  /* HA_ERR_LOCK_DEADLOCK */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
91
  N_("Lock deadlock; Retry transaction"),
1 by brian
clean slate
92
  /* HA_ERR_CANNOT_ADD_FOREIGN */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
93
  N_("Foreign key constraint is incorrectly formed"),
1 by brian
clean slate
94
  /* HA_ERR_NO_REFERENCED_ROW */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
95
  N_("Cannot add a child row"),
1 by brian
clean slate
96
  /* HA_ERR_ROW_IS_REFERENCED */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
97
  N_("Cannot delete a parent row"),
1 by brian
clean slate
98
  /* HA_ERR_NO_SAVEPOINT */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
99
  N_("No savepoint with that name"),
1 by brian
clean slate
100
  /* HA_ERR_NON_UNIQUE_BLOCK_SIZE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
101
  N_("Non unique key block size"),
1 by brian
clean slate
102
  /* HA_ERR_NO_SUCH_TABLE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
103
  N_("The table does not exist in engine"),
1 by brian
clean slate
104
  /* HA_ERR_TABLE_EXIST */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
105
  N_("The table already existed in storage engine"),
1 by brian
clean slate
106
  /* HA_ERR_NO_CONNECTION */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
107
  N_("Could not connect to storage engine"),
1 by brian
clean slate
108
  /* HA_ERR_NULL_IN_SPATIAL */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
109
  N_("Unexpected null pointer found when using spatial index"),
1 by brian
clean slate
110
  /* HA_ERR_TABLE_DEF_CHANGED */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
111
  N_("The table changed in storage engine"),
1 by brian
clean slate
112
  /* HA_ERR_NO_PARTITION_FOUND */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
113
  N_("There's no partition in table for the given value"),
1 by brian
clean slate
114
  /* HA_ERR_RBR_LOGGING_FAILED */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
115
  N_("Row-based binlogging of row failed"),
1 by brian
clean slate
116
  /* HA_ERR_DROP_INDEX_FK */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
117
  N_("Index needed in foreign key constraint"),
1 by brian
clean slate
118
  /* HA_ERR_FOREIGN_DUPLICATE_KEY */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
119
  N_("Upholding foreign key constraints would lead to a duplicate key error"),
1 by brian
clean slate
120
  /* HA_ERR_TABLE_NEEDS_UPGRADE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
121
  N_("Table needs to be upgraded before it can be used"),
1 by brian
clean slate
122
  /* HA_ERR_TABLE_READONLY */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
123
  N_("Table is read only"),
1 by brian
clean slate
124
  /* HA_ERR_AUTOINC_READ_FAILED */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
125
  N_("Failed to get next auto increment value"),
1 by brian
clean slate
126
  /* HA_ERR_AUTOINC_ERANGE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
127
  N_("Failed to set row auto increment value"),
1 by brian
clean slate
128
  /* HA_ERR_GENERIC */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
129
  N_("Unknown (generic) error from engine"),
1 by brian
clean slate
130
  /* HA_ERR_RECORD_IS_THE_SAME */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
131
  N_("Record is the same"),
1 by brian
clean slate
132
  /* HA_ERR_LOGGING_IMPOSSIBLE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
133
  N_("It is not possible to log this statement"),
1 by brian
clean slate
134
  /* HA_ERR_TABLESPACE_EXIST */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
135
  N_("Tablespace exists"),
1 by brian
clean slate
136
  /* HA_ERR_CORRUPT_EVENT */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
137
  N_("The event was corrupt, leading to illegal data being read"),
1 by brian
clean slate
138
  /* HA_ERR_NEW_FILE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
139
  N_("The table is of a new format not supported by this version"),
1 by brian
clean slate
140
  /* HA_ERR_ROWS_EVENT_APPLY */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
141
  N_("The event could not be processed no other hanlder error happened"),
1 by brian
clean slate
142
  /* HA_ERR_INITIALIZATION */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
143
  N_("Got a fatal error during initialzaction of handler"),
1 by brian
clean slate
144
  /* HA_ERR_FILE_TOO_SHORT */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
145
  N_("File to short; Expected more data in file"),
1 by brian
clean slate
146
  /* HA_ERR_WRONG_CRC */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
147
  N_("Read page with wrong checksum"),
1 by brian
clean slate
148
  /* HA_ERR_LOCK_OR_ACTIVE_TRANSACTION */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
149
  N_("Lock or active transaction"), /* TODO: get a better message */
1 by brian
clean slate
150
  /* HA_ERR_NO_SUCH_TABLESPACE */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
151
  N_("No such table space"), /* TODO: get a better message */
1 by brian
clean slate
152
  /* HA_ERR_TABLESPACE_NOT_EMPTY */
261.3.5 by Monty Taylor
Changed gettext_noop() to N_()
153
  N_("Tablespace not empty") /* TODO: get a better message */
1 by brian
clean slate
154
};
155
547 by Monty Taylor
Moved handler_error_messages array out of header file. Moved associated
156
157
/*
158
  Register handler error messages for usage with my_error()
159
160
  NOTES
161
    This is safe to call multiple times as my_error_register()
162
    will ignore calls to register already registered error numbers.
163
*/
164
165
166
void my_handler_error_register(void)
167
{
168
  /*
169
    If you got compilation error here about compile_time_assert array, check
170
    that every HA_ERR_xxx constant has a corresponding error message in
171
    handler_error_messages[] list (check mysys/ma_handler_errors.h and
172
    include/my_base.h).
173
174
    TODO: Remove fix the handler_error_messages so that this hack isn't 
175
          necessary.
176
  */
177
#ifdef __GNUC__
178
  char compile_time_assert[(HA_ERR_FIRST +
179
                            array_elements(handler_error_messages) ==
180
                            HA_ERR_LAST + 1) ? 1 : -1]
181
    __attribute__ ((__unused__));
182
#endif
183
  my_error_register(handler_error_messages, HA_ERR_FIRST,
184
                    HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
185
}
186
187
188
void my_handler_error_unregister(void)
189
{
190
  my_error_unregister(HA_ERR_FIRST,
191
                      HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
192
}