-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMysqlState.cpp
More file actions
66 lines (59 loc) · 1.4 KB
/
CMysqlState.cpp
File metadata and controls
66 lines (59 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "CMysqlState.h"
CMysqlState::StObErrorStringMap CMysqlState::maps_[C_MAX_ERROR_CODE] = {};
const CMysqlState CMysqlState::instance_;
CMysqlState::CMysqlState()
{
#include "CMysqlState.map"
}
void CMysqlState::C_ADD_SQLSTATE(int oberr, const char *jdbc_state, const char *odbc_state)
{
if (oberr <= 0)
{
maps_[-oberr].jdbc_state = jdbc_state;
maps_[-oberr].odbc_state = odbc_state;
}
}
const char *CMysqlState::get_odbc_state(int oberr) const
{
const char *state = "S1000";
const char *state_succ = "00000";
if (oberr <= 0)
{
if (oberr == C_SUCCESS)
{
state = state_succ;
}
else if ((-oberr) >= C_MAX_ERROR_CODE)
{
//Logs::log
LOG("oceanbase error code out of range, err=[%d]", oberr);
}
else if (NULL != maps_[-oberr].odbc_state && maps_[-oberr].odbc_state[0] != '\0')
{
state = maps_[-oberr].odbc_state;
}
}
return state;
}
const char *CMysqlState::get_jdbc_state(int oberr) const
{
const char *state = "HY000";
const char *state_succ = "00000";
if (oberr <= 0)
{
if (oberr == C_SUCCESS)
{
state = state_succ;
}
else if ((-oberr) >= C_MAX_ERROR_CODE)
{
//Logs::log
LOG("oceanbase error code out of range, err=[%d]", oberr);
}
else if (NULL != maps_[-oberr].jdbc_state && maps_[-oberr].jdbc_state[0] != '\0')
{
state = maps_[-oberr].jdbc_state;
}
}
return state;
}