1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2003 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
/* Functions to map mysqld errno to sql_state */
|
|
243.1.17
by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.) |
17 |
#include <drizzled/global.h> |
212.5.42
by Monty Taylor
Ding dong include is dead. |
18 |
#include <drizzled/error.h> |
383.1.44
by Monty Taylor
Renamed drizzle.h to libdrizzle.h. |
19 |
#include <libdrizzle/libdrizzle.h> |
212.5.42
by Monty Taylor
Ding dong include is dead. |
20 |
#include "sql_state.h" |
1
by brian
clean slate |
21 |
|
261.4.1
by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR. |
22 |
const char *drizzle_errno_to_sqlstate(uint mysql_errno) |
1
by brian
clean slate |
23 |
{
|
24 |
uint first=0, end= array_elements(sqlstate_map)-1; |
|
25 |
struct st_map_errno_to_sqlstate *map; |
|
26 |
||
27 |
/* Do binary search in the sorted array */
|
|
28 |
while (first != end) |
|
29 |
{
|
|
30 |
uint mid= (first+end)/2; |
|
31 |
map= sqlstate_map+mid; |
|
32 |
if (map->mysql_errno < mysql_errno) |
|
33 |
first= mid+1; |
|
34 |
else
|
|
35 |
end= mid; |
|
36 |
}
|
|
37 |
map= sqlstate_map+first; |
|
38 |
if (map->mysql_errno == mysql_errno) |
|
39 |
return map->odbc_state; |
|
40 |
return "HY000"; /* General error */ |
|
41 |
}
|