~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/myisam/my_handler_errors.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

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