~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/error/sql_state.cc

  • Committer: Olaf van der Spek
  • Date: 2011-03-24 00:16:14 UTC
  • mto: This revision was merged to the branch mainline in revision 2251.
  • Revision ID: olafvdspek@gmail.com-20110324001614-wvmgc6eg52oq2321
Remove const_reference and reference from Session

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
/* Functions to map drizzle errno to sql_state */
22
 
#include "config.h"
 
22
#include <config.h>
23
23
 
24
24
#include <algorithm>
25
25
 
26
 
#include <drizzled/sql_state.h>
27
26
#include <drizzled/error.h>
 
27
#include <drizzled/error/sql_state.h>
28
28
 
29
29
using namespace std;
30
30
 
31
31
namespace drizzled
32
32
{
33
33
 
34
 
typedef struct st_map_errno_to_sqlstate
35
 
{
36
 
  uint32_t drizzle_errno;
 
34
namespace error
 
35
{
 
36
 
 
37
struct sql_state_t
 
38
{
 
39
  drizzled::error_t drizzle_errno;
37
40
  const char *odbc_state;
38
41
  const char *jdbc_state;
39
 
} errno_sqlstate_map;
 
42
};
40
43
 
41
 
errno_sqlstate_map sqlstate_map[]=
 
44
sql_state_t sqlstate_map[]=
42
45
{
43
46
  { ER_DUP_KEY                              ,"23000", "" },
44
47
  { ER_OUTOFMEMORY                          ,"HY001", "S1001" },
100
103
  { ER_NULL_COLUMN_IN_INDEX                 ,"42000", "" },
101
104
  { ER_WRONG_VALUE_COUNT_ON_ROW             ,"21S01", "" },
102
105
  { ER_MIX_OF_GROUP_FUNC_AND_FIELDS         ,"42000", "" },
103
 
  { ER_NO_SUCH_TABLE                        ,"42S02", "" },
 
106
  { ER_TABLE_UNKNOWN                        ,"42S02", "" },
104
107
  { ER_SYNTAX_ERROR                         ,"42000", "" },
105
108
  { ER_NET_PACKET_TOO_LARGE                 ,"08S01", "" },
106
109
  { ER_NET_PACKETS_OUT_OF_ORDER             ,"08S01", "" },
168
171
  { ER_DUP_ENTRY_WITH_KEY_NAME              ,"23000", "S1009" },
169
172
};
170
173
 
171
 
static bool compare_errno_map(errno_sqlstate_map a,
172
 
                              errno_sqlstate_map b)
 
174
static bool compare_errno_map(sql_state_t a,
 
175
                              sql_state_t b)
173
176
{
174
177
  return (a.drizzle_errno < b.drizzle_errno);
175
178
}
176
179
 
177
 
const char *drizzle_errno_to_sqlstate(uint32_t drizzle_errno)
 
180
const char *convert_to_sqlstate(drizzled::error_t drizzle_errno)
178
181
{
179
182
 
180
 
  errno_sqlstate_map drizzle_err_state= {drizzle_errno, NULL, NULL};
181
 
  errno_sqlstate_map* result=
 
183
  sql_state_t drizzle_err_state= {drizzle_errno, NULL, NULL};
 
184
  sql_state_t* result=
182
185
    lower_bound(&sqlstate_map[0],
183
186
                &sqlstate_map[sizeof(sqlstate_map)/sizeof(*sqlstate_map)],
184
187
                drizzle_err_state, compare_errno_map);
185
188
 
186
189
  if ((*result).drizzle_errno == drizzle_errno)
187
190
    return (*result).odbc_state;
 
191
 
188
192
  /* General error */
189
193
  return "HY000";
190
 
 
191
194
}
192
195
 
 
196
} /* namespace error */
193
197
} /* namespace drizzled */