drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
wt_to_drizzle_error.cc
1#include <config.h>
2#include <drizzled/error.h>
3#include "wt_to_drizzle_error.h"
4#include <wiredtiger.h>
5#include <cerrno>
6
7using namespace drizzled;
8
9int wt_to_drizzle_error(int wt_error)
10{
11 switch (wt_error)
12 {
13 case 0:
14 return 0;
15 case WT_DEADLOCK:
16 return HA_ERR_LOCK_DEADLOCK;
17 case WT_DUPLICATE_KEY:
18 return HA_ERR_FOUND_DUPP_KEY;
19 case WT_ERROR:
20 return -1;
21 case WT_NOTFOUND:
22 return HA_ERR_NO_ACTIVE_RECORD;
23 case WT_PANIC:
24 return HA_ERR_CRASHED;
25 case WT_RESTART: /* Should never happen, is WT internal */
26 break;
27
28 /* WiredTiger requires exclusive data-handle access for schema
29 operations (drop, rename) and returns EBUSY when cursors are
30 still open on the object. Surface that as a lock-wait failure
31 the user can retry, not as a generic -1 (which the SQL layer
32 reports as "Unknown table"). */
33 case EBUSY:
34 return HA_ERR_LOCK_WAIT_TIMEOUT;
35
36 /* WiredTiger can also return POSIX errors,
37 let's try to handle things gracefully */
38 default:
39 return -1;
40 }
41
42 return wt_error;
43}
TODO: Rename this file - func.h is stupid.