feat(ob_error): add ob_error tool (#192)
This commit is contained in:
parent
b20901e8c8
commit
a6d5591ddf
@ -29,6 +29,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
add_subdirectory(deps/easy)
|
||||
add_subdirectory(deps/oblib)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tools)
|
||||
|
||||
include(CMakeDependentOption)
|
||||
# OB_BUILD_RPM => include tools and build them.
|
||||
|
@ -20,16 +20,38 @@ my $def_ora_errno=600;
|
||||
my $def_ora_errmsg="\"internal error code, arguments: %d, %s\"";
|
||||
my $print_def_ora_errmsg="\"%s-%05d: internal error code, arguments: %d, %s\"";
|
||||
my $print_ora_errmsg="\"%s-%05d: %s\"";
|
||||
my $print_error_cause="\"Internal Error\"";
|
||||
my $print_error_solution="\"Contact OceanBase Support\"";
|
||||
|
||||
while(<$fh>) {
|
||||
my $error_msg;
|
||||
my $sqlstate;
|
||||
my $error_code;
|
||||
|
||||
if (/^DEFINE_ERROR\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")/) {
|
||||
if (/^DEFINE_ERROR\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6, $7\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_def_ora_errmsg, "ORA", $def_ora_errno, $2, substr($5, 1, length($5) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $5, "$1", $def_ora_errno, $tmp_ora_errmsg, $tmp_ora_errmsg, $6, $7];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
$error_msg = $5;
|
||||
} elsif (/^DEFINE_ERROR\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2, $3, $4, $5\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_def_ora_errmsg, "ORA", $def_ora_errno, $2, substr($5, 1, length($5) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $5, "$1", $def_ora_errno, $tmp_ora_errmsg, $tmp_ora_errmsg];
|
||||
$map{$1} = [$2, $3, $4, $5, $5, "$1", $def_ora_errno, $tmp_ora_errmsg, $tmp_ora_errmsg, $print_error_cause, $print_error_solution];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
$error_msg = $5;
|
||||
} elsif (/^DEFINE_ERROR_EXT\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6, $7, $8\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_def_ora_errmsg, "ORA", $def_ora_errno, $2, substr($5, 1, length($5) - 2));
|
||||
my $tmp_ora_user_errmsg=sprintf($print_def_ora_errmsg, "ORA", $def_ora_errno, $2, substr($6, 1, length($6) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $def_ora_errno, $tmp_ora_errmsg, $tmp_ora_user_errmsg, $7, $8];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
@ -39,7 +61,16 @@ while(<$fh>) {
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_def_ora_errmsg, "ORA", $def_ora_errno, $2, substr($5, 1, length($5) - 2));
|
||||
my $tmp_ora_user_errmsg=sprintf($print_def_ora_errmsg, "ORA", $def_ora_errno, $2, substr($6, 1, length($6) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $def_ora_errno, $tmp_ora_errmsg, $tmp_ora_user_errmsg];
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $def_ora_errno, $tmp_ora_errmsg, $tmp_ora_user_errmsg, $print_error_cause, $print_error_solution];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
$error_msg = $5;
|
||||
} elsif (/^DEFINE_ORACLE_ERROR\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")\s*,\s*([^,]*),\s*("[^"]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6, $7, $8, $9\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_ora_errmsg, "ORA", $6, substr($7, 1, length($7) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $5, "$1", $6, $tmp_ora_errmsg, $tmp_ora_errmsg, $8, $9];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
@ -49,7 +80,17 @@ while(<$fh>) {
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6, $7\n";
|
||||
#print "\"$1\", $6, $7\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_ora_errmsg, "ORA", $6, substr($7, 1, length($7) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $5, "$1", $6, $tmp_ora_errmsg, $tmp_ora_errmsg];
|
||||
$map{$1} = [$2, $3, $4, $5, $5, "$1", $6, $tmp_ora_errmsg, $tmp_ora_errmsg, $print_error_cause, $print_error_solution];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
$error_msg = $5;
|
||||
} elsif (/^DEFINE_ORACLE_ERROR_EXT\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")\s*,\s*("[^"]*")\s*,\s*([^,]*),\s*("[^"]*")\s*,\s*("[^"]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_ora_errmsg, "ORA", $7, substr($8, 1, length($8) - 2));
|
||||
my $tmp_ora_user_errmsg=sprintf($print_ora_errmsg, "ORA", $7, substr($9, 1, length($9) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $7, $tmp_ora_errmsg, $tmp_ora_user_errmsg, $10, $11];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
@ -60,20 +101,36 @@ while(<$fh>) {
|
||||
#print "\"$1\", $7, $8, $9\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_ora_errmsg, "ORA", $7, substr($8, 1, length($8) - 2));
|
||||
my $tmp_ora_user_errmsg=sprintf($print_ora_errmsg, "ORA", $7, substr($9, 1, length($9) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $7, $tmp_ora_errmsg, $tmp_ora_user_errmsg];
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $7, $tmp_ora_errmsg, $tmp_ora_user_errmsg, $print_error_cause, $print_error_solution];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
$error_msg = $5;
|
||||
} elsif (/^DEFINE_PLS_ERROR\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")\s*,\s*([^,]*),\s*("[^"]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6, $7, $8, $9\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_ora_errmsg, "PLS", $6, substr($7, 1, length($7) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $5, "$1", $6, $tmp_ora_errmsg, $tmp_ora_errmsg, $8, $9];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
$error_msg = $5;
|
||||
} elsif (/^DEFINE_OTHER_MSG_FMT\(([^,]+),\s*([^,]*),\s*("[^"]*")\s*,\s*("[^"]*")/) {
|
||||
#print "\"$1\", $1, $2, $3, $4\n";
|
||||
$other_map{$1} = [$2, $3, $4];
|
||||
} elsif (/^DEFINE_PLS_ERROR\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")\s*,\s*([^,]*),\s*("[^"]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6, $7\n";
|
||||
#print "\"$1\", $6, $7\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_ora_errmsg, "PLS", $6, substr($7, 1, length($7) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $5, "$1", $6, $tmp_ora_errmsg, $tmp_ora_errmsg];
|
||||
$map{$1} = [$2, $3, $4, $5, $5, "$1", $6, $tmp_ora_errmsg, $tmp_ora_errmsg, $print_error_cause, $print_error_solution];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
$error_msg = $5;
|
||||
} elsif (/^DEFINE_PLS_ERROR_EXT\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")\s*,\s*("[^"]*")\s*,\s*([^,]*),\s*("[^"]*")\s*,\s*("[^"]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_ora_errmsg, "PLS", $7, substr($8, 1, length($8) - 2));
|
||||
my $tmp_ora_user_errmsg=sprintf($print_ora_errmsg, "PLS", $7, substr($9, 1, length($9) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $7, $tmp_ora_errmsg, $tmp_ora_user_errmsg, $10, $11];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
@ -84,18 +141,21 @@ while(<$fh>) {
|
||||
#print "\"$1\", $7, $8, $9\n";
|
||||
my $tmp_ora_errmsg=sprintf($print_ora_errmsg, "PLS", $7, substr($8, 1, length($8) - 2));
|
||||
my $tmp_ora_user_errmsg=sprintf($print_ora_errmsg, "PLS", $7, substr($9, 1, length($9) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $7, $tmp_ora_errmsg, $tmp_ora_user_errmsg];
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $7, $tmp_ora_errmsg, $tmp_ora_user_errmsg, $print_error_cause, $print_error_solution];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
$error_msg = $5;
|
||||
} elsif (/^DEFINE_OTHER_MSG_FMT\(([^,]+),\s*([^,]*),\s*("[^"]*")\s*,\s*("[^"]*")/) {
|
||||
#print "\"$1\", $1, $2, $3, $4\n";
|
||||
$other_map{$1} = [$2, $3, $4];
|
||||
} elsif (/^DEFINE_ORACLE_ERROR_V2_EXT\(([^,]+),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*("[^"]*")\s*,\s*("[^"]*")\s*,\s*([^,]*),\s*("[^"]*")\s*,\s*("[^"]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2, $3, $4, $5, $6, $7, $8, $9\n";
|
||||
#print "\"$1\", $7, $8, $9\n";
|
||||
my $tmp_ora_errmsg=sprintf("\"%s\"", substr($8, 1, length($8) - 2));
|
||||
my $tmp_ora_user_errmsg=sprintf("\"%s\"", substr($9, 1, length($9) - 2));
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $7, $tmp_ora_errmsg, $tmp_ora_user_errmsg];
|
||||
$map{$1} = [$2, $3, $4, $5, $6, "$1", $7, $tmp_ora_errmsg, $tmp_ora_user_errmsg, $print_error_cause, $print_error_solution];
|
||||
$last_errno = $2 if ($2 < $last_errno);
|
||||
$error_code = $2;
|
||||
$sqlstate = $4;
|
||||
@ -149,11 +209,8 @@ print $fh_header '/**
|
||||
#include "share/mysql_errno.h"
|
||||
#include "lib/ob_errno.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
using namespace ::oblib;
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
';
|
||||
print $fh_header "
|
||||
constexpr int OB_LAST_ERROR_CODE = $last_errno;
|
||||
@ -203,6 +260,9 @@ constexpr int OB_ERR_SQL_END = -5999;
|
||||
print $fh_header '
|
||||
|
||||
const char *ob_error_name(const int oberr);
|
||||
const char* ob_error_cause(const int oberr);
|
||||
const char* ob_error_solution(const int oberr);
|
||||
|
||||
int ob_mysql_errno(const int oberr);
|
||||
int ob_mysql_errno_with_check(const int oberr);
|
||||
const char *ob_sqlstate(const int oberr);
|
||||
@ -218,7 +278,6 @@ constexpr int OB_ERR_SQL_END = -5999;
|
||||
const char *ob_errpkt_strerror(const int oberr, const bool is_oracle_mode);
|
||||
const char *ob_errpkt_str_user_error(const int oberr, const bool is_oracle_mode);
|
||||
|
||||
|
||||
} // end namespace common
|
||||
} // end namespace oceanbase
|
||||
|
||||
@ -238,13 +297,24 @@ print $fh_cpp '/**
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated from `ob_errno.def\'.
|
||||
|
||||
#include "ob_errno.h"
|
||||
#ifndef __ERROR_CODE_PARSER_
|
||||
#include "ob_define.h"
|
||||
#else
|
||||
#define OB_LIKELY
|
||||
#define OB_UNLIKELY
|
||||
#define NULL 0
|
||||
#include <string.h>
|
||||
#endif
|
||||
using namespace oceanbase::common;
|
||||
|
||||
static const char *ERROR_NAME[OB_MAX_ERROR_CODE];
|
||||
static const char *ERROR_CAUSE[OB_MAX_ERROR_CODE];
|
||||
static const char *ERROR_SOLUTION[OB_MAX_ERROR_CODE];
|
||||
|
||||
static int MYSQL_ERRNO[OB_MAX_ERROR_CODE];
|
||||
static const char *SQLSTATE[OB_MAX_ERROR_CODE];
|
||||
static const char *STR_ERROR[OB_MAX_ERROR_CODE];
|
||||
@ -259,6 +329,9 @@ static struct ObStrErrorInit
|
||||
ObStrErrorInit()
|
||||
{
|
||||
memset(ERROR_NAME, 0, sizeof(ERROR_NAME));
|
||||
memset(ERROR_CAUSE, 0, sizeof(ERROR_CAUSE));
|
||||
memset(ERROR_SOLUTION, 0, sizeof(ERROR_SOLUTION));
|
||||
|
||||
memset(MYSQL_ERRNO, 0, sizeof(MYSQL_ERRNO));
|
||||
memset(SQLSTATE, 0, sizeof(SQLSTATE));
|
||||
memset(STR_ERROR, 0, sizeof(STR_ERROR));
|
||||
@ -272,6 +345,8 @@ static struct ObStrErrorInit
|
||||
for my $oberr (@errors) {
|
||||
if (0 > $map{$oberr}->[0]) {
|
||||
print $fh_cpp " ERROR_NAME[-$oberr] = \"$map{$oberr}->[5]\";\n";
|
||||
print $fh_cpp " ERROR_CAUSE[-$oberr] = $map{$oberr}->[9];\n";
|
||||
print $fh_cpp " ERROR_SOLUTION[-$oberr] = $map{$oberr}->[10];\n";
|
||||
print $fh_cpp " MYSQL_ERRNO[-$oberr] = $map{$oberr}->[1];\n";
|
||||
print $fh_cpp " SQLSTATE[-$oberr] = $map{$oberr}->[2];\n";
|
||||
print $fh_cpp " STR_ERROR[-$oberr] = $map{$oberr}->[3];\n";
|
||||
@ -286,132 +361,158 @@ static struct ObStrErrorInit
|
||||
}
|
||||
} local_init;
|
||||
|
||||
namespace oceanbase
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
const char *ob_error_name(const int err)
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
const char *ob_error_name(const int err)
|
||||
{
|
||||
const char *ret = "Unknown error";
|
||||
if (OB_UNLIKELY(0 == err)) {
|
||||
ret = "OB_SUCCESS";
|
||||
} else if (OB_LIKELY(0 > err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ERROR_NAME[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0]))
|
||||
{
|
||||
ret = "Unknown Error";
|
||||
}
|
||||
const char *ret = "Unknown error";
|
||||
if (OB_UNLIKELY(0 == err)) {
|
||||
ret = "OB_SUCCESS";
|
||||
} else if (OB_LIKELY(0 > err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ERROR_NAME[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0]))
|
||||
{
|
||||
ret = "Unknown Error";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char *ob_error_cause(const int err)
|
||||
{
|
||||
const char *ret = "Internal Error";
|
||||
if (OB_UNLIKELY(0 == err)) {
|
||||
ret = "Not an Error";
|
||||
} else if (OB_LIKELY(0 > err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ERROR_CAUSE[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0]))
|
||||
{
|
||||
ret = "Internal Error";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char *ob_error_solution(const int err)
|
||||
{
|
||||
const char *ret = "Contact OceanBase Support";
|
||||
if (OB_UNLIKELY(0 == err)) {
|
||||
ret = "Contact OceanBase Support";
|
||||
} else if (OB_LIKELY(0 > err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ERROR_SOLUTION[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0]))
|
||||
{
|
||||
ret = "Contact OceanBase Support";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char *ob_strerror(const int err)
|
||||
{
|
||||
const char *ret = "Unknown error";
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = STR_ERROR[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0]))
|
||||
{
|
||||
ret = "Unknown Error";
|
||||
}
|
||||
const char *ob_strerror(const int err)
|
||||
{
|
||||
const char *ret = "Unknown error";
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = STR_ERROR[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0]))
|
||||
{
|
||||
ret = "Unknown Error";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char *ob_str_user_error(const int err)
|
||||
{
|
||||
const char *ret = NULL;
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = STR_USER_ERROR[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0])) {
|
||||
ret = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char *ob_str_user_error(const int err)
|
||||
{
|
||||
const char *ret = NULL;
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = STR_USER_ERROR[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0])) {
|
||||
ret = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char *ob_sqlstate(const int err)
|
||||
{
|
||||
const char *ret = "HY000";
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = SQLSTATE[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0])) {
|
||||
ret = "HY000";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char *ob_sqlstate(const int err)
|
||||
{
|
||||
const char *ret = "HY000";
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = SQLSTATE[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0])) {
|
||||
ret = "HY000";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ob_mysql_errno(const int err)
|
||||
{
|
||||
int ret = -1;
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = MYSQL_ERRNO[-err];
|
||||
return ret;
|
||||
}
|
||||
int ob_mysql_errno(const int err)
|
||||
{
|
||||
int ret = -1;
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = MYSQL_ERRNO[-err];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ob_mysql_errno_with_check(const int err)
|
||||
{
|
||||
int ret = ob_mysql_errno(err);
|
||||
if (ret < 0) {
|
||||
ret = -err;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char *ob_oracle_strerror(const int err)
|
||||
{
|
||||
const char *ret = "Unknown error";
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ORACLE_STR_ERROR[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0]))
|
||||
{
|
||||
ret = "Unknown Error";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ob_mysql_errno_with_check(const int err)
|
||||
{
|
||||
int ret = ob_mysql_errno(err);
|
||||
if (ret < 0) {
|
||||
ret = -err;
|
||||
return ret;
|
||||
}
|
||||
const char *ob_oracle_str_user_error(const int err)
|
||||
{
|
||||
const char *ret = NULL;
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ORACLE_STR_USER_ERROR[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0])) {
|
||||
ret = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char *ob_oracle_strerror(const int err)
|
||||
{
|
||||
const char *ret = "Unknown error";
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ORACLE_STR_ERROR[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0]))
|
||||
{
|
||||
ret = "Unknown Error";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
int ob_oracle_errno(const int err)
|
||||
{
|
||||
int ret = -1;
|
||||
if (OB_ERR_PROXY_REROUTE == err) {
|
||||
// Oracle Mode and MySQL mode should return same errcode for reroute sql
|
||||
// thus we make the specialization here
|
||||
ret = -1;
|
||||
} else if (err >= OB_MIN_RAISE_APPLICATION_ERROR && err <= OB_MAX_RAISE_APPLICATION_ERROR) {
|
||||
ret = err; // PL/SQL Raise Application Error
|
||||
} else if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ORACLE_ERRNO[-err];
|
||||
}
|
||||
const char *ob_oracle_str_user_error(const int err)
|
||||
{
|
||||
const char *ret = NULL;
|
||||
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ORACLE_STR_USER_ERROR[-err];
|
||||
if (OB_UNLIKELY(NULL == ret || \'\0\' == ret[0])) {
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ob_oracle_errno(const int err)
|
||||
{
|
||||
int ret = -1;
|
||||
if (OB_ERR_PROXY_REROUTE == err) {
|
||||
// Oracle Mode and MySQL mode should return same errcode for reroute sql
|
||||
// thus we make the specialization here
|
||||
ret = -1;
|
||||
} else if (err >= OB_MIN_RAISE_APPLICATION_ERROR && err <= OB_MAX_RAISE_APPLICATION_ERROR) {
|
||||
ret = err; // PL/SQL Raise Application Error
|
||||
} else if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
|
||||
ret = ORACLE_ERRNO[-err];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ob_oracle_errno_with_check(const int err)
|
||||
{
|
||||
int ret = ob_oracle_errno(err);
|
||||
if (ret < 0) {
|
||||
ret = -err;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ob_errpkt_errno(const int err, const bool is_oracle_mode)
|
||||
{
|
||||
return (is_oracle_mode ? ob_oracle_errno_with_check(err) : ob_mysql_errno_with_check(err));
|
||||
}
|
||||
const char *ob_errpkt_strerror(const int err, const bool is_oracle_mode)
|
||||
{
|
||||
return (is_oracle_mode ? ob_oracle_strerror(err) : ob_strerror(err));
|
||||
}
|
||||
const char *ob_errpkt_str_user_error(const int err, const bool is_oracle_mode)
|
||||
{
|
||||
return (is_oracle_mode ? ob_oracle_str_user_error(err) : ob_str_user_error(err));
|
||||
return ret;
|
||||
}
|
||||
int ob_oracle_errno_with_check(const int err)
|
||||
{
|
||||
int ret = ob_oracle_errno(err);
|
||||
if (ret < 0) {
|
||||
ret = -err;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ob_errpkt_errno(const int err, const bool is_oracle_mode)
|
||||
{
|
||||
return (is_oracle_mode ? ob_oracle_errno_with_check(err) : ob_mysql_errno_with_check(err));
|
||||
}
|
||||
const char *ob_errpkt_strerror(const int err, const bool is_oracle_mode)
|
||||
{
|
||||
return (is_oracle_mode ? ob_oracle_strerror(err) : ob_strerror(err));
|
||||
}
|
||||
const char *ob_errpkt_str_user_error(const int err, const bool is_oracle_mode)
|
||||
{
|
||||
return (is_oracle_mode ? ob_oracle_str_user_error(err) : ob_str_user_error(err));
|
||||
}
|
||||
|
||||
} // end namespace common
|
||||
} // end namespace oceanbase
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,6 +20,8 @@
|
||||
//
|
||||
//C0: int OB_MAX_ERROR_CODE -----> ob errno
|
||||
//C1: char *ERROR_NAME[OB_MAX_ERROR_CODE]; -----> store ob errno name
|
||||
//C2: char *ERROR_CAUSE[OB_MAX_ERROR_CODE]; -----> store ob errno cause
|
||||
//C3: char *ERROR_SOLUTION[OB_MAX_ERROR_CODE]; -----> store ob errno solution
|
||||
//M1: int MYSQL_ERRNO[OB_MAX_ERROR_CODE]; -----> store mysql errno
|
||||
//M2: char *SQLSTATE[OB_MAX_ERROR_CODE]; -----> store mysql errstate
|
||||
//M3: char *STR_ERROR[OB_MAX_ERROR_CODE]; -----> store mysql errmsg without parameter
|
||||
@ -36,6 +38,13 @@
|
||||
//DEFINE_PLS_ERROR(C1, C0, M1, M2, M3, R1, R3) <==> DEFINE_ORACLE_ERROR_EXT(C1, C0, M1, M2, M3, M3, R1, PLS, R3, R3)
|
||||
//DEFINE_PLS_ERROR_EXT(C1, C0, M1, M2, M3, M4, R1, R3, R4) <==> DEFINE_ORACLE_ERROR_EXT(C1, C0, M1, M2, M3, M4, R1, PLS, R3, R4)
|
||||
//
|
||||
//DEFINE_ERROR(C1, C0, M1, M2, M3, C2, C3) <==> DEFINE_ORACLE_ERROR_EXT(C1, C0, M1, M2, M3, M3, -600, M2, M3, M3, C2, C3)
|
||||
//DEFINE_ERROR_EXT(C1, C0, M1, M2, M3, M4, C2, C3) <==> DEFINE_ORACLE_ERROR_EXT(C1, C0, M1, M2, M3, M4, -600, M2, M3, M4, C2, C3)
|
||||
//DEFINE_ORACLE_ERROR(C1, C0, M1, M2, M3, R1, R3, C2, C3) <==> DEFINE_ORACLE_ERROR_EXT(C1, C0, M1, M2, M3, M3, R1, ORA, R3, R3, C2, C3)
|
||||
//DEFINE_ORACLE_ERROR_EXT(C1, C0, M1, M2, M3, M4, R1, R3, R4, C2, C3) <==> DEFINE_ORACLE_ERROR_EXT(C1, C0, M1, M2, M3, M4, R1, ORA, R3, R4, C2, C3)
|
||||
//DEFINE_PLS_ERROR(C1, C0, M1, M2, M3, R1, R3, C2, C3) <==> DEFINE_ORACLE_ERROR_EXT(C1, C0, M1, M2, M3, M3, R1, PLS, R3, R3, C2, C3)
|
||||
//DEFINE_PLS_ERROR_EXT(C1, C0, M1, M2, M3, M4, R1, R3, R4, C2, C3) <==> DEFINE_ORACLE_ERROR_EXT(C1, C0, M1, M2, M3, M4, R1, PLS, R3, R4, C2, C3)
|
||||
//
|
||||
//DEFINE_ERROR(C1, C0, M1, M2, M3)
|
||||
// M1 = (M1 == -1 ? C0 : M1)
|
||||
// M4 = M3
|
||||
@ -824,7 +833,7 @@ DEFINE_ORACLE_ERROR(OB_EER_NULL_IN_VALUES_LESS_THAN, -5285, ER_NULL_IN_VALUES_LE
|
||||
DEFINE_ERROR(OB_ERR_PARTITION_CONST_DOMAIN_ERROR, -5286, ER_PARTITION_CONST_DOMAIN_ERROR, "HY000", "Partition constant is out of partition function domain");
|
||||
DEFINE_ERROR(OB_ERR_TOO_MANY_PARTITION_FUNC_FIELDS, -5287, ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, "HY000", "Too many fields in \'list of partition fields\'");
|
||||
DEFINE_ERROR_EXT(OB_ERR_BAD_FT_COLUMN, -5288, ER_BAD_FT_COLUMN, "HY000", "Column cannot be part of FULLTEXT index", "Column '%.*s' cannot be part of FULLTEXT index");
|
||||
DEFINE_ERROR_EXT(OB_ERR_KEY_DOES_NOT_EXISTS, -5289, ER_KEY_DOES_NOT_EXITS, "42000", "key does not exist in table", "Key '%.*s' doesn't exist in table '%.*s'");
|
||||
DEFINE_ERROR_EXT(OB_ERR_KEY_DOES_NOT_EXISTS, -5289, ER_KEY_DOES_NOT_EXISTS, "42000", "key does not exist in table", "Key '%.*s' doesn't exist in table '%.*s'");
|
||||
DEFINE_ERROR_EXT(OB_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN, -5290, ER_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN, "HY000", "non-default value for generated column is not allowed", "The value specified for generated column '%.*s' in table '%.*s' is not allowed");
|
||||
DEFINE_ERROR(OB_ERR_BAD_CTXCAT_COLUMN, -5291, -1, "HY000", "The CTXCAT column must be contiguous in the index column list");
|
||||
DEFINE_ERROR_EXT(OB_ERR_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN, -5292, ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN, "HY000", "not supported for generated columns", "'%s' is not supported for generated columns.");
|
||||
@ -1199,7 +1208,7 @@ DEFINE_ORACLE_ERROR(OB_ERR_REGEXP_EPAREN, -5813, -1, "HY000", "unmatched parenth
|
||||
DEFINE_ORACLE_ERROR(OB_ERR_REGEXP_ESUBREG, -5814, -1, "HY000", "invalid back reference in regular expression", 12727, "invalid back reference in regular expression");
|
||||
DEFINE_ORACLE_ERROR(OB_ERR_REGEXP_ERANGE, -5815, -1, "HY000", "invalid range in regular expression", 12728, "invalid range in regular expression");
|
||||
DEFINE_ORACLE_ERROR(OB_ERR_REGEXP_ECTYPE, -5816, -1, "HY000", "invalid character class in regular expression", 12729, "invalid character class in regular expression");
|
||||
DEFINE_ERROR(OB_ERR_REGEXP_ECOLLATE, -5817, -1, "HY000", "invalid collation class in regular expression", 12731, "invalid collation class in regular expression");
|
||||
DEFINE_ORACLE_ERROR(OB_ERR_REGEXP_ECOLLATE, -5817, -1, "HY000", "invalid collation class in regular expression", 12731, "invalid collation class in regular expression");
|
||||
DEFINE_ERROR(OB_ERR_REGEXP_EBRACE, -5818, -1, "HY000", "braces {} not balanced in in regular expression");
|
||||
DEFINE_ERROR(OB_ERR_REGEXP_BADBR, -5819, -1, "HY000", "invalid repetition count(s) in regular expression");
|
||||
DEFINE_ERROR(OB_ERR_REGEXP_BADRPT, -5820, -1, "HY000", "The regular expression was too complex and current library can't be parsed");
|
||||
|
@ -10,6 +10,8 @@
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated from `ob_errno.def'.
|
||||
|
||||
#ifndef OCEANBASE_LIB_OB_ERRNO_H_
|
||||
#define OCEANBASE_LIB_OB_ERRNO_H_
|
||||
#include <stdint.h>
|
||||
@ -4679,8 +4681,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
||||
#define OB_ERR_REGEXP_ESUBREG__ORA_USER_ERROR_MSG "ORA-12727: invalid back reference in regular expression"
|
||||
#define OB_ERR_REGEXP_ERANGE__ORA_USER_ERROR_MSG "ORA-12728: invalid range in regular expression"
|
||||
#define OB_ERR_REGEXP_ECTYPE__ORA_USER_ERROR_MSG "ORA-12729: invalid character class in regular expression"
|
||||
#define OB_ERR_REGEXP_ECOLLATE__ORA_USER_ERROR_MSG \
|
||||
"ORA-00600: internal error code, arguments: -5817, invalid collation class in regular expression"
|
||||
#define OB_ERR_REGEXP_ECOLLATE__ORA_USER_ERROR_MSG "ORA-12731: invalid collation class in regular expression"
|
||||
#define OB_ERR_REGEXP_EBRACE__ORA_USER_ERROR_MSG \
|
||||
"ORA-00600: internal error code, arguments: -5818, braces {} not balanced in in regular expression"
|
||||
#define OB_ERR_REGEXP_BADBR__ORA_USER_ERROR_MSG \
|
||||
@ -5243,6 +5244,9 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
||||
"ORA-01861: Incorrect datetime value for column '%.*s' at row %ld"
|
||||
|
||||
const char* ob_error_name(const int oberr);
|
||||
const char* ob_error_cause(const int oberr);
|
||||
const char* ob_error_solution(const int oberr);
|
||||
|
||||
int ob_mysql_errno(const int oberr);
|
||||
int ob_mysql_errno_with_check(const int oberr);
|
||||
const char* ob_sqlstate(const int oberr);
|
||||
|
1
tools/CMakeLists.txt
Normal file
1
tools/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(ob_error)
|
1
tools/ob_error/CMakeLists.txt
Normal file
1
tools/ob_error/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(src)
|
166
tools/ob_error/README.md
Normal file
166
tools/ob_error/README.md
Normal file
@ -0,0 +1,166 @@
|
||||
# What is ob_error
|
||||
|
||||
ob_error is the error tool of OceanBase.
|
||||
|
||||
An error tool can return the information, reason and solution corresponding to the error code which entered by the user.
|
||||
|
||||
It saves the trouble of looking up documents.
|
||||
|
||||
## How to build
|
||||
|
||||
### debug mode
|
||||
|
||||
```shell
|
||||
bash build.sh debug --init
|
||||
cd build_debug
|
||||
make ob_error
|
||||
cp tools/ob_error/src/ob_error /usr/local/bin
|
||||
```
|
||||
|
||||
`ob_error` will generated in `DEBUG_BUILD_DIR/tools/ob_error/src/ob_error` by default.
|
||||
|
||||
### release mode
|
||||
|
||||
```shell
|
||||
bash build.sh release --init
|
||||
cd build_release
|
||||
make ob_error
|
||||
cp tools/ob_error/src/ob_error /usr/local/bin
|
||||
```
|
||||
|
||||
`ob_error` will generated in `RELEASE_BUILD_DIR/tools/ob_error/src/ob_error` by default.
|
||||
|
||||
### RPM packges
|
||||
|
||||
NOTE: this is not support now.
|
||||
|
||||
```shell
|
||||
bash build.sh rpm --init && cd build_rpm && make -j16 rpm
|
||||
rpm2cpio oceanbase-ce-3.1.0-1.alios7.x86_64.rpm | cpio -idmv ./home/admin/oceanbase/bin/ob_error
|
||||
cp home/admin/oceanbase/bin/ob_error /usr/local/bin
|
||||
```
|
||||
|
||||
`ob_error` will included in `oceanbase-ce-3.1.0-1.alios7.x86_64.rpm`.
|
||||
Because you just need `ob_error`, you can use `rpm2cpio` to do it.
|
||||
|
||||
## How to use
|
||||
|
||||
You can search error message by only enter the error code.
|
||||
|
||||
Then you will get the error message corresponding to OS, Oracle and MySQL modes, and OceanBase own error (if any exists).
|
||||
|
||||
such as:
|
||||
|
||||
```shell
|
||||
$ob_error 4001
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_OBJ_TYPE_ERROR(-4001)
|
||||
Message: Object type error
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-04001
|
||||
Message: sequence parameter must be an integer
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_SEQ_OPTION_MUST_BE_INTEGER(-4317)
|
||||
```
|
||||
|
||||
Also, you can search error message of specific mode by adding a prefix (we called facility).
|
||||
|
||||
When the facility is `my`, if the error code is not an error which exists in MySQL, you will get the OceanBase error info(if it exists). Otherwise, you will get the error info of MySQL mode.
|
||||
|
||||
such as:
|
||||
|
||||
```shell
|
||||
$ob_error my 4000
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_ERROR(-4000)
|
||||
Message: Common error
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
|
||||
$ob_error my 1210
|
||||
|
||||
MySQL:
|
||||
MySQL Error Code: 1210 (HY000)
|
||||
Message: Invalid argument
|
||||
Message: Miss argument
|
||||
Message: Incorrect arguments to ESCAPE
|
||||
Related OceanBase Error Code:
|
||||
OB_INVALID_ARGUMENT(-4002)
|
||||
OB_MISS_ARGUMENT(-4277)
|
||||
INCORRECT_ARGUMENTS_TO_ESCAPE(-5832)
|
||||
```
|
||||
|
||||
When the facility is `ora` or `pls`, you will get the error info of Oracle mode(if it exists).
|
||||
such as:
|
||||
|
||||
```shell
|
||||
$ob_error ora 51
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-00051
|
||||
Message: timeout occurred while waiting for a resource
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_TIMEOUT_ON_RESOURCE(-5848)
|
||||
```
|
||||
|
||||
Further more, there is an exceptional case. If you use the `-a` option, you will get the OceanBase own error info and the error info of Oracle mode (if any exists).
|
||||
|
||||
such as:
|
||||
|
||||
```shell
|
||||
$ob_error ora 600 -a 5727
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_ERR_PROXY_REROUTE(-5727)
|
||||
Message: SQL request should be rerouted
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-00600
|
||||
Message: internal error code, arguments: -5727, SQL request should be rerouted
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_PROXY_REROUTE(-5727)
|
||||
```
|
||||
|
||||
Note: `-a` option is designed to find `ORA-00600` error which has an `arguments` (those Oracle internal error).
|
||||
|
||||
You can find more test example in [expect_result](test/expect_result.result).
|
||||
|
||||
Further more, you can get the complete user manual by `--help` option.
|
||||
|
||||
```shell
|
||||
ob_error --help
|
||||
```
|
||||
|
||||
## How to add error cause/solution
|
||||
|
||||
*This part is for developers.*
|
||||
|
||||
For example:
|
||||
|
||||
The ob error `4000` in `src/oberror_errno.def` defined as
|
||||
|
||||
```shell
|
||||
DEFINE_ERROR(OB_ERROR, -4000, -1, "HY000", "Common error");
|
||||
```
|
||||
|
||||
If you want to add the cause and solution info, you can change the define as
|
||||
|
||||
```shell
|
||||
DEFINE_ERROR(OB_ERROR, -4000, -1, "HY000", "Common error", "CAUSE", "SOLUTION");
|
||||
```
|
||||
|
||||
And then regenerate the `src/lib/oberror_errno.h`、`src/oberror_errno.h` and `src/oberror_errno.cpp` by
|
||||
|
||||
```shell
|
||||
cd src/share
|
||||
./gen_errno.pl
|
||||
```
|
||||
|
||||
Finally back to `BUILD_DIR` to remake `ob_error`.
|
13
tools/ob_error/src/CMakeLists.txt
Normal file
13
tools/ob_error/src/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${DEP_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/deps/oblib/src
|
||||
)
|
||||
add_definitions(-D__ERROR_CODE_PARSER_)
|
||||
set(SRC_LIST ob_error.cpp os_errno.cpp ${CMAKE_SOURCE_DIR}/src/share/ob_errno.cpp)
|
||||
|
||||
add_executable(ob_error ${SRC_LIST})
|
||||
|
||||
add_library(oberror SHARED ${SRC_LIST})
|
||||
|
||||
# message(STATUS "DIR = " ${CMAKE_SOURCE_DIR})
|
172
tools/ob_error/src/gen_os_errno.pl
Executable file
172
tools/ob_error/src/gen_os_errno.pl
Executable file
@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env perl
|
||||
# Copyright (c) 2021 OceanBase
|
||||
# OceanBase CE is licensed under Mulan PubL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
# You may obtain a copy of Mulan PubL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPubL-2.0
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PubL v2 for more details.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
open my $fh, '<', "os_errno.def";
|
||||
my %os_map;
|
||||
my $error_count=0;
|
||||
|
||||
while(<$fh>) {
|
||||
if (/^DEFINE_OS_ERROR\(([^,]+),\s*([^,]*),\s*([^,]*),\s*("[^,]*")/) {
|
||||
++$error_count;
|
||||
#print "\"$1\", $1, $2\n";
|
||||
$os_map{$1} = [$2, $3, "$1", $4];
|
||||
}
|
||||
}
|
||||
|
||||
print "total error code: $error_count\n";
|
||||
print "please wait for writing files ...\n";
|
||||
# check duplicate error number
|
||||
my %dedup;
|
||||
for my $oberr (keys % os_map) {
|
||||
my $errno = $os_map{$oberr}->[0];
|
||||
if (defined $dedup{$errno})
|
||||
{
|
||||
print "Error: error code($errno) is duplicated for $oberr and $dedup{$errno}\n";
|
||||
exit 1;
|
||||
} else {
|
||||
$dedup{$errno} = $oberr;
|
||||
}
|
||||
}
|
||||
|
||||
# sort
|
||||
my @os_pairs = map {[$_, $os_map{$_}->[0] ]} keys %os_map;
|
||||
my @os_sorted = sort {$b->[1] <=> $a->[1]} @os_pairs;
|
||||
my @os_errors = map {$_->[0]} @os_sorted;
|
||||
|
||||
# generate os_errno.h
|
||||
open my $fh_header_os, '>', "os_errno.h";
|
||||
print $fh_header_os '/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated from `ob_errno.def\'.
|
||||
#ifndef OBERROR_OS_ERRNO_H
|
||||
#define OBERROR_OS_ERRNO_H
|
||||
|
||||
// linux
|
||||
#include <errno.h>
|
||||
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
|
||||
// The length of the second dimension, in order to solve the conflict of multiple identical error codes
|
||||
constexpr int OS_MAX_SAME_ERROR_COUNT = 2;
|
||||
|
||||
constexpr int OS_MAX_ERROR_CODE = 135;
|
||||
';
|
||||
for my $oserr (@os_errors) {
|
||||
print $fh_header_os "constexpr int $oserr = $os_map{$oserr}->[0];\n";
|
||||
}
|
||||
print $fh_header_os '
|
||||
const char* str_os_error_name(const int err);
|
||||
const char* str_os_error_msg(const int err);
|
||||
int os_errno(const int err);
|
||||
} // end namespace common
|
||||
} // end namespace oceanbase
|
||||
|
||||
#endif /* OBERROR_OS_ERRNO_H */
|
||||
';
|
||||
|
||||
# generate os_errno.cpp
|
||||
open my $fh_cpp_os, '>', "os_errno.cpp";
|
||||
print $fh_cpp_os '/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated from `ob_errno.def\'.
|
||||
|
||||
#include "os_errno.h"
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
using namespace oceanbase::common;
|
||||
|
||||
static const char *OS_ERRNO_NAME[OS_MAX_ERROR_CODE];
|
||||
static const char *OS_ERRNO_MSG[OS_MAX_ERROR_CODE];
|
||||
static int OS_ERRNO[OS_MAX_ERROR_CODE];
|
||||
|
||||
static struct OSStrErrorInit
|
||||
{
|
||||
OSStrErrorInit() {
|
||||
memset(OS_ERRNO_NAME, 0, sizeof(OS_ERRNO_NAME));
|
||||
memset(OS_ERRNO_MSG, 0, sizeof(OS_ERRNO_MSG));
|
||||
memset(OS_ERRNO, 0, sizeof(OS_ERRNO));
|
||||
|
||||
';
|
||||
for my $oserr (@os_errors) {
|
||||
if (0 > $os_map{$oserr}->[0]) {
|
||||
print $fh_cpp_os " OS_ERRNO_NAME[-$oserr] = \"$os_map{$oserr}->[2]\";\n";
|
||||
print $fh_cpp_os " OS_ERRNO_MSG[-$oserr] = $os_map{$oserr}->[3];\n";
|
||||
print $fh_cpp_os " OS_ERRNO[-$oserr] = $os_map{$oserr}->[1];\n";
|
||||
}
|
||||
}
|
||||
print $fh_cpp_os '
|
||||
}
|
||||
} local_init;
|
||||
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
const char *str_os_error_name(const int err)
|
||||
{
|
||||
const char *ret = "Unknown error";
|
||||
if (0 == err) {
|
||||
ret = "OB_SUCCESS";
|
||||
} else if (0 > err && err > -OS_MAX_ERROR_CODE) {
|
||||
ret = OS_ERRNO_NAME[-err];
|
||||
if (NULL == ret || \'\0\' == ret[0])
|
||||
{
|
||||
ret = "Unknown Error";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char *str_os_error_msg(const int err)
|
||||
{
|
||||
const char *ret = NULL;
|
||||
if (0 == err) {
|
||||
ret = NULL;
|
||||
} else if (0 > err && err > -OS_MAX_ERROR_CODE) {
|
||||
ret = OS_ERRNO_MSG[-err];
|
||||
if (NULL == ret || \'\0\' == ret[0])
|
||||
{
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int os_errno(const int err)
|
||||
{
|
||||
int ret = -1;
|
||||
if (0 >= err && err > -OS_MAX_ERROR_CODE) {
|
||||
ret = OS_ERRNO[-err];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // end namespace common
|
||||
} // end namespace oceanbase
|
||||
';
|
784
tools/ob_error/src/ob_error.cpp
Normal file
784
tools/ob_error/src/ob_error.cpp
Normal file
@ -0,0 +1,784 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "ob_error.h"
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
|
||||
ObErrorInfoMgr::ObErrorInfoMgr()
|
||||
: os_error_count_(0),
|
||||
mysql_error_count_(0),
|
||||
oracle_error_count_(0),
|
||||
ob_error_count_(0)
|
||||
{}
|
||||
|
||||
ObErrorInfoMgr::~ObErrorInfoMgr()
|
||||
{
|
||||
for (int i = 0; i < os_error_count_; i++) {
|
||||
os_error_[i].free_space();
|
||||
}
|
||||
for (int i = 0; i < mysql_error_count_; i++) {
|
||||
mysql_error_[i].free_space();
|
||||
}
|
||||
for (int i = 0; i < oracle_error_count_; i++) {
|
||||
oracle_error_[i].free_space();
|
||||
}
|
||||
for (int i = 0; i < ob_error_count_; i++) {
|
||||
ob_error_[i].free_space();
|
||||
}
|
||||
}
|
||||
|
||||
bool ObErrorInfoMgr::insert_os_error(const char* name, const char* msg, int error_code)
|
||||
{
|
||||
bool bret = false;
|
||||
if (OS_MAX_SAME_ERROR_COUNT <= os_error_count_) {
|
||||
ERROR_PRINT("error: ObErrorInfoMgr os_error_[] is full.\n");
|
||||
} else if (nullptr == name) {
|
||||
ERROR_PRINT("error: name is nullptr.\n");
|
||||
} else if (nullptr == msg) {
|
||||
ERROR_PRINT("error: msg is nullptr.\n");
|
||||
} else {
|
||||
os_error_[os_error_count_].error_name_ = strdup(name);
|
||||
os_error_[os_error_count_].error_msg_ = strdup(msg);
|
||||
os_error_[os_error_count_].error_code_ = error_code;
|
||||
os_error_count_++;
|
||||
bret = true;
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
void ObErrorInfoMgr::print_os_error()
|
||||
{
|
||||
for (int i = 0; i < os_error_count_; i++) {
|
||||
printf("\n\tLinux Error Code: %s(%d)\n\tMessage: %s\n",
|
||||
os_error_[i].error_name_,
|
||||
os_error_[i].error_code_,
|
||||
os_error_[i].error_msg_);
|
||||
}
|
||||
}
|
||||
|
||||
bool ObErrorInfoMgr::insert_mysql_error(const char* name, const char* msg, int mysql_errno, const char* sqlstate,
|
||||
const char* cause, const char* solution, int ob_error)
|
||||
{
|
||||
bool bret = false;
|
||||
if (OB_MAX_SAME_ERROR_COUNT <= mysql_error_count_) {
|
||||
ERROR_PRINT("error: ObErrorInfoMgr mysql_error_[] is full.\n");
|
||||
} else if (nullptr == name) {
|
||||
ERROR_PRINT("error: name is nullptr.\n");
|
||||
} else if (nullptr == msg) {
|
||||
ERROR_PRINT("error: msg is nullptr.\n");
|
||||
} else if (nullptr == sqlstate) {
|
||||
ERROR_PRINT("error: sqlstate is nullptr.\n");
|
||||
} else if (nullptr == cause) {
|
||||
ERROR_PRINT("error: cause is nullptr.\n");
|
||||
} else if (nullptr == solution) {
|
||||
ERROR_PRINT("error: solution is nullptr.\n");
|
||||
} else {
|
||||
mysql_error_[mysql_error_count_].error_name_ = strdup(name);
|
||||
mysql_error_[mysql_error_count_].error_msg_ = strdup(msg);
|
||||
mysql_error_[mysql_error_count_].mysql_errno_ = mysql_errno;
|
||||
mysql_error_[mysql_error_count_].sqlstate_ = strdup(sqlstate);
|
||||
mysql_error_[mysql_error_count_].cause_ = strdup(cause);
|
||||
mysql_error_[mysql_error_count_].solution_ = strdup(solution);
|
||||
mysql_error_[mysql_error_count_].ob_error_ = ob_error;
|
||||
mysql_error_count_++;
|
||||
bret = true;
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
void ObErrorInfoMgr::print_mysql_error()
|
||||
{
|
||||
for (int i = 0; i < mysql_error_count_; i++) {
|
||||
if (0 == i) {
|
||||
printf("\n\tMySQL Error Code: %d (%s)\n", mysql_error_[i].mysql_errno_, mysql_error_[i].sqlstate_);
|
||||
printf("\tMessage: %s\n", mysql_error_[i].error_msg_);
|
||||
} else if (0 != strcmp(mysql_error_[i].error_msg_, mysql_error_[i - 1].error_msg_)) {
|
||||
printf("\tMessage: %s\n", mysql_error_[i].error_msg_);
|
||||
}
|
||||
}
|
||||
printf("\tRelated OceanBase Error Code:\n");
|
||||
for (int i = 0; i < mysql_error_count_; i++) {
|
||||
printf("\t\t%s(%d)\n", mysql_error_[i].error_name_, -mysql_error_[i].ob_error_);
|
||||
}
|
||||
}
|
||||
|
||||
bool ObErrorInfoMgr::insert_oracle_error(const char* name, const char* msg, const char* cause, const char* solution,
|
||||
Fac facility, int error_code, int ob_error)
|
||||
{
|
||||
bool bret = false;
|
||||
if (OB_MAX_SAME_ERROR_COUNT <= oracle_error_count_) {
|
||||
ERROR_PRINT("error: ObErrorInfoMgr oracle_error_[] is full.\n");
|
||||
} else if (nullptr == name) {
|
||||
ERROR_PRINT("error: name is nullptr.\n");
|
||||
} else if (nullptr == msg) {
|
||||
ERROR_PRINT("error: msg is nullptr.\n");
|
||||
} else if (nullptr == cause) {
|
||||
ERROR_PRINT("error: cause is nullptr.\n");
|
||||
} else if (nullptr == solution) {
|
||||
ERROR_PRINT("error: solution is nullptr.\n");
|
||||
} else if (MY <= facility) {
|
||||
ERROR_PRINT("error: facility is not a Oracle facility.\n");
|
||||
} else {
|
||||
oracle_error_[oracle_error_count_].error_name_ = strdup(name);
|
||||
oracle_error_[oracle_error_count_].error_msg_ = strdup(msg);
|
||||
oracle_error_[oracle_error_count_].cause_ = strdup(cause);
|
||||
oracle_error_[oracle_error_count_].solution_ = strdup(solution);
|
||||
oracle_error_[oracle_error_count_].facility_ = facility;
|
||||
oracle_error_[oracle_error_count_].error_code_ = error_code;
|
||||
oracle_error_[oracle_error_count_].ob_error_ = ob_error;
|
||||
oracle_error_count_++;
|
||||
bret = true;
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
void ObErrorInfoMgr::print_oracle_error()
|
||||
{
|
||||
for (int i = 0; i < oracle_error_count_; i++) {
|
||||
if (0 == i) {
|
||||
printf(
|
||||
"\n\tOracle Error Code: %s-%05d\n", facility_str[oracle_error_[i].facility_], oracle_error_[i].error_code_);
|
||||
printf("\tMessage: %s\n", oracle_error_[i].error_msg_);
|
||||
} else if (0 != strcmp(oracle_error_[i].error_msg_, oracle_error_[i - 1].error_msg_)) {
|
||||
printf("\tMessage: %s\n", oracle_error_[i].error_msg_);
|
||||
}
|
||||
}
|
||||
printf("\tRelated OceanBase Error Code:\n");
|
||||
for (int i = 0; i < oracle_error_count_; i++) {
|
||||
printf("\t\t%s(%d)\n", oracle_error_[i].error_name_, -oracle_error_[i].ob_error_);
|
||||
}
|
||||
}
|
||||
|
||||
bool ObErrorInfoMgr::insert_ob_error(
|
||||
const char* name, const char* msg, const char* cause, const char* solution, int error_code)
|
||||
{
|
||||
bool bret = false;
|
||||
if (OB_MAX_SAME_ERROR_COUNT <= ob_error_count_) {
|
||||
ERROR_PRINT("error: ObErrorInfoMgr ob_error_[] is full.\n");
|
||||
} else if (nullptr == name) {
|
||||
ERROR_PRINT("error: name is nullptr.\n");
|
||||
} else if (nullptr == msg) {
|
||||
ERROR_PRINT("error: msg is nullptr.\n");
|
||||
} else if (nullptr == cause) {
|
||||
ERROR_PRINT("error: cause is nullptr.\n");
|
||||
} else if (nullptr == solution) {
|
||||
ERROR_PRINT("error: solution is nullptr.\n");
|
||||
} else {
|
||||
ob_error_[ob_error_count_].error_name_ = strdup(name);
|
||||
ob_error_[ob_error_count_].error_msg_ = strdup(msg);
|
||||
ob_error_[ob_error_count_].cause_ = strdup(cause);
|
||||
ob_error_[ob_error_count_].solution_ = strdup(solution);
|
||||
ob_error_[ob_error_count_].error_code_ = error_code;
|
||||
ob_error_count_++;
|
||||
bret = true;
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
void ObErrorInfoMgr::print_ob_error()
|
||||
{
|
||||
for (int i = 0; i < ob_error_count_; i++) {
|
||||
printf("\n\tOceanBase Error Code: %s(%d)\n\tMessage: %s\n\tCause: %s\n\tSolution: %s\n",
|
||||
ob_error_[i].error_name_,
|
||||
-ob_error_[i].error_code_,
|
||||
ob_error_[i].error_msg_,
|
||||
ob_error_[i].cause_,
|
||||
ob_error_[i].solution_);
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
static void print_help()
|
||||
{
|
||||
printf("This is the ob_error tool. Usage:\n\n"
|
||||
" ob_error [option]\n"
|
||||
" ob_error [facility] error_code [-a ARGUMENT]\n"
|
||||
" ob_error [facility] error_code [--argument ARGUMENT]\n"
|
||||
"Get the error information, reasons and possible solutions.\n\n"
|
||||
"Query an error:\n\n"
|
||||
" ob_error error_code\n\n"
|
||||
"Query an error in MySQL mode:\n\n"
|
||||
" ob_error MY error_code\n\n"
|
||||
"Query an error in ORACLE mode:\n\n"
|
||||
" ob_error facility error_code\n"
|
||||
" ob_error facility error_code -a ARGUMENT\n"
|
||||
" ob_error facility error_code --argument ARGUMENT\n\n"
|
||||
"ARGUMENT: \n\n"
|
||||
" Positive number OceanBase error_code in ORA-00600 error output.\n\n"
|
||||
"facility:\n\n"
|
||||
" MY MySQL mode.\n"
|
||||
" ORA ORACLE mode. Error from database.\n"
|
||||
" PLS ORACLE mode. Error from the stored procedure.\n\n"
|
||||
"Normal options:\n\n"
|
||||
" --help, -h Print this message and then exit.\n"
|
||||
" --version, -V Print version information and then exit.\n\n");
|
||||
}
|
||||
|
||||
static void print_version()
|
||||
{
|
||||
printf("OceanBase ob_error %.1f\n", OB_ERROR_VERSION);
|
||||
}
|
||||
|
||||
static void print_not_found(Fac facility, int error_code, int argument)
|
||||
{
|
||||
if (MY > facility) { // oracle mode
|
||||
if (-1 == argument) {
|
||||
printf("\n\tError Code %s-%05d not found.\n", facility_str[facility], error_code);
|
||||
} else {
|
||||
printf("\n\tError Code %s-%05d arguments: -%d not found.\n", facility_str[facility], error_code, argument);
|
||||
}
|
||||
} else {
|
||||
printf("\n\tError Code %d not found.\n", error_code);
|
||||
}
|
||||
}
|
||||
|
||||
bool print_error_info(Fac facility, int error_code, int argument)
|
||||
{
|
||||
bool bret = false;
|
||||
ObErrorInfoMgr mgr;
|
||||
if (MY > facility) {
|
||||
if (-1 != argument) {
|
||||
bret = add_ob_info(argument, &mgr);
|
||||
if (mgr.is_ob_error_exist()) {
|
||||
printf("\nOceanBase:");
|
||||
mgr.print_ob_error();
|
||||
} else if (!bret) {
|
||||
printf("\nOceanBase:");
|
||||
print_not_found(NONE, argument, -1);
|
||||
}
|
||||
}
|
||||
bool oracle_bret = add_oracle_info(facility, error_code, argument, &mgr);
|
||||
if (mgr.is_oracle_error_exist()) {
|
||||
printf("\nOracle:");
|
||||
mgr.print_oracle_error();
|
||||
} else if (!oracle_bret) {
|
||||
printf("\nOracle:");
|
||||
print_not_found(facility, error_code, argument);
|
||||
}
|
||||
bret = true;
|
||||
} else if (MY == facility) {
|
||||
bret = add_mysql_info(error_code, &mgr);
|
||||
if (mgr.is_mysql_error_exist()) {
|
||||
printf("\nMySQL:");
|
||||
mgr.print_mysql_error();
|
||||
} else if (!bret) {
|
||||
bret = add_ob_info(error_code, &mgr);
|
||||
if (mgr.is_ob_error_exist()) {
|
||||
printf("\nOceanBase:");
|
||||
mgr.print_ob_error();
|
||||
} else if (!bret) {
|
||||
printf("\nMySQL:");
|
||||
print_not_found(NONE, error_code, argument);
|
||||
bret = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bret |= add_os_info(error_code, &mgr);
|
||||
if (mgr.is_os_error_exist()) {
|
||||
printf("\nOperating System:");
|
||||
mgr.print_os_error();
|
||||
}
|
||||
bret |= add_ob_info(error_code, &mgr);
|
||||
if (mgr.is_ob_error_exist()) {
|
||||
printf("\nOceanBase:");
|
||||
mgr.print_ob_error();
|
||||
}
|
||||
bret |= add_mysql_info(error_code, &mgr);
|
||||
if (mgr.is_mysql_error_exist()) {
|
||||
printf("\nMySQL:");
|
||||
mgr.print_mysql_error();
|
||||
}
|
||||
bret |= add_oracle_info(facility, error_code, argument, &mgr);
|
||||
if (mgr.is_oracle_error_exist()) {
|
||||
printf("\nOracle:");
|
||||
mgr.print_oracle_error();
|
||||
}
|
||||
if (!bret) {
|
||||
printf("\nOceanBase:");
|
||||
print_not_found(NONE, error_code, -1);
|
||||
bret = true;
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
bool add_os_info(int error_code, ObErrorInfoMgr* mgr)
|
||||
{
|
||||
bool bret = false;
|
||||
if (nullptr == mgr) {
|
||||
ERROR_PRINT("ObErrorInfoMgr *mgr is null.\n");
|
||||
bret = true;
|
||||
} else if (0 == error_code) {
|
||||
bret = true;
|
||||
} else if (0 < error_code && OS_MAX_ERROR_CODE > error_code) {
|
||||
int ob_error = 0;
|
||||
int info_count = 0;
|
||||
for (int i = 0; i < OS_MAX_SAME_ERROR_COUNT; i++) {
|
||||
if (-1 == g_os_error[error_code][i]) {
|
||||
break;
|
||||
} else {
|
||||
ob_error = g_os_error[error_code][i];
|
||||
const char* error_msg = str_os_error_msg(-ob_error);
|
||||
if (nullptr != error_msg) {
|
||||
const char* error_name = str_os_error_name(-ob_error);
|
||||
if (mgr->insert_os_error(error_name + strlen("OS_"), error_msg, error_code)) {
|
||||
info_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bret = (0 != info_count);
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
bool add_ob_info(int error_code, ObErrorInfoMgr* mgr)
|
||||
{
|
||||
bool bret = false;
|
||||
if (nullptr == mgr) {
|
||||
ERROR_PRINT("ObErrorInfoMgr *mgr is null.\n");
|
||||
bret = true;
|
||||
} else if (0 <= error_code && OB_MAX_ERROR_CODE > error_code) {
|
||||
if (0 == error_code) {
|
||||
const char* error_msg = "It is not an error.";
|
||||
const char* error_name = ob_error_name(-error_code);
|
||||
const char* error_cause = ob_error_cause(-error_code);
|
||||
const char* error_solution = ob_error_solution(-error_code);
|
||||
if (mgr->insert_ob_error(error_name, error_msg, error_cause, error_solution, error_code)) {
|
||||
bret = true;
|
||||
}
|
||||
} else if (-1 == g_mysql_error[error_code][0]) {
|
||||
const char* error_usr_msg = ob_errpkt_str_user_error(-error_code, false);
|
||||
if (nullptr != error_usr_msg) {
|
||||
const char* error_msg = ob_errpkt_strerror(-error_code, false);
|
||||
const char* error_name = ob_error_name(-error_code);
|
||||
const char* error_cause = ob_error_cause(-error_code);
|
||||
const char* error_solution = ob_error_solution(-error_code);
|
||||
if (mgr->insert_ob_error(error_name, error_msg, error_cause, error_solution, error_code)) {
|
||||
bret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
static bool add_error_info(int error_code, Fac facility, int g_error[][OB_MAX_SAME_ERROR_COUNT], ObErrorInfoMgr* mgr)
|
||||
{
|
||||
bool bret = false;
|
||||
int ob_error = 0;
|
||||
int info_count = 0;
|
||||
if (nullptr == mgr) {
|
||||
ERROR_PRINT("ObErrorInfoMgr *mgr is null.\n");
|
||||
bret = true;
|
||||
} else if (0 <= error_code) {
|
||||
for (int i = 0; i < OB_MAX_SAME_ERROR_COUNT; i++) {
|
||||
if (-1 == g_error[error_code][i]) {
|
||||
break;
|
||||
} else {
|
||||
ob_error = g_error[error_code][i];
|
||||
const char* error_usr_msg = ob_errpkt_str_user_error(-ob_error, MY > facility);
|
||||
if (nullptr != error_usr_msg) {
|
||||
const char* error_msg = ob_errpkt_strerror(-ob_error, MY > facility);
|
||||
const char* error_name = ob_error_name(-ob_error);
|
||||
const char* error_cause = ob_error_cause(-ob_error);
|
||||
const char* error_solution = ob_error_solution(-ob_error);
|
||||
if (MY > facility) {
|
||||
if (mgr->insert_oracle_error(error_name,
|
||||
error_msg + ORACLE_MSG_PREFIX,
|
||||
error_cause,
|
||||
error_solution,
|
||||
facility,
|
||||
error_code,
|
||||
ob_error)) {
|
||||
info_count++;
|
||||
}
|
||||
} else {
|
||||
const char* sqlstate = ob_sqlstate(-ob_error);
|
||||
if (mgr->insert_mysql_error(
|
||||
error_name, error_msg, error_code, sqlstate, error_cause, error_solution, ob_error)) {
|
||||
info_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bret = (0 != info_count);
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
bool add_mysql_info(int error_code, ObErrorInfoMgr* mgr)
|
||||
{
|
||||
bool bret = false;
|
||||
if (nullptr == mgr) {
|
||||
ERROR_PRINT("ObErrorInfoMgr *mgr is null.\n");
|
||||
bret = true;
|
||||
} else if (0 <= error_code && OB_MAX_ERROR_CODE > error_code) {
|
||||
if (-1 != g_mysql_error[error_code][0]) {
|
||||
// map is not emtpy which means MySQL error exists
|
||||
bret = add_error_info(error_code, MY, g_mysql_error, mgr);
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
bool add_oracle_info(Fac oracle_facility, int error_code, int argument, ObErrorInfoMgr* mgr)
|
||||
{
|
||||
bool bret = false;
|
||||
if (nullptr == mgr) {
|
||||
ERROR_PRINT("ObErrorInfoMgr *mgr is null.\n");
|
||||
bret = true;
|
||||
} else if (0 <= error_code && ORACLE_MAX_ERROR_CODE > error_code) {
|
||||
int info_count = 0;
|
||||
int ob_error = -1;
|
||||
// Before being called, ensure that argument cannot be set when nullptr == oracle_facility
|
||||
if (NONE == oracle_facility) {
|
||||
// Handle the case where error is ORA-error_code
|
||||
bret |= add_error_info(error_code, ORA, g_oracle_ora, mgr);
|
||||
// Handle the case where error is PLS-error_code
|
||||
bret |= add_error_info(error_code, PLS, g_oracle_pls, mgr);
|
||||
} else {
|
||||
if (ORA == oracle_facility) {
|
||||
if (ORACLE_SPECIAL_ERROR_CODE == error_code) {
|
||||
// 600 is a special error code.
|
||||
// If there is no '-a ARG' parameter, the original possible error of ora-00600 will be output
|
||||
if (-1 == argument) {
|
||||
bret = add_error_info(error_code, ORA, g_oracle_ora, mgr);
|
||||
} else {
|
||||
ob_error = argument;
|
||||
const char* error_usr_msg = ob_errpkt_str_user_error(-ob_error, true);
|
||||
if (nullptr != error_usr_msg) {
|
||||
// verify that the error is ora-00600
|
||||
if (-OB_ERR_PROXY_REROUTE == ob_errpkt_errno(-ob_error, true) ||
|
||||
ORACLE_SPECIAL_ERROR_CODE == ob_errpkt_errno(-ob_error, true)) {
|
||||
const char* error_msg = ob_errpkt_strerror(-ob_error, true);
|
||||
const char* error_name = ob_error_name(-ob_error);
|
||||
const char* error_cause = ob_error_cause(-ob_error);
|
||||
const char* error_solution = ob_error_solution(-ob_error);
|
||||
if (mgr->insert_oracle_error(error_name,
|
||||
error_msg + ORACLE_MSG_PREFIX,
|
||||
error_cause,
|
||||
error_solution,
|
||||
ORA,
|
||||
error_code,
|
||||
ob_error)) {
|
||||
bret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// '-a ARG' parameter only supports ora-00600 error
|
||||
if (-1 != argument) {
|
||||
printf("error: '-a ARG' is unsupport in this scene\n"
|
||||
"Use 'ob_error ora 600 -a=ARG'.\n"
|
||||
"Use 'ob_error --help' for help.\n");
|
||||
bret = true;
|
||||
} else {
|
||||
bret = add_error_info(error_code, ORA, g_oracle_ora, mgr);
|
||||
}
|
||||
}
|
||||
} else if (PLS == oracle_facility) {
|
||||
// '-a ARG' parameter only supports ora-00600 error
|
||||
if (-1 != argument) {
|
||||
printf("error: '-a ARG' is unsupport in this scene\n"
|
||||
"Use 'ob_error ora 600 -a ARG'.\n"
|
||||
"Use 'ob_error --help' for help.\n");
|
||||
bret = true;
|
||||
} else {
|
||||
bret = add_error_info(error_code, PLS, g_oracle_pls, mgr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
// prevent the atoi parse "123abc"
|
||||
void parse_error_code(const char* argv, int& error_code)
|
||||
{
|
||||
int len = 0;
|
||||
int code = 0;
|
||||
if (nullptr != argv) {
|
||||
len = strlen(argv);
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (argv[i] <= '9' && argv[i] >= '0') {
|
||||
int tmp_code = code * 10 + (argv[i] - '0');
|
||||
if (code > tmp_code) { // overflow
|
||||
code = -1;
|
||||
break;
|
||||
} else {
|
||||
code = tmp_code;
|
||||
}
|
||||
} else {
|
||||
code = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
error_code = code;
|
||||
}
|
||||
}
|
||||
|
||||
void parse_facility(const char* argv, Fac& facility)
|
||||
{
|
||||
if (nullptr != argv) {
|
||||
if (0 == strcasecmp(argv, facility_str[ORA])) {
|
||||
facility = ORA;
|
||||
} else if (0 == strcasecmp(argv, facility_str[PLS])) {
|
||||
facility = PLS;
|
||||
} else if (0 == strcasecmp(argv, facility_str[MY])) {
|
||||
facility = MY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool parse_param(int args, char* argv[])
|
||||
{
|
||||
bool bret = false;
|
||||
Fac facility = NONE;
|
||||
int error_code = -1;
|
||||
int argument = -1;
|
||||
|
||||
if (1 < args && 5 >= args) {
|
||||
parse_facility(argv[1], facility);
|
||||
if (NONE == facility) {
|
||||
parse_error_code(argv[1], error_code);
|
||||
} else if (2 < args) {
|
||||
parse_error_code(argv[2], error_code);
|
||||
}
|
||||
|
||||
extern char* optarg;
|
||||
extern int opterr;
|
||||
|
||||
opterr = 0; // getpot_long will not print error messages
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{"help", 0, 0, 'h'}, {"version", 0, 0, 'V'}, {"argument", 1, 0, 'a'}, {0, 0, 0, 0}};
|
||||
|
||||
int c = getopt_long(args, argv, ":hVa:", long_options, &option_index);
|
||||
if (-1 != c) {
|
||||
switch (c) {
|
||||
case 'h': {
|
||||
print_help();
|
||||
bret = true;
|
||||
break;
|
||||
}
|
||||
case 'V': {
|
||||
print_version();
|
||||
bret = true;
|
||||
break;
|
||||
}
|
||||
case 'a': {
|
||||
if (ORA == facility && ORACLE_SPECIAL_ERROR_CODE == error_code) {
|
||||
parse_error_code(optarg, argument);
|
||||
if (-1 == argument) {
|
||||
printf("error: '-a ARG': ARG should be a number\n"
|
||||
"Use 'ob_error --help' for help.\n");
|
||||
bret = true;
|
||||
}
|
||||
} else {
|
||||
printf("error: '-a ARG' is unsupport in this scene\n"
|
||||
"Use 'ob_error ora 600 -a ARG'.\n"
|
||||
"Use 'ob_error --help' for help.\n");
|
||||
bret = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ':': {
|
||||
printf("error: '-a' missing parameter\n"
|
||||
"Use 'ob_error --help' for help.\n");
|
||||
bret = true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
printf("error: parameters invalid\n"
|
||||
"Use 'ob_error --help' for help.\n");
|
||||
bret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bret) {
|
||||
if (-1 == error_code) {
|
||||
printf("error: 'facility' invalid or 'error_code' may overflow or not be a positive number\n"
|
||||
"Use 'ob_error --help' for help.\n");
|
||||
bret = true;
|
||||
} else {
|
||||
bret = print_error_info(facility, error_code, argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bret;
|
||||
}
|
||||
|
||||
static bool insert_oracle_error_slot_ora(int err_map[][OB_MAX_SAME_ERROR_COUNT], int error_code, int ob_error)
|
||||
{
|
||||
bool bret = true;
|
||||
int k = 0;
|
||||
if (0 > error_code || ORACLE_MAX_ERROR_CODE < error_code) {
|
||||
ERROR_PRINT("error: error_code invalid.\n");
|
||||
bret = false;
|
||||
} else {
|
||||
for (k = 0; k < OB_MAX_SAME_ERROR_COUNT; k++) {
|
||||
if (-1 == err_map[error_code][k]) {
|
||||
if (ORACLE_SPECIAL_ERROR_CODE == error_code) {
|
||||
// Compatible error for ORA-00600
|
||||
if (OB_AUTOINC_SERVICE_BUSY == -ob_error || OB_ROWID_TYPE_MISMATCH == -ob_error ||
|
||||
OB_ROWID_NUM_MISMATCH == -ob_error) {
|
||||
err_map[error_code][k] = ob_error;
|
||||
}
|
||||
} else {
|
||||
err_map[error_code][k] = ob_error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (OB_MAX_SAME_ERROR_COUNT <= k) {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
static bool insert_oracle_error_slot_pls(int err_map[][OB_MAX_SAME_ERROR_COUNT], int error_code, int ob_error)
|
||||
{
|
||||
bool bret = true;
|
||||
int k = 0;
|
||||
if (0 > error_code || ORACLE_MAX_ERROR_CODE < error_code) {
|
||||
ERROR_PRINT("error: error_code invalid.\n");
|
||||
bret = false;
|
||||
} else {
|
||||
for (k = 0; k < OB_MAX_SAME_ERROR_COUNT; k++) {
|
||||
if (-1 == err_map[error_code][k]) {
|
||||
err_map[error_code][k] = ob_error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (OB_MAX_SAME_ERROR_COUNT <= k) {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
static bool insert_mysql_error_slot(int err_map[][OB_MAX_SAME_ERROR_COUNT], int error_code, int ob_error)
|
||||
{
|
||||
bool bret = true;
|
||||
int k = 0;
|
||||
if (0 > error_code || OB_MAX_ERROR_CODE < error_code) {
|
||||
ERROR_PRINT("error: error_code invalid.\n");
|
||||
bret = false;
|
||||
} else {
|
||||
for (k = 0; k < OB_MAX_SAME_ERROR_COUNT; k++) {
|
||||
if (-1 == err_map[error_code][k]) {
|
||||
err_map[error_code][k] = ob_error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (OB_MAX_SAME_ERROR_COUNT <= k) {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
static bool insert_os_error_slot(int err_map[][OS_MAX_SAME_ERROR_COUNT], int error_code, int ob_error)
|
||||
{
|
||||
bool bret = true;
|
||||
int k = 0;
|
||||
if (0 > error_code || OS_MAX_ERROR_CODE < error_code) {
|
||||
ERROR_PRINT("error: error_code invalid.\n");
|
||||
bret = false;
|
||||
} else {
|
||||
for (k = 0; k < OS_MAX_SAME_ERROR_COUNT; k++) {
|
||||
if (-1 == err_map[error_code][k]) {
|
||||
err_map[error_code][k] = ob_error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (OS_MAX_SAME_ERROR_COUNT <= k) {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
static bool ob_init_error_to_oberror(int ora_err[][OB_MAX_SAME_ERROR_COUNT], int pls_err[][OB_MAX_SAME_ERROR_COUNT],
|
||||
int mysql_err[][OB_MAX_SAME_ERROR_COUNT], int os_err[][OS_MAX_SAME_ERROR_COUNT])
|
||||
{
|
||||
bool bret = true;
|
||||
int error_code = -1;
|
||||
int k = 0;
|
||||
// init os_err map
|
||||
for (int i = 0; i < OS_MAX_ERROR_CODE; i++) {
|
||||
error_code = os_errno(-i);
|
||||
if (-1 != error_code && 0 != error_code) {
|
||||
if (!insert_os_error_slot(os_err, error_code, i)) {
|
||||
bret = false;
|
||||
ERROR_PRINT("error: OS_MAX_SAME_ERROR_COUNT is not enough for OS Error %d(OB Error %d)\n", error_code, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
// init mysql_err/ora_err/pls_err map
|
||||
for (int i = 0; i < OB_MAX_ERROR_CODE; i++) {
|
||||
// init mysql_err map
|
||||
error_code = ob_mysql_errno(-i);
|
||||
if (-1 != error_code && 0 != error_code) {
|
||||
if (0 > error_code)
|
||||
error_code = -error_code;
|
||||
if (!insert_mysql_error_slot(mysql_err, error_code, i)) {
|
||||
ERROR_PRINT("error: OB_MAX_SAME_ERROR_COUNT is not enough for Error %d(OB Error %d)\n", error_code, i);
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
// init ora_err/pls_err map
|
||||
const char* error_usr_msg = ob_oracle_str_user_error(-i);
|
||||
error_code = ob_oracle_errno(-i);
|
||||
if (-1 != error_code && NULL != error_usr_msg) {
|
||||
if (0 > error_code)
|
||||
error_code = -error_code;
|
||||
if (0 == strncmp(error_usr_msg, facility_str[ORA], strlen(facility_str[ORA]))) {
|
||||
if (!insert_oracle_error_slot_ora(ora_err, error_code, i)) {
|
||||
ERROR_PRINT("error: OB_MAX_SAME_ERROR_COUNT is not enough for ORA-%05d(OB Error %d)\n", error_code, i);
|
||||
bret = false;
|
||||
}
|
||||
} else if (0 == strncmp(error_usr_msg, facility_str[PLS], strlen(facility_str[PLS]))) {
|
||||
if (!insert_oracle_error_slot_pls(pls_err, error_code, i)) {
|
||||
ERROR_PRINT("error: OB_MAX_SAME_ERROR_COUNT is not enough for PLS-%05d(OB Error %d)\n", error_code, i);
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
bool init_global_info()
|
||||
{
|
||||
memset(g_oracle_ora, -1, sizeof(g_oracle_ora));
|
||||
memset(g_oracle_pls, -1, sizeof(g_oracle_pls));
|
||||
memset(g_mysql_error, -1, sizeof(g_mysql_error));
|
||||
memset(g_os_error, -1, sizeof(g_os_error));
|
||||
|
||||
return ob_init_error_to_oberror(g_oracle_ora, g_oracle_pls, g_mysql_error, g_os_error);
|
||||
}
|
||||
|
||||
int main(int args, char* argv[])
|
||||
{
|
||||
if (!init_global_info()) {
|
||||
printf("\nerror: ob_error init failed.\n");
|
||||
} else if (1 < args) {
|
||||
if (!parse_param(args, argv)) {
|
||||
printf("error: parameters invalid\n"
|
||||
"Use 'ob_error --help' for help.\n");
|
||||
}
|
||||
} else {
|
||||
printf("error: missing parameter\n"
|
||||
"Use 'ob_error --help' for help.\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
256
tools/ob_error/src/ob_error.h
Normal file
256
tools/ob_error/src/ob_error.h
Normal file
@ -0,0 +1,256 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OBERROR_ERROR_H
|
||||
#define OBERROR_ERROR_H
|
||||
|
||||
#include "share/ob_errno.h"
|
||||
#include "os_errno.h"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
using namespace oceanbase::common;
|
||||
|
||||
// code error print define
|
||||
#define ERROR_PRINT(fmt, ...) printf("%s[%d]-<%s>: " #fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)
|
||||
|
||||
enum Fac {
|
||||
ORA, // oracle mode // ora
|
||||
PLS, // oracle mode // pls
|
||||
MY, // mysql mode
|
||||
NONE
|
||||
};
|
||||
|
||||
struct OSErrorInfo {
|
||||
public:
|
||||
OSErrorInfo() : error_name_(nullptr), error_msg_(nullptr), error_code_(-1)
|
||||
{}
|
||||
virtual ~OSErrorInfo()
|
||||
{}
|
||||
void free_space()
|
||||
{
|
||||
if (nullptr != error_name_) {
|
||||
free(error_name_);
|
||||
error_name_ = nullptr;
|
||||
}
|
||||
if (nullptr != error_msg_) {
|
||||
free(error_msg_);
|
||||
error_msg_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
char* error_name_;
|
||||
char* error_msg_;
|
||||
int error_code_;
|
||||
};
|
||||
|
||||
struct MySQLErrorInfo {
|
||||
public:
|
||||
MySQLErrorInfo()
|
||||
: error_name_(nullptr),
|
||||
error_msg_(nullptr),
|
||||
mysql_errno_(-1),
|
||||
sqlstate_(nullptr),
|
||||
cause_(nullptr),
|
||||
solution_(nullptr),
|
||||
ob_error_(-1)
|
||||
{}
|
||||
virtual ~MySQLErrorInfo()
|
||||
{}
|
||||
void free_space()
|
||||
{
|
||||
if (nullptr != error_name_) {
|
||||
free(error_name_);
|
||||
error_name_ = nullptr;
|
||||
}
|
||||
if (nullptr != error_msg_) {
|
||||
free(error_msg_);
|
||||
error_msg_ = nullptr;
|
||||
}
|
||||
if (nullptr != sqlstate_) {
|
||||
free(sqlstate_);
|
||||
sqlstate_ = nullptr;
|
||||
}
|
||||
if (nullptr != cause_) {
|
||||
free(cause_);
|
||||
cause_ = nullptr;
|
||||
}
|
||||
if (nullptr != solution_) {
|
||||
free(solution_);
|
||||
solution_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
char* error_name_;
|
||||
char* error_msg_;
|
||||
int mysql_errno_;
|
||||
char* sqlstate_;
|
||||
char* cause_;
|
||||
char* solution_;
|
||||
int ob_error_;
|
||||
};
|
||||
|
||||
struct OracleErrorInfo {
|
||||
public:
|
||||
OracleErrorInfo()
|
||||
: error_name_(nullptr),
|
||||
error_msg_(nullptr),
|
||||
cause_(nullptr),
|
||||
solution_(nullptr),
|
||||
facility_(NONE),
|
||||
error_code_(-1),
|
||||
ob_error_(-1)
|
||||
{}
|
||||
virtual ~OracleErrorInfo()
|
||||
{}
|
||||
void free_space()
|
||||
{
|
||||
if (nullptr != error_name_) {
|
||||
free(error_name_);
|
||||
error_name_ = nullptr;
|
||||
}
|
||||
if (nullptr != error_msg_) {
|
||||
free(error_msg_);
|
||||
error_msg_ = nullptr;
|
||||
}
|
||||
if (nullptr != cause_) {
|
||||
free(cause_);
|
||||
cause_ = nullptr;
|
||||
}
|
||||
if (nullptr != solution_) {
|
||||
free(solution_);
|
||||
solution_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
char* error_name_;
|
||||
char* error_msg_;
|
||||
char* cause_;
|
||||
char* solution_;
|
||||
Fac facility_;
|
||||
int error_code_;
|
||||
int ob_error_;
|
||||
};
|
||||
|
||||
struct OBErrorInfo {
|
||||
public:
|
||||
OBErrorInfo() : error_name_(nullptr), error_msg_(nullptr), cause_(nullptr), solution_(nullptr), error_code_(-1)
|
||||
{}
|
||||
virtual ~OBErrorInfo()
|
||||
{}
|
||||
void free_space()
|
||||
{
|
||||
if (nullptr != error_name_) {
|
||||
free(error_name_);
|
||||
error_name_ = nullptr;
|
||||
}
|
||||
if (nullptr != error_msg_) {
|
||||
free(error_msg_);
|
||||
error_msg_ = nullptr;
|
||||
}
|
||||
if (nullptr != cause_) {
|
||||
free(cause_);
|
||||
cause_ = nullptr;
|
||||
}
|
||||
if (nullptr != solution_) {
|
||||
free(solution_);
|
||||
solution_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
char* error_name_;
|
||||
char* error_msg_;
|
||||
char* cause_;
|
||||
char* solution_;
|
||||
int error_code_;
|
||||
};
|
||||
|
||||
// The length of the second dimension, in order to solve the conflict of multiple identical error codes
|
||||
constexpr int OB_MAX_SAME_ERROR_COUNT = 10;
|
||||
constexpr int ORACLE_SPECIAL_ERROR_CODE = 600;
|
||||
constexpr int ORACLE_MAX_ERROR_CODE = 65535;
|
||||
constexpr int ORACLE_MSG_PREFIX = 11; // strlen("ORA-00000: ")
|
||||
constexpr float OB_ERROR_VERSION = 1.0;
|
||||
|
||||
static const char* facility_str[NONE] = {"ORA", "PLS", "MY"};
|
||||
|
||||
class ObErrorInfoMgr {
|
||||
public:
|
||||
ObErrorInfoMgr();
|
||||
virtual ~ObErrorInfoMgr();
|
||||
|
||||
bool insert_os_error(const char* name, const char* msg, int error_code);
|
||||
void print_os_error();
|
||||
bool is_os_error_exist()
|
||||
{
|
||||
return 0 < os_error_count_;
|
||||
}
|
||||
|
||||
bool insert_mysql_error(const char* name, const char* msg, int mysql_errno, const char* sqlstate, const char* cause,
|
||||
const char* solution, int ob_error);
|
||||
void print_mysql_error();
|
||||
bool is_mysql_error_exist()
|
||||
{
|
||||
return 0 < mysql_error_count_;
|
||||
}
|
||||
|
||||
bool insert_oracle_error(const char* name, const char* msg, const char* cause, const char* solution, Fac facility,
|
||||
int error_code, int ob_error);
|
||||
void print_oracle_error();
|
||||
bool is_oracle_error_exist()
|
||||
{
|
||||
return 0 < oracle_error_count_;
|
||||
}
|
||||
|
||||
bool insert_ob_error(const char* name, const char* msg, const char* cause, const char* solution, int error_code);
|
||||
void print_ob_error();
|
||||
bool is_ob_error_exist()
|
||||
{
|
||||
return 0 < ob_error_count_;
|
||||
}
|
||||
|
||||
private:
|
||||
int os_error_count_;
|
||||
OSErrorInfo os_error_[OS_MAX_SAME_ERROR_COUNT];
|
||||
int mysql_error_count_;
|
||||
MySQLErrorInfo mysql_error_[OB_MAX_SAME_ERROR_COUNT];
|
||||
int oracle_error_count_;
|
||||
OracleErrorInfo oracle_error_[OB_MAX_SAME_ERROR_COUNT];
|
||||
int ob_error_count_;
|
||||
OBErrorInfo ob_error_[OB_MAX_SAME_ERROR_COUNT];
|
||||
};
|
||||
|
||||
// oracle error code -> ob error map // Maximum number of identical error codes is OB_MAX_SAME_ERROR_COUNT
|
||||
static int g_oracle_ora[ORACLE_MAX_ERROR_CODE][OB_MAX_SAME_ERROR_COUNT];
|
||||
static int g_oracle_pls[ORACLE_MAX_ERROR_CODE][OB_MAX_SAME_ERROR_COUNT];
|
||||
// mysql error code -> ob error map // Maximum number of identical error codes is OB_MAX_SAME_ERROR_COUNT
|
||||
static int g_mysql_error[OB_MAX_ERROR_CODE][OB_MAX_SAME_ERROR_COUNT];
|
||||
// os error code -> ob error map // Maximum number of identical error codes is OS_MAX_SAME_ERROR_COUNT
|
||||
static int g_os_error[OS_MAX_ERROR_CODE][OS_MAX_SAME_ERROR_COUNT];
|
||||
|
||||
// adder
|
||||
bool add_os_info(int error_code, ObErrorInfoMgr* mgr);
|
||||
bool add_ob_info(int error_code, ObErrorInfoMgr* mgr);
|
||||
bool add_oracle_info(Fac oracle_facility, int error_code, int argument, ObErrorInfoMgr* mgr);
|
||||
bool add_mysql_info(int error_code, ObErrorInfoMgr* mgr);
|
||||
|
||||
// parser
|
||||
void parse_error_code(const char* argv, int& error_code);
|
||||
void parse_facility(const char* argv, Fac& facility);
|
||||
bool parse_param(int args, char* argv[]);
|
||||
|
||||
// printer
|
||||
bool print_error_info(Fac facility, int error_code, int argument);
|
||||
|
||||
// init
|
||||
bool init_global_info();
|
||||
|
||||
#endif /* OBERROR_ERROR_H */
|
464
tools/ob_error/src/os_errno.cpp
Normal file
464
tools/ob_error/src/os_errno.cpp
Normal file
@ -0,0 +1,464 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated from `ob_errno.def'.
|
||||
|
||||
#include "os_errno.h"
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
using namespace oceanbase::common;
|
||||
|
||||
static const char* OS_ERRNO_NAME[OS_MAX_ERROR_CODE];
|
||||
static const char* OS_ERRNO_MSG[OS_MAX_ERROR_CODE];
|
||||
static int OS_ERRNO[OS_MAX_ERROR_CODE];
|
||||
|
||||
static struct OSStrErrorInit {
|
||||
OSStrErrorInit()
|
||||
{
|
||||
memset(OS_ERRNO_NAME, 0, sizeof(OS_ERRNO_NAME));
|
||||
memset(OS_ERRNO_MSG, 0, sizeof(OS_ERRNO_MSG));
|
||||
memset(OS_ERRNO, 0, sizeof(OS_ERRNO));
|
||||
|
||||
OS_ERRNO_NAME[-OS_ENOENT] = "OS_ENOENT";
|
||||
OS_ERRNO_MSG[-OS_ENOENT] = "No such file or directory";
|
||||
OS_ERRNO[-OS_ENOENT] = 2;
|
||||
OS_ERRNO_NAME[-OS_ESRCH] = "OS_ESRCH";
|
||||
OS_ERRNO_MSG[-OS_ESRCH] = "No such process";
|
||||
OS_ERRNO[-OS_ESRCH] = 3;
|
||||
OS_ERRNO_NAME[-OS_EINTR] = "OS_EINTR";
|
||||
OS_ERRNO_MSG[-OS_EINTR] = "Interrupted system call";
|
||||
OS_ERRNO[-OS_EINTR] = 4;
|
||||
OS_ERRNO_NAME[-OS_EIO] = "OS_EIO";
|
||||
OS_ERRNO_MSG[-OS_EIO] = "I/O error";
|
||||
OS_ERRNO[-OS_EIO] = 5;
|
||||
OS_ERRNO_NAME[-OS_ENXIO] = "OS_ENXIO";
|
||||
OS_ERRNO_MSG[-OS_ENXIO] = "No such device or address";
|
||||
OS_ERRNO[-OS_ENXIO] = 6;
|
||||
OS_ERRNO_NAME[-OS_E2BIG] = "OS_E2BIG";
|
||||
OS_ERRNO_MSG[-OS_E2BIG] = "Argument list too long";
|
||||
OS_ERRNO[-OS_E2BIG] = 7;
|
||||
OS_ERRNO_NAME[-OS_ENOEXEC] = "OS_ENOEXEC";
|
||||
OS_ERRNO_MSG[-OS_ENOEXEC] = "Exec format error";
|
||||
OS_ERRNO[-OS_ENOEXEC] = 8;
|
||||
OS_ERRNO_NAME[-OS_EBADF] = "OS_EBADF";
|
||||
OS_ERRNO_MSG[-OS_EBADF] = "Bad file number";
|
||||
OS_ERRNO[-OS_EBADF] = 9;
|
||||
OS_ERRNO_NAME[-OS_ECHILD] = "OS_ECHILD";
|
||||
OS_ERRNO_MSG[-OS_ECHILD] = "No child processes";
|
||||
OS_ERRNO[-OS_ECHILD] = 10;
|
||||
OS_ERRNO_NAME[-OS_EAGAIN] = "OS_EAGAIN";
|
||||
OS_ERRNO_MSG[-OS_EAGAIN] = "Try again";
|
||||
OS_ERRNO[-OS_EAGAIN] = 11;
|
||||
OS_ERRNO_NAME[-OS_ENOMEM] = "OS_ENOMEM";
|
||||
OS_ERRNO_MSG[-OS_ENOMEM] = "Out of memory";
|
||||
OS_ERRNO[-OS_ENOMEM] = 12;
|
||||
OS_ERRNO_NAME[-OS_EACCES] = "OS_EACCES";
|
||||
OS_ERRNO_MSG[-OS_EACCES] = "Permission denied";
|
||||
OS_ERRNO[-OS_EACCES] = 13;
|
||||
OS_ERRNO_NAME[-OS_EFAULT] = "OS_EFAULT";
|
||||
OS_ERRNO_MSG[-OS_EFAULT] = "Bad address";
|
||||
OS_ERRNO[-OS_EFAULT] = 14;
|
||||
OS_ERRNO_NAME[-OS_ENOTBLK] = "OS_ENOTBLK";
|
||||
OS_ERRNO_MSG[-OS_ENOTBLK] = "Block device required";
|
||||
OS_ERRNO[-OS_ENOTBLK] = 15;
|
||||
OS_ERRNO_NAME[-OS_EBUSY] = "OS_EBUSY";
|
||||
OS_ERRNO_MSG[-OS_EBUSY] = "Device or resource busy";
|
||||
OS_ERRNO[-OS_EBUSY] = 16;
|
||||
OS_ERRNO_NAME[-OS_EEXIST] = "OS_EEXIST";
|
||||
OS_ERRNO_MSG[-OS_EEXIST] = "File exists";
|
||||
OS_ERRNO[-OS_EEXIST] = 17;
|
||||
OS_ERRNO_NAME[-OS_EXDEV] = "OS_EXDEV";
|
||||
OS_ERRNO_MSG[-OS_EXDEV] = "Cross-device link";
|
||||
OS_ERRNO[-OS_EXDEV] = 18;
|
||||
OS_ERRNO_NAME[-OS_ENODEV] = "OS_ENODEV";
|
||||
OS_ERRNO_MSG[-OS_ENODEV] = "No such device";
|
||||
OS_ERRNO[-OS_ENODEV] = 19;
|
||||
OS_ERRNO_NAME[-OS_ENOTDIR] = "OS_ENOTDIR";
|
||||
OS_ERRNO_MSG[-OS_ENOTDIR] = "Not a directory";
|
||||
OS_ERRNO[-OS_ENOTDIR] = 20;
|
||||
OS_ERRNO_NAME[-OS_EISDIR] = "OS_EISDIR";
|
||||
OS_ERRNO_MSG[-OS_EISDIR] = "Is a directory";
|
||||
OS_ERRNO[-OS_EISDIR] = 21;
|
||||
OS_ERRNO_NAME[-OS_EINVAL] = "OS_EINVAL";
|
||||
OS_ERRNO_MSG[-OS_EINVAL] = "Invalid argument";
|
||||
OS_ERRNO[-OS_EINVAL] = 22;
|
||||
OS_ERRNO_NAME[-OS_ENFILE] = "OS_ENFILE";
|
||||
OS_ERRNO_MSG[-OS_ENFILE] = "File table overflow";
|
||||
OS_ERRNO[-OS_ENFILE] = 23;
|
||||
OS_ERRNO_NAME[-OS_EMFILE] = "OS_EMFILE";
|
||||
OS_ERRNO_MSG[-OS_EMFILE] = "Too many open files";
|
||||
OS_ERRNO[-OS_EMFILE] = 24;
|
||||
OS_ERRNO_NAME[-OS_ENOTTY] = "OS_ENOTTY";
|
||||
OS_ERRNO_MSG[-OS_ENOTTY] = "Not a typewriter";
|
||||
OS_ERRNO[-OS_ENOTTY] = 25;
|
||||
OS_ERRNO_NAME[-OS_ETXTBSY] = "OS_ETXTBSY";
|
||||
OS_ERRNO_MSG[-OS_ETXTBSY] = "Text file busy";
|
||||
OS_ERRNO[-OS_ETXTBSY] = 26;
|
||||
OS_ERRNO_NAME[-OS_EFBIG] = "OS_EFBIG";
|
||||
OS_ERRNO_MSG[-OS_EFBIG] = "File too large";
|
||||
OS_ERRNO[-OS_EFBIG] = 27;
|
||||
OS_ERRNO_NAME[-OS_ENOSPC] = "OS_ENOSPC";
|
||||
OS_ERRNO_MSG[-OS_ENOSPC] = "No space left on device";
|
||||
OS_ERRNO[-OS_ENOSPC] = 28;
|
||||
OS_ERRNO_NAME[-OS_ESPIPE] = "OS_ESPIPE";
|
||||
OS_ERRNO_MSG[-OS_ESPIPE] = "Illegal seek";
|
||||
OS_ERRNO[-OS_ESPIPE] = 29;
|
||||
OS_ERRNO_NAME[-OS_EROFS] = "OS_EROFS";
|
||||
OS_ERRNO_MSG[-OS_EROFS] = "Read-only file system";
|
||||
OS_ERRNO[-OS_EROFS] = 30;
|
||||
OS_ERRNO_NAME[-OS_EMLINK] = "OS_EMLINK";
|
||||
OS_ERRNO_MSG[-OS_EMLINK] = "Too many links";
|
||||
OS_ERRNO[-OS_EMLINK] = 31;
|
||||
OS_ERRNO_NAME[-OS_EPIPE] = "OS_EPIPE";
|
||||
OS_ERRNO_MSG[-OS_EPIPE] = "Broken pipe";
|
||||
OS_ERRNO[-OS_EPIPE] = 32;
|
||||
OS_ERRNO_NAME[-OS_EDOM] = "OS_EDOM";
|
||||
OS_ERRNO_MSG[-OS_EDOM] = "Math argument out of domain of func";
|
||||
OS_ERRNO[-OS_EDOM] = 33;
|
||||
OS_ERRNO_NAME[-OS_ERANGE] = "OS_ERANGE";
|
||||
OS_ERRNO_MSG[-OS_ERANGE] = "Math result not representable";
|
||||
OS_ERRNO[-OS_ERANGE] = 34;
|
||||
OS_ERRNO_NAME[-OS_EDEADLK] = "OS_EDEADLK";
|
||||
OS_ERRNO_MSG[-OS_EDEADLK] = "Resource deadlock would occur";
|
||||
OS_ERRNO[-OS_EDEADLK] = 35;
|
||||
OS_ERRNO_NAME[-OS_ENAMETOOLONG] = "OS_ENAMETOOLONG";
|
||||
OS_ERRNO_MSG[-OS_ENAMETOOLONG] = "File name too long";
|
||||
OS_ERRNO[-OS_ENAMETOOLONG] = 36;
|
||||
OS_ERRNO_NAME[-OS_ENOLCK] = "OS_ENOLCK";
|
||||
OS_ERRNO_MSG[-OS_ENOLCK] = "No record locks available";
|
||||
OS_ERRNO[-OS_ENOLCK] = 37;
|
||||
OS_ERRNO_NAME[-OS_ENOSYS] = "OS_ENOSYS";
|
||||
OS_ERRNO_MSG[-OS_ENOSYS] = "Function not implemented";
|
||||
OS_ERRNO[-OS_ENOSYS] = 38;
|
||||
OS_ERRNO_NAME[-OS_ENOTEMPTY] = "OS_ENOTEMPTY";
|
||||
OS_ERRNO_MSG[-OS_ENOTEMPTY] = "Directory not empty";
|
||||
OS_ERRNO[-OS_ENOTEMPTY] = 39;
|
||||
OS_ERRNO_NAME[-OS_ELOOP] = "OS_ELOOP";
|
||||
OS_ERRNO_MSG[-OS_ELOOP] = "Too many symbolic links encountered";
|
||||
OS_ERRNO[-OS_ELOOP] = 40;
|
||||
OS_ERRNO_NAME[-OS_EWOULDBLOCK] = "OS_EWOULDBLOCK";
|
||||
OS_ERRNO_MSG[-OS_EWOULDBLOCK] = "Operation would block";
|
||||
OS_ERRNO[-OS_EWOULDBLOCK] = 11;
|
||||
OS_ERRNO_NAME[-OS_ENOMSG] = "OS_ENOMSG";
|
||||
OS_ERRNO_MSG[-OS_ENOMSG] = "No message of desired type";
|
||||
OS_ERRNO[-OS_ENOMSG] = 42;
|
||||
OS_ERRNO_NAME[-OS_EIDRM] = "OS_EIDRM";
|
||||
OS_ERRNO_MSG[-OS_EIDRM] = "Identifier removed";
|
||||
OS_ERRNO[-OS_EIDRM] = 43;
|
||||
OS_ERRNO_NAME[-OS_ECHRNG] = "OS_ECHRNG";
|
||||
OS_ERRNO_MSG[-OS_ECHRNG] = "Channel number out of range";
|
||||
OS_ERRNO[-OS_ECHRNG] = 44;
|
||||
OS_ERRNO_NAME[-OS_EL2NSYNC] = "OS_EL2NSYNC";
|
||||
OS_ERRNO_MSG[-OS_EL2NSYNC] = "Level 2 not synchronized";
|
||||
OS_ERRNO[-OS_EL2NSYNC] = 45;
|
||||
OS_ERRNO_NAME[-OS_EL3HLT] = "OS_EL3HLT";
|
||||
OS_ERRNO_MSG[-OS_EL3HLT] = "Level 3 halted";
|
||||
OS_ERRNO[-OS_EL3HLT] = 46;
|
||||
OS_ERRNO_NAME[-OS_EL3RST] = "OS_EL3RST";
|
||||
OS_ERRNO_MSG[-OS_EL3RST] = "Level 3 reset";
|
||||
OS_ERRNO[-OS_EL3RST] = 47;
|
||||
OS_ERRNO_NAME[-OS_ELNRNG] = "OS_ELNRNG";
|
||||
OS_ERRNO_MSG[-OS_ELNRNG] = "Link number out of range";
|
||||
OS_ERRNO[-OS_ELNRNG] = 48;
|
||||
OS_ERRNO_NAME[-OS_EUNATCH] = "OS_EUNATCH";
|
||||
OS_ERRNO_MSG[-OS_EUNATCH] = "Protocol driver not attached";
|
||||
OS_ERRNO[-OS_EUNATCH] = 49;
|
||||
OS_ERRNO_NAME[-OS_ENOCSI] = "OS_ENOCSI";
|
||||
OS_ERRNO_MSG[-OS_ENOCSI] = "No CSI structure available";
|
||||
OS_ERRNO[-OS_ENOCSI] = 50;
|
||||
OS_ERRNO_NAME[-OS_EL2HLT] = "OS_EL2HLT";
|
||||
OS_ERRNO_MSG[-OS_EL2HLT] = "Level 2 halted";
|
||||
OS_ERRNO[-OS_EL2HLT] = 51;
|
||||
OS_ERRNO_NAME[-OS_EBADE] = "OS_EBADE";
|
||||
OS_ERRNO_MSG[-OS_EBADE] = "Invalid exchange";
|
||||
OS_ERRNO[-OS_EBADE] = 52;
|
||||
OS_ERRNO_NAME[-OS_EBADR] = "OS_EBADR";
|
||||
OS_ERRNO_MSG[-OS_EBADR] = "Invalid request descriptor";
|
||||
OS_ERRNO[-OS_EBADR] = 53;
|
||||
OS_ERRNO_NAME[-OS_EXFULL] = "OS_EXFULL";
|
||||
OS_ERRNO_MSG[-OS_EXFULL] = "Exchange full";
|
||||
OS_ERRNO[-OS_EXFULL] = 54;
|
||||
OS_ERRNO_NAME[-OS_ENOANO] = "OS_ENOANO";
|
||||
OS_ERRNO_MSG[-OS_ENOANO] = "No anode";
|
||||
OS_ERRNO[-OS_ENOANO] = 55;
|
||||
OS_ERRNO_NAME[-OS_EBADRQC] = "OS_EBADRQC";
|
||||
OS_ERRNO_MSG[-OS_EBADRQC] = "Invalid request code";
|
||||
OS_ERRNO[-OS_EBADRQC] = 56;
|
||||
OS_ERRNO_NAME[-OS_EBADSLT] = "OS_EBADSLT";
|
||||
OS_ERRNO_MSG[-OS_EBADSLT] = "Invalid slot";
|
||||
OS_ERRNO[-OS_EBADSLT] = 57;
|
||||
OS_ERRNO_NAME[-OS_EBFONT] = "OS_EBFONT";
|
||||
OS_ERRNO_MSG[-OS_EBFONT] = "Bad font file format";
|
||||
OS_ERRNO[-OS_EBFONT] = 59;
|
||||
OS_ERRNO_NAME[-OS_ENOSTR] = "OS_ENOSTR";
|
||||
OS_ERRNO_MSG[-OS_ENOSTR] = "Device not a stream";
|
||||
OS_ERRNO[-OS_ENOSTR] = 60;
|
||||
OS_ERRNO_NAME[-OS_ENODATA] = "OS_ENODATA";
|
||||
OS_ERRNO_MSG[-OS_ENODATA] = "No data available";
|
||||
OS_ERRNO[-OS_ENODATA] = 61;
|
||||
OS_ERRNO_NAME[-OS_ETIME] = "OS_ETIME";
|
||||
OS_ERRNO_MSG[-OS_ETIME] = "Timer expired";
|
||||
OS_ERRNO[-OS_ETIME] = 62;
|
||||
OS_ERRNO_NAME[-OS_ENOSR] = "OS_ENOSR";
|
||||
OS_ERRNO_MSG[-OS_ENOSR] = "OOut of streams resources";
|
||||
OS_ERRNO[-OS_ENOSR] = 63;
|
||||
OS_ERRNO_NAME[-OS_ENONET] = "OS_ENONET";
|
||||
OS_ERRNO_MSG[-OS_ENONET] = "Machine is not on the network";
|
||||
OS_ERRNO[-OS_ENONET] = 64;
|
||||
OS_ERRNO_NAME[-OS_ENOPKG] = "OS_ENOPKG";
|
||||
OS_ERRNO_MSG[-OS_ENOPKG] = "Package not installed";
|
||||
OS_ERRNO[-OS_ENOPKG] = 65;
|
||||
OS_ERRNO_NAME[-OS_EREMOTE] = "OS_EREMOTE";
|
||||
OS_ERRNO_MSG[-OS_EREMOTE] = "Object is remote";
|
||||
OS_ERRNO[-OS_EREMOTE] = 66;
|
||||
OS_ERRNO_NAME[-OS_ENOLINK] = "OS_ENOLINK";
|
||||
OS_ERRNO_MSG[-OS_ENOLINK] = "Link has been severed";
|
||||
OS_ERRNO[-OS_ENOLINK] = 67;
|
||||
OS_ERRNO_NAME[-OS_EADV] = "OS_EADV";
|
||||
OS_ERRNO_MSG[-OS_EADV] = "Advertise error";
|
||||
OS_ERRNO[-OS_EADV] = 68;
|
||||
OS_ERRNO_NAME[-OS_ESRMNT] = "OS_ESRMNT";
|
||||
OS_ERRNO_MSG[-OS_ESRMNT] = "Srmount error";
|
||||
OS_ERRNO[-OS_ESRMNT] = 69;
|
||||
OS_ERRNO_NAME[-OS_ECOMM] = "OS_ECOMM";
|
||||
OS_ERRNO_MSG[-OS_ECOMM] = "Communication error on send";
|
||||
OS_ERRNO[-OS_ECOMM] = 70;
|
||||
OS_ERRNO_NAME[-OS_EPROTO] = "OS_EPROTO";
|
||||
OS_ERRNO_MSG[-OS_EPROTO] = "Protocol error";
|
||||
OS_ERRNO[-OS_EPROTO] = 71;
|
||||
OS_ERRNO_NAME[-OS_EMULTIHOP] = "OS_EMULTIHOP";
|
||||
OS_ERRNO_MSG[-OS_EMULTIHOP] = "Multihop attempted";
|
||||
OS_ERRNO[-OS_EMULTIHOP] = 72;
|
||||
OS_ERRNO_NAME[-OS_EDOTDOT] = "OS_EDOTDOT";
|
||||
OS_ERRNO_MSG[-OS_EDOTDOT] = "RFS specific error";
|
||||
OS_ERRNO[-OS_EDOTDOT] = 73;
|
||||
OS_ERRNO_NAME[-OS_EBADMSG] = "OS_EBADMSG";
|
||||
OS_ERRNO_MSG[-OS_EBADMSG] = "Not a data message";
|
||||
OS_ERRNO[-OS_EBADMSG] = 74;
|
||||
OS_ERRNO_NAME[-OS_EOVERFLOW] = "OS_EOVERFLOW";
|
||||
OS_ERRNO_MSG[-OS_EOVERFLOW] = "Value too large for defined data type";
|
||||
OS_ERRNO[-OS_EOVERFLOW] = 75;
|
||||
OS_ERRNO_NAME[-OS_ENOTUNIQ] = "OS_ENOTUNIQ";
|
||||
OS_ERRNO_MSG[-OS_ENOTUNIQ] = "Name not unique on network";
|
||||
OS_ERRNO[-OS_ENOTUNIQ] = 76;
|
||||
OS_ERRNO_NAME[-OS_EBADFD] = "OS_EBADFD";
|
||||
OS_ERRNO_MSG[-OS_EBADFD] = "File descriptor in bad state";
|
||||
OS_ERRNO[-OS_EBADFD] = 77;
|
||||
OS_ERRNO_NAME[-OS_EREMCHG] = "OS_EREMCHG";
|
||||
OS_ERRNO_MSG[-OS_EREMCHG] = "Remote address changed";
|
||||
OS_ERRNO[-OS_EREMCHG] = 78;
|
||||
OS_ERRNO_NAME[-OS_ELIBACC] = "OS_ELIBACC";
|
||||
OS_ERRNO_MSG[-OS_ELIBACC] = "Can not access a needed shared library";
|
||||
OS_ERRNO[-OS_ELIBACC] = 79;
|
||||
OS_ERRNO_NAME[-OS_ELIBBAD] = "OS_ELIBBAD";
|
||||
OS_ERRNO_MSG[-OS_ELIBBAD] = "Accessing a corrupted shared library";
|
||||
OS_ERRNO[-OS_ELIBBAD] = 80;
|
||||
OS_ERRNO_NAME[-OS_ELIBSCN] = "OS_ELIBSCN";
|
||||
OS_ERRNO_MSG[-OS_ELIBSCN] = ".lib section in a.out corrupted";
|
||||
OS_ERRNO[-OS_ELIBSCN] = 81;
|
||||
OS_ERRNO_NAME[-OS_ELIBMAX] = "OS_ELIBMAX";
|
||||
OS_ERRNO_MSG[-OS_ELIBMAX] = "Attempting to link in too many shared libraries";
|
||||
OS_ERRNO[-OS_ELIBMAX] = 82;
|
||||
OS_ERRNO_NAME[-OS_ELIBEXEC] = "OS_ELIBEXEC";
|
||||
OS_ERRNO_MSG[-OS_ELIBEXEC] = "Cannot exec a shared library directly";
|
||||
OS_ERRNO[-OS_ELIBEXEC] = 83;
|
||||
OS_ERRNO_NAME[-OS_EILSEQ] = "OS_EILSEQ";
|
||||
OS_ERRNO_MSG[-OS_EILSEQ] = "Illegal byte sequence";
|
||||
OS_ERRNO[-OS_EILSEQ] = 84;
|
||||
OS_ERRNO_NAME[-OS_ERESTART] = "OS_ERESTART";
|
||||
OS_ERRNO_MSG[-OS_ERESTART] = "Interrupted system call should be restarted";
|
||||
OS_ERRNO[-OS_ERESTART] = 85;
|
||||
OS_ERRNO_NAME[-OS_ESTRPIPE] = "OS_ESTRPIPE";
|
||||
OS_ERRNO_MSG[-OS_ESTRPIPE] = "Streams pipe error";
|
||||
OS_ERRNO[-OS_ESTRPIPE] = 86;
|
||||
OS_ERRNO_NAME[-OS_EUSERS] = "OS_EUSERS";
|
||||
OS_ERRNO_MSG[-OS_EUSERS] = "Too many users";
|
||||
OS_ERRNO[-OS_EUSERS] = 87;
|
||||
OS_ERRNO_NAME[-OS_ENOTSOCK] = "OS_ENOTSOCK";
|
||||
OS_ERRNO_MSG[-OS_ENOTSOCK] = "Socket operation on non-socket";
|
||||
OS_ERRNO[-OS_ENOTSOCK] = 88;
|
||||
OS_ERRNO_NAME[-OS_EDESTADDRREQ] = "OS_EDESTADDRREQ";
|
||||
OS_ERRNO_MSG[-OS_EDESTADDRREQ] = "Destination address required";
|
||||
OS_ERRNO[-OS_EDESTADDRREQ] = 89;
|
||||
OS_ERRNO_NAME[-OS_EMSGSIZE] = "OS_EMSGSIZE";
|
||||
OS_ERRNO_MSG[-OS_EMSGSIZE] = "Message too long";
|
||||
OS_ERRNO[-OS_EMSGSIZE] = 90;
|
||||
OS_ERRNO_NAME[-OS_EPROTOTYPE] = "OS_EPROTOTYPE";
|
||||
OS_ERRNO_MSG[-OS_EPROTOTYPE] = "Protocol wrong type for socket";
|
||||
OS_ERRNO[-OS_EPROTOTYPE] = 91;
|
||||
OS_ERRNO_NAME[-OS_ENOPROTOOPT] = "OS_ENOPROTOOPT";
|
||||
OS_ERRNO_MSG[-OS_ENOPROTOOPT] = "Protocol not available";
|
||||
OS_ERRNO[-OS_ENOPROTOOPT] = 92;
|
||||
OS_ERRNO_NAME[-OS_EPROTONOSUPPORT] = "OS_EPROTONOSUPPORT";
|
||||
OS_ERRNO_MSG[-OS_EPROTONOSUPPORT] = "Protocol not supported";
|
||||
OS_ERRNO[-OS_EPROTONOSUPPORT] = 93;
|
||||
OS_ERRNO_NAME[-OS_ESOCKTNOSUPPORT] = "OS_ESOCKTNOSUPPORT";
|
||||
OS_ERRNO_MSG[-OS_ESOCKTNOSUPPORT] = "Socket type not supported";
|
||||
OS_ERRNO[-OS_ESOCKTNOSUPPORT] = 94;
|
||||
OS_ERRNO_NAME[-OS_EOPNOTSUPP] = "OS_EOPNOTSUPP";
|
||||
OS_ERRNO_MSG[-OS_EOPNOTSUPP] = "Operation not supported on transport endpoint";
|
||||
OS_ERRNO[-OS_EOPNOTSUPP] = 95;
|
||||
OS_ERRNO_NAME[-OS_EPFNOSUPPORT] = "OS_EPFNOSUPPORT";
|
||||
OS_ERRNO_MSG[-OS_EPFNOSUPPORT] = "Protocol family not supported";
|
||||
OS_ERRNO[-OS_EPFNOSUPPORT] = 96;
|
||||
OS_ERRNO_NAME[-OS_EAFNOSUPPORT] = "OS_EAFNOSUPPORT";
|
||||
OS_ERRNO_MSG[-OS_EAFNOSUPPORT] = "Address family not supported by protocol";
|
||||
OS_ERRNO[-OS_EAFNOSUPPORT] = 97;
|
||||
OS_ERRNO_NAME[-OS_EADDRINUSE] = "OS_EADDRINUSE";
|
||||
OS_ERRNO_MSG[-OS_EADDRINUSE] = "Address already in use";
|
||||
OS_ERRNO[-OS_EADDRINUSE] = 98;
|
||||
OS_ERRNO_NAME[-OS_EADDRNOTAVAIL] = "OS_EADDRNOTAVAIL";
|
||||
OS_ERRNO_MSG[-OS_EADDRNOTAVAIL] = "Cannot assign requested address";
|
||||
OS_ERRNO[-OS_EADDRNOTAVAIL] = 99;
|
||||
OS_ERRNO_NAME[-OS_ENETDOWN] = "OS_ENETDOWN";
|
||||
OS_ERRNO_MSG[-OS_ENETDOWN] = "Network is down";
|
||||
OS_ERRNO[-OS_ENETDOWN] = 100;
|
||||
OS_ERRNO_NAME[-OS_ENETUNREACH] = "OS_ENETUNREACH";
|
||||
OS_ERRNO_MSG[-OS_ENETUNREACH] = "Network is unreachable";
|
||||
OS_ERRNO[-OS_ENETUNREACH] = 101;
|
||||
OS_ERRNO_NAME[-OS_ENETRESET] = "OS_ENETRESET";
|
||||
OS_ERRNO_MSG[-OS_ENETRESET] = "Network dropped connection because of reset";
|
||||
OS_ERRNO[-OS_ENETRESET] = 102;
|
||||
OS_ERRNO_NAME[-OS_ECONNABORTED] = "OS_ECONNABORTED";
|
||||
OS_ERRNO_MSG[-OS_ECONNABORTED] = "Software caused connection abort";
|
||||
OS_ERRNO[-OS_ECONNABORTED] = 103;
|
||||
OS_ERRNO_NAME[-OS_ECONNRESET] = "OS_ECONNRESET";
|
||||
OS_ERRNO_MSG[-OS_ECONNRESET] = "Connection reset by peer";
|
||||
OS_ERRNO[-OS_ECONNRESET] = 104;
|
||||
OS_ERRNO_NAME[-OS_ENOBUFS] = "OS_ENOBUFS";
|
||||
OS_ERRNO_MSG[-OS_ENOBUFS] = "No buffer space available";
|
||||
OS_ERRNO[-OS_ENOBUFS] = 105;
|
||||
OS_ERRNO_NAME[-OS_EISCONN] = "OS_EISCONN";
|
||||
OS_ERRNO_MSG[-OS_EISCONN] = "Transport endpoint is already connected";
|
||||
OS_ERRNO[-OS_EISCONN] = 106;
|
||||
OS_ERRNO_NAME[-OS_ENOTCONN] = "OS_ENOTCONN";
|
||||
OS_ERRNO_MSG[-OS_ENOTCONN] = "Transport endpoint is not connected";
|
||||
OS_ERRNO[-OS_ENOTCONN] = 107;
|
||||
OS_ERRNO_NAME[-OS_ESHUTDOWN] = "OS_ESHUTDOWN";
|
||||
OS_ERRNO_MSG[-OS_ESHUTDOWN] = "Cannot send after transport endpoint shutdown";
|
||||
OS_ERRNO[-OS_ESHUTDOWN] = 108;
|
||||
OS_ERRNO_NAME[-OS_ETOOMANYREFS] = "OS_ETOOMANYREFS";
|
||||
OS_ERRNO_MSG[-OS_ETOOMANYREFS] = "Too many references: cannot splice";
|
||||
OS_ERRNO[-OS_ETOOMANYREFS] = 109;
|
||||
OS_ERRNO_NAME[-OS_ETIMEDOUT] = "OS_ETIMEDOUT";
|
||||
OS_ERRNO_MSG[-OS_ETIMEDOUT] = "Connection timed out";
|
||||
OS_ERRNO[-OS_ETIMEDOUT] = 110;
|
||||
OS_ERRNO_NAME[-OS_ECONNREFUSED] = "OS_ECONNREFUSED";
|
||||
OS_ERRNO_MSG[-OS_ECONNREFUSED] = "Connection refused";
|
||||
OS_ERRNO[-OS_ECONNREFUSED] = 111;
|
||||
OS_ERRNO_NAME[-OS_EHOSTDOWN] = "OS_EHOSTDOWN";
|
||||
OS_ERRNO_MSG[-OS_EHOSTDOWN] = "Host is down";
|
||||
OS_ERRNO[-OS_EHOSTDOWN] = 112;
|
||||
OS_ERRNO_NAME[-OS_EHOSTUNREACH] = "OS_EHOSTUNREACH";
|
||||
OS_ERRNO_MSG[-OS_EHOSTUNREACH] = "No route to host";
|
||||
OS_ERRNO[-OS_EHOSTUNREACH] = 113;
|
||||
OS_ERRNO_NAME[-OS_EALREADY] = "OS_EALREADY";
|
||||
OS_ERRNO_MSG[-OS_EALREADY] = "Operation already in progress";
|
||||
OS_ERRNO[-OS_EALREADY] = 114;
|
||||
OS_ERRNO_NAME[-OS_EINPROGRESS] = "OS_EINPROGRESS";
|
||||
OS_ERRNO_MSG[-OS_EINPROGRESS] = "Operation now in progress";
|
||||
OS_ERRNO[-OS_EINPROGRESS] = 115;
|
||||
OS_ERRNO_NAME[-OS_ESTALE] = "OS_ESTALE";
|
||||
OS_ERRNO_MSG[-OS_ESTALE] = "Stale file handle";
|
||||
OS_ERRNO[-OS_ESTALE] = 116;
|
||||
OS_ERRNO_NAME[-OS_EUCLEAN] = "OS_EUCLEAN";
|
||||
OS_ERRNO_MSG[-OS_EUCLEAN] = "Structure needs cleaning";
|
||||
OS_ERRNO[-OS_EUCLEAN] = 117;
|
||||
OS_ERRNO_NAME[-OS_ENOTNAM] = "OS_ENOTNAM";
|
||||
OS_ERRNO_MSG[-OS_ENOTNAM] = "Not a XENIX named type file";
|
||||
OS_ERRNO[-OS_ENOTNAM] = 118;
|
||||
OS_ERRNO_NAME[-OS_ENAVAIL] = "OS_ENAVAIL";
|
||||
OS_ERRNO_MSG[-OS_ENAVAIL] = "No XENIX semaphores available";
|
||||
OS_ERRNO[-OS_ENAVAIL] = 119;
|
||||
OS_ERRNO_NAME[-OS_EISNAM] = "OS_EISNAM";
|
||||
OS_ERRNO_MSG[-OS_EISNAM] = "Is a named type file";
|
||||
OS_ERRNO[-OS_EISNAM] = 120;
|
||||
OS_ERRNO_NAME[-OS_EREMOTEIO] = "OS_EREMOTEIO";
|
||||
OS_ERRNO_MSG[-OS_EREMOTEIO] = "Remote I/O error";
|
||||
OS_ERRNO[-OS_EREMOTEIO] = 121;
|
||||
OS_ERRNO_NAME[-OS_EDQUOT] = "OS_EDQUOT";
|
||||
OS_ERRNO_MSG[-OS_EDQUOT] = "Quota exceeded";
|
||||
OS_ERRNO[-OS_EDQUOT] = 122;
|
||||
OS_ERRNO_NAME[-OS_ENOMEDIUM] = "OS_ENOMEDIUM";
|
||||
OS_ERRNO_MSG[-OS_ENOMEDIUM] = "No medium found";
|
||||
OS_ERRNO[-OS_ENOMEDIUM] = 123;
|
||||
OS_ERRNO_NAME[-OS_EMEDIUMTYPE] = "OS_EMEDIUMTYPE";
|
||||
OS_ERRNO_MSG[-OS_EMEDIUMTYPE] = "Wrong medium type";
|
||||
OS_ERRNO[-OS_EMEDIUMTYPE] = 124;
|
||||
OS_ERRNO_NAME[-OS_ECANCELED] = "OS_ECANCELED";
|
||||
OS_ERRNO_MSG[-OS_ECANCELED] = "Operation Canceled";
|
||||
OS_ERRNO[-OS_ECANCELED] = 125;
|
||||
OS_ERRNO_NAME[-OS_ENOKEY] = "OS_ENOKEY";
|
||||
OS_ERRNO_MSG[-OS_ENOKEY] = "Required key not available";
|
||||
OS_ERRNO[-OS_ENOKEY] = 126;
|
||||
OS_ERRNO_NAME[-OS_EKEYEXPIRED] = "OS_EKEYEXPIRED";
|
||||
OS_ERRNO_MSG[-OS_EKEYEXPIRED] = "Key has expired";
|
||||
OS_ERRNO[-OS_EKEYEXPIRED] = 127;
|
||||
OS_ERRNO_NAME[-OS_EKEYREVOKED] = "OS_EKEYREVOKED";
|
||||
OS_ERRNO_MSG[-OS_EKEYREVOKED] = "Key has been revoked";
|
||||
OS_ERRNO[-OS_EKEYREVOKED] = 128;
|
||||
OS_ERRNO_NAME[-OS_EKEYREJECTED] = "OS_EKEYREJECTED";
|
||||
OS_ERRNO_MSG[-OS_EKEYREJECTED] = "Key was rejected by service";
|
||||
OS_ERRNO[-OS_EKEYREJECTED] = 129;
|
||||
OS_ERRNO_NAME[-OS_EOWNERDEAD] = "OS_EOWNERDEAD";
|
||||
OS_ERRNO_MSG[-OS_EOWNERDEAD] = "Owner died";
|
||||
OS_ERRNO[-OS_EOWNERDEAD] = 130;
|
||||
OS_ERRNO_NAME[-OS_ENOTRECOVERABLE] = "OS_ENOTRECOVERABLE";
|
||||
OS_ERRNO_MSG[-OS_ENOTRECOVERABLE] = "State not recoverable";
|
||||
OS_ERRNO[-OS_ENOTRECOVERABLE] = 131;
|
||||
OS_ERRNO_NAME[-OS_ERFKILL] = "OS_ERFKILL";
|
||||
OS_ERRNO_MSG[-OS_ERFKILL] = "Operation not possible due to RF-kill";
|
||||
OS_ERRNO[-OS_ERFKILL] = 132;
|
||||
OS_ERRNO_NAME[-OS_EHWPOISON] = "OS_EHWPOISON";
|
||||
OS_ERRNO_MSG[-OS_EHWPOISON] = "Memory page has hardware error";
|
||||
OS_ERRNO[-OS_EHWPOISON] = 133;
|
||||
}
|
||||
} local_init;
|
||||
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
const char* str_os_error_name(const int err)
|
||||
{
|
||||
const char* ret = "Unknown error";
|
||||
if (0 == err) {
|
||||
ret = "OB_SUCCESS";
|
||||
} else if (0 > err && err > -OS_MAX_ERROR_CODE) {
|
||||
ret = OS_ERRNO_NAME[-err];
|
||||
if (NULL == ret || '\0' == ret[0]) {
|
||||
ret = "Unknown Error";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char* str_os_error_msg(const int err)
|
||||
{
|
||||
const char* ret = NULL;
|
||||
if (0 == err) {
|
||||
ret = NULL;
|
||||
} else if (0 > err && err > -OS_MAX_ERROR_CODE) {
|
||||
ret = OS_ERRNO_MSG[-err];
|
||||
if (NULL == ret || '\0' == ret[0]) {
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int os_errno(const int err)
|
||||
{
|
||||
int ret = -1;
|
||||
if (0 >= err && err > -OS_MAX_ERROR_CODE) {
|
||||
ret = OS_ERRNO[-err];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // end namespace common
|
||||
} // end namespace oceanbase
|
139
tools/ob_error/src/os_errno.def
Normal file
139
tools/ob_error/src/os_errno.def
Normal file
@ -0,0 +1,139 @@
|
||||
//here is os errno.
|
||||
//C0: int OS_MAX_ERROR_CODE -----> ob errno
|
||||
//C1: char *OS_ERROR_NAME[OS_MAX_ERROR_CODE] -----> store os errno name
|
||||
//C2: int OS_ERRNO[OS_MAX_ERROR_CODE]; -----> store os errno
|
||||
//C3: char *OS_ERROR_MSG[OS_MAX_ERROR_CODE]; -----> store os errno msg
|
||||
|
||||
//DEFINE_OS_ERROR(C1, C0, C2, C3)
|
||||
DEFINE_OS_ERROR(OS_EPERM, -1, 1 "Operation not permitted");
|
||||
DEFINE_OS_ERROR(OS_ENOENT, -2, 2, "No such file or directory");
|
||||
DEFINE_OS_ERROR(OS_ESRCH, -3, 3, "No such process");
|
||||
DEFINE_OS_ERROR(OS_EINTR, -4, 4, "Interrupted system call");
|
||||
DEFINE_OS_ERROR(OS_EIO, -5, 5, "I/O error");
|
||||
DEFINE_OS_ERROR(OS_ENXIO, -6, 6, "No such device or address");
|
||||
DEFINE_OS_ERROR(OS_E2BIG, -7, 7, "Argument list too long");
|
||||
DEFINE_OS_ERROR(OS_ENOEXEC, -8, 8, "Exec format error");
|
||||
DEFINE_OS_ERROR(OS_EBADF, -9, 9, "Bad file number");
|
||||
DEFINE_OS_ERROR(OS_ECHILD, -10, 10, "No child processes");
|
||||
DEFINE_OS_ERROR(OS_EAGAIN, -11, 11, "Try again");
|
||||
DEFINE_OS_ERROR(OS_ENOMEM, -12, 12, "Out of memory");
|
||||
DEFINE_OS_ERROR(OS_EACCES, -13, 13, "Permission denied");
|
||||
DEFINE_OS_ERROR(OS_EFAULT, -14, 14, "Bad address");
|
||||
DEFINE_OS_ERROR(OS_ENOTBLK, -15, 15, "Block device required");
|
||||
DEFINE_OS_ERROR(OS_EBUSY, -16, 16, "Device or resource busy");
|
||||
DEFINE_OS_ERROR(OS_EEXIST, -17, 17, "File exists");
|
||||
DEFINE_OS_ERROR(OS_EXDEV, -18, 18, "Cross-device link");
|
||||
DEFINE_OS_ERROR(OS_ENODEV, -19, 19, "No such device");
|
||||
DEFINE_OS_ERROR(OS_ENOTDIR, -20, 20, "Not a directory");
|
||||
DEFINE_OS_ERROR(OS_EISDIR, -21, 21, "Is a directory");
|
||||
DEFINE_OS_ERROR(OS_EINVAL, -22, 22, "Invalid argument");
|
||||
DEFINE_OS_ERROR(OS_ENFILE, -23, 23, "File table overflow");
|
||||
DEFINE_OS_ERROR(OS_EMFILE, -24, 24, "Too many open files");
|
||||
DEFINE_OS_ERROR(OS_ENOTTY, -25, 25, "Not a typewriter");
|
||||
DEFINE_OS_ERROR(OS_ETXTBSY, -26, 26, "Text file busy");
|
||||
DEFINE_OS_ERROR(OS_EFBIG, -27, 27, "File too large");
|
||||
DEFINE_OS_ERROR(OS_ENOSPC, -28, 28, "No space left on device");
|
||||
DEFINE_OS_ERROR(OS_ESPIPE, -29, 29, "Illegal seek");
|
||||
DEFINE_OS_ERROR(OS_EROFS, -30, 30, "Read-only file system");
|
||||
DEFINE_OS_ERROR(OS_EMLINK, -31, 31, "Too many links");
|
||||
DEFINE_OS_ERROR(OS_EPIPE, -32, 32, "Broken pipe");
|
||||
DEFINE_OS_ERROR(OS_EDOM, -33, 33, "Math argument out of domain of func");
|
||||
DEFINE_OS_ERROR(OS_ERANGE, -34, 34, "Math result not representable");
|
||||
DEFINE_OS_ERROR(OS_EDEADLK, -35, 35, "Resource deadlock would occur");
|
||||
DEFINE_OS_ERROR(OS_ENAMETOOLONG, -36, 36, "File name too long");
|
||||
DEFINE_OS_ERROR(OS_ENOLCK, -37, 37, "No record locks available");
|
||||
DEFINE_OS_ERROR(OS_ENOSYS, -38, 38, "Function not implemented");
|
||||
DEFINE_OS_ERROR(OS_ENOTEMPTY, -39, 39, "Directory not empty");
|
||||
DEFINE_OS_ERROR(OS_ELOOP, -40, 40, "Too many symbolic links encountered");
|
||||
DEFINE_OS_ERROR(OS_EWOULDBLOCK, -41, 11, "Operation would block");
|
||||
DEFINE_OS_ERROR(OS_ENOMSG, -42, 42, "No message of desired type");
|
||||
DEFINE_OS_ERROR(OS_EIDRM, -43, 43, "Identifier removed");
|
||||
DEFINE_OS_ERROR(OS_ECHRNG, -44, 44, "Channel number out of range");
|
||||
DEFINE_OS_ERROR(OS_EL2NSYNC, -45, 45, "Level 2 not synchronized");
|
||||
DEFINE_OS_ERROR(OS_EL3HLT, -46, 46, "Level 3 halted");
|
||||
DEFINE_OS_ERROR(OS_EL3RST, -47, 47, "Level 3 reset");
|
||||
DEFINE_OS_ERROR(OS_ELNRNG, -48, 48, "Link number out of range");
|
||||
DEFINE_OS_ERROR(OS_EUNATCH, -49, 49, "Protocol driver not attached");
|
||||
DEFINE_OS_ERROR(OS_ENOCSI, -50, 50, "No CSI structure available");
|
||||
DEFINE_OS_ERROR(OS_EL2HLT, -51, 51, "Level 2 halted");
|
||||
DEFINE_OS_ERROR(OS_EBADE, -52, 52, "Invalid exchange");
|
||||
DEFINE_OS_ERROR(OS_EBADR, -53, 53, "Invalid request descriptor");
|
||||
DEFINE_OS_ERROR(OS_EXFULL, -54, 54, "Exchange full");
|
||||
DEFINE_OS_ERROR(OS_ENOANO, -55, 55, "No anode");
|
||||
DEFINE_OS_ERROR(OS_EBADRQC, -56, 56, "Invalid request code");
|
||||
DEFINE_OS_ERROR(OS_EBADSLT, -57, 57, "Invalid slot");
|
||||
DEFINE_OS_ERROR(OS_EBFONT, -59, 59, "Bad font file format");
|
||||
DEFINE_OS_ERROR(OS_ENOSTR, -60, 60, "Device not a stream");
|
||||
DEFINE_OS_ERROR(OS_ENODATA, -61, 61, "No data available");
|
||||
DEFINE_OS_ERROR(OS_ETIME, -62, 62, "Timer expired");
|
||||
DEFINE_OS_ERROR(OS_ENOSR, -63, 63, "OOut of streams resources");
|
||||
DEFINE_OS_ERROR(OS_ENONET, -64, 64, "Machine is not on the network");
|
||||
DEFINE_OS_ERROR(OS_ENOPKG, -65, 65, "Package not installed");
|
||||
DEFINE_OS_ERROR(OS_EREMOTE, -66, 66, "Object is remote");
|
||||
DEFINE_OS_ERROR(OS_ENOLINK, -67, 67, "Link has been severed");
|
||||
DEFINE_OS_ERROR(OS_EADV, -68, 68, "Advertise error");
|
||||
DEFINE_OS_ERROR(OS_ESRMNT, -69, 69, "Srmount error");
|
||||
DEFINE_OS_ERROR(OS_ECOMM, -70, 70, "Communication error on send");
|
||||
DEFINE_OS_ERROR(OS_EPROTO, -71, 71, "Protocol error");
|
||||
DEFINE_OS_ERROR(OS_EMULTIHOP, -72, 72, "Multihop attempted");
|
||||
DEFINE_OS_ERROR(OS_EDOTDOT, -73, 73, "RFS specific error");
|
||||
DEFINE_OS_ERROR(OS_EBADMSG, -74, 74, "Not a data message");
|
||||
DEFINE_OS_ERROR(OS_EOVERFLOW, -75, 75, "Value too large for defined data type");
|
||||
DEFINE_OS_ERROR(OS_ENOTUNIQ, -76, 76, "Name not unique on network");
|
||||
DEFINE_OS_ERROR(OS_EBADFD, -77, 77, "File descriptor in bad state");
|
||||
DEFINE_OS_ERROR(OS_EREMCHG, -78, 78, "Remote address changed");
|
||||
DEFINE_OS_ERROR(OS_ELIBACC, -79, 79, "Can not access a needed shared library");
|
||||
DEFINE_OS_ERROR(OS_ELIBBAD, -80, 80, "Accessing a corrupted shared library");
|
||||
DEFINE_OS_ERROR(OS_ELIBSCN, -81, 81, ".lib section in a.out corrupted");
|
||||
DEFINE_OS_ERROR(OS_ELIBMAX, -82, 82, "Attempting to link in too many shared libraries");
|
||||
DEFINE_OS_ERROR(OS_ELIBEXEC, -83, 83, "Cannot exec a shared library directly");
|
||||
DEFINE_OS_ERROR(OS_EILSEQ, -84, 84, "Illegal byte sequence");
|
||||
DEFINE_OS_ERROR(OS_ERESTART, -85, 85, "Interrupted system call should be restarted");
|
||||
DEFINE_OS_ERROR(OS_ESTRPIPE, -86, 86, "Streams pipe error");
|
||||
DEFINE_OS_ERROR(OS_EUSERS, -87, 87, "Too many users");
|
||||
DEFINE_OS_ERROR(OS_ENOTSOCK, -88, 88, "Socket operation on non-socket");
|
||||
DEFINE_OS_ERROR(OS_EDESTADDRREQ, -89, 89, "Destination address required");
|
||||
DEFINE_OS_ERROR(OS_EMSGSIZE, -90, 90, "Message too long");
|
||||
DEFINE_OS_ERROR(OS_EPROTOTYPE, -91, 91, "Protocol wrong type for socket");
|
||||
DEFINE_OS_ERROR(OS_ENOPROTOOPT, -92, 92, "Protocol not available");
|
||||
DEFINE_OS_ERROR(OS_EPROTONOSUPPORT, -93, 93, "Protocol not supported");
|
||||
DEFINE_OS_ERROR(OS_ESOCKTNOSUPPORT, -94, 94, "Socket type not supported");
|
||||
DEFINE_OS_ERROR(OS_EOPNOTSUPP, -95, 95, "Operation not supported on transport endpoint");
|
||||
DEFINE_OS_ERROR(OS_EPFNOSUPPORT, -96, 96, "Protocol family not supported");
|
||||
DEFINE_OS_ERROR(OS_EAFNOSUPPORT, -97, 97, "Address family not supported by protocol");
|
||||
DEFINE_OS_ERROR(OS_EADDRINUSE, -98, 98, "Address already in use");
|
||||
DEFINE_OS_ERROR(OS_EADDRNOTAVAIL, -99, 99, "Cannot assign requested address");
|
||||
DEFINE_OS_ERROR(OS_ENETDOWN, -100, 100, "Network is down");
|
||||
DEFINE_OS_ERROR(OS_ENETUNREACH, -101, 101, "Network is unreachable");
|
||||
DEFINE_OS_ERROR(OS_ENETRESET, -102, 102, "Network dropped connection because of reset");
|
||||
DEFINE_OS_ERROR(OS_ECONNABORTED, -103, 103, "Software caused connection abort");
|
||||
DEFINE_OS_ERROR(OS_ECONNRESET, -104, 104, "Connection reset by peer");
|
||||
DEFINE_OS_ERROR(OS_ENOBUFS, -105, 105, "No buffer space available");
|
||||
DEFINE_OS_ERROR(OS_EISCONN, -106, 106, "Transport endpoint is already connected");
|
||||
DEFINE_OS_ERROR(OS_ENOTCONN, -107, 107, "Transport endpoint is not connected");
|
||||
DEFINE_OS_ERROR(OS_ESHUTDOWN, -108, 108, "Cannot send after transport endpoint shutdown");
|
||||
DEFINE_OS_ERROR(OS_ETOOMANYREFS, -109, 109, "Too many references: cannot splice");
|
||||
DEFINE_OS_ERROR(OS_ETIMEDOUT, -110, 110, "Connection timed out");
|
||||
DEFINE_OS_ERROR(OS_ECONNREFUSED, -111, 111, "Connection refused");
|
||||
DEFINE_OS_ERROR(OS_EHOSTDOWN, -112, 112, "Host is down");
|
||||
DEFINE_OS_ERROR(OS_EHOSTUNREACH, -113, 113, "No route to host");
|
||||
DEFINE_OS_ERROR(OS_EALREADY, -114, 114, "Operation already in progress");
|
||||
DEFINE_OS_ERROR(OS_EINPROGRESS, -115, 115, "Operation now in progress");
|
||||
DEFINE_OS_ERROR(OS_ESTALE, -116, 116, "Stale file handle");
|
||||
DEFINE_OS_ERROR(OS_EUCLEAN, -117, 117, "Structure needs cleaning");
|
||||
DEFINE_OS_ERROR(OS_ENOTNAM, -118, 118, "Not a XENIX named type file");
|
||||
DEFINE_OS_ERROR(OS_ENAVAIL, -119, 119, "No XENIX semaphores available");
|
||||
DEFINE_OS_ERROR(OS_EISNAM, -120, 120, "Is a named type file");
|
||||
DEFINE_OS_ERROR(OS_EREMOTEIO, -121, 121, "Remote I/O error");
|
||||
DEFINE_OS_ERROR(OS_EDQUOT, -122, 122, "Quota exceeded");
|
||||
DEFINE_OS_ERROR(OS_ENOMEDIUM, -123, 123, "No medium found");
|
||||
DEFINE_OS_ERROR(OS_EMEDIUMTYPE, -124, 124, "Wrong medium type");
|
||||
DEFINE_OS_ERROR(OS_ECANCELED, -125, 125, "Operation Canceled");
|
||||
DEFINE_OS_ERROR(OS_ENOKEY, -126, 126, "Required key not available");
|
||||
DEFINE_OS_ERROR(OS_EKEYEXPIRED, -127, 127, "Key has expired");
|
||||
DEFINE_OS_ERROR(OS_EKEYREVOKED, -128, 128, "Key has been revoked");
|
||||
DEFINE_OS_ERROR(OS_EKEYREJECTED, -129, 129, "Key was rejected by service");
|
||||
DEFINE_OS_ERROR(OS_EOWNERDEAD, -130, 130, "Owner died");
|
||||
DEFINE_OS_ERROR(OS_ENOTRECOVERABLE, -131, 131, "State not recoverable");
|
||||
DEFINE_OS_ERROR(OS_ERFKILL, -132, 132, "Operation not possible due to RF-kill");
|
||||
DEFINE_OS_ERROR(OS_EHWPOISON, -133, 133, "Memory page has hardware error");
|
165
tools/ob_error/src/os_errno.h
Normal file
165
tools/ob_error/src/os_errno.h
Normal file
@ -0,0 +1,165 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated from `ob_errno.def'.
|
||||
#ifndef OBERROR_OS_ERRNO_H
|
||||
#define OBERROR_OS_ERRNO_H
|
||||
|
||||
// linux
|
||||
#include <errno.h>
|
||||
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
|
||||
// The length of the second dimension, in order to solve the conflict of multiple identical error codes
|
||||
constexpr int OS_MAX_SAME_ERROR_COUNT = 2;
|
||||
|
||||
constexpr int OS_MAX_ERROR_CODE = 135;
|
||||
constexpr int OS_ENOENT = -2;
|
||||
constexpr int OS_ESRCH = -3;
|
||||
constexpr int OS_EINTR = -4;
|
||||
constexpr int OS_EIO = -5;
|
||||
constexpr int OS_ENXIO = -6;
|
||||
constexpr int OS_E2BIG = -7;
|
||||
constexpr int OS_ENOEXEC = -8;
|
||||
constexpr int OS_EBADF = -9;
|
||||
constexpr int OS_ECHILD = -10;
|
||||
constexpr int OS_EAGAIN = -11;
|
||||
constexpr int OS_ENOMEM = -12;
|
||||
constexpr int OS_EACCES = -13;
|
||||
constexpr int OS_EFAULT = -14;
|
||||
constexpr int OS_ENOTBLK = -15;
|
||||
constexpr int OS_EBUSY = -16;
|
||||
constexpr int OS_EEXIST = -17;
|
||||
constexpr int OS_EXDEV = -18;
|
||||
constexpr int OS_ENODEV = -19;
|
||||
constexpr int OS_ENOTDIR = -20;
|
||||
constexpr int OS_EISDIR = -21;
|
||||
constexpr int OS_EINVAL = -22;
|
||||
constexpr int OS_ENFILE = -23;
|
||||
constexpr int OS_EMFILE = -24;
|
||||
constexpr int OS_ENOTTY = -25;
|
||||
constexpr int OS_ETXTBSY = -26;
|
||||
constexpr int OS_EFBIG = -27;
|
||||
constexpr int OS_ENOSPC = -28;
|
||||
constexpr int OS_ESPIPE = -29;
|
||||
constexpr int OS_EROFS = -30;
|
||||
constexpr int OS_EMLINK = -31;
|
||||
constexpr int OS_EPIPE = -32;
|
||||
constexpr int OS_EDOM = -33;
|
||||
constexpr int OS_ERANGE = -34;
|
||||
constexpr int OS_EDEADLK = -35;
|
||||
constexpr int OS_ENAMETOOLONG = -36;
|
||||
constexpr int OS_ENOLCK = -37;
|
||||
constexpr int OS_ENOSYS = -38;
|
||||
constexpr int OS_ENOTEMPTY = -39;
|
||||
constexpr int OS_ELOOP = -40;
|
||||
constexpr int OS_EWOULDBLOCK = -41;
|
||||
constexpr int OS_ENOMSG = -42;
|
||||
constexpr int OS_EIDRM = -43;
|
||||
constexpr int OS_ECHRNG = -44;
|
||||
constexpr int OS_EL2NSYNC = -45;
|
||||
constexpr int OS_EL3HLT = -46;
|
||||
constexpr int OS_EL3RST = -47;
|
||||
constexpr int OS_ELNRNG = -48;
|
||||
constexpr int OS_EUNATCH = -49;
|
||||
constexpr int OS_ENOCSI = -50;
|
||||
constexpr int OS_EL2HLT = -51;
|
||||
constexpr int OS_EBADE = -52;
|
||||
constexpr int OS_EBADR = -53;
|
||||
constexpr int OS_EXFULL = -54;
|
||||
constexpr int OS_ENOANO = -55;
|
||||
constexpr int OS_EBADRQC = -56;
|
||||
constexpr int OS_EBADSLT = -57;
|
||||
constexpr int OS_EBFONT = -59;
|
||||
constexpr int OS_ENOSTR = -60;
|
||||
constexpr int OS_ENODATA = -61;
|
||||
constexpr int OS_ETIME = -62;
|
||||
constexpr int OS_ENOSR = -63;
|
||||
constexpr int OS_ENONET = -64;
|
||||
constexpr int OS_ENOPKG = -65;
|
||||
constexpr int OS_EREMOTE = -66;
|
||||
constexpr int OS_ENOLINK = -67;
|
||||
constexpr int OS_EADV = -68;
|
||||
constexpr int OS_ESRMNT = -69;
|
||||
constexpr int OS_ECOMM = -70;
|
||||
constexpr int OS_EPROTO = -71;
|
||||
constexpr int OS_EMULTIHOP = -72;
|
||||
constexpr int OS_EDOTDOT = -73;
|
||||
constexpr int OS_EBADMSG = -74;
|
||||
constexpr int OS_EOVERFLOW = -75;
|
||||
constexpr int OS_ENOTUNIQ = -76;
|
||||
constexpr int OS_EBADFD = -77;
|
||||
constexpr int OS_EREMCHG = -78;
|
||||
constexpr int OS_ELIBACC = -79;
|
||||
constexpr int OS_ELIBBAD = -80;
|
||||
constexpr int OS_ELIBSCN = -81;
|
||||
constexpr int OS_ELIBMAX = -82;
|
||||
constexpr int OS_ELIBEXEC = -83;
|
||||
constexpr int OS_EILSEQ = -84;
|
||||
constexpr int OS_ERESTART = -85;
|
||||
constexpr int OS_ESTRPIPE = -86;
|
||||
constexpr int OS_EUSERS = -87;
|
||||
constexpr int OS_ENOTSOCK = -88;
|
||||
constexpr int OS_EDESTADDRREQ = -89;
|
||||
constexpr int OS_EMSGSIZE = -90;
|
||||
constexpr int OS_EPROTOTYPE = -91;
|
||||
constexpr int OS_ENOPROTOOPT = -92;
|
||||
constexpr int OS_EPROTONOSUPPORT = -93;
|
||||
constexpr int OS_ESOCKTNOSUPPORT = -94;
|
||||
constexpr int OS_EOPNOTSUPP = -95;
|
||||
constexpr int OS_EPFNOSUPPORT = -96;
|
||||
constexpr int OS_EAFNOSUPPORT = -97;
|
||||
constexpr int OS_EADDRINUSE = -98;
|
||||
constexpr int OS_EADDRNOTAVAIL = -99;
|
||||
constexpr int OS_ENETDOWN = -100;
|
||||
constexpr int OS_ENETUNREACH = -101;
|
||||
constexpr int OS_ENETRESET = -102;
|
||||
constexpr int OS_ECONNABORTED = -103;
|
||||
constexpr int OS_ECONNRESET = -104;
|
||||
constexpr int OS_ENOBUFS = -105;
|
||||
constexpr int OS_EISCONN = -106;
|
||||
constexpr int OS_ENOTCONN = -107;
|
||||
constexpr int OS_ESHUTDOWN = -108;
|
||||
constexpr int OS_ETOOMANYREFS = -109;
|
||||
constexpr int OS_ETIMEDOUT = -110;
|
||||
constexpr int OS_ECONNREFUSED = -111;
|
||||
constexpr int OS_EHOSTDOWN = -112;
|
||||
constexpr int OS_EHOSTUNREACH = -113;
|
||||
constexpr int OS_EALREADY = -114;
|
||||
constexpr int OS_EINPROGRESS = -115;
|
||||
constexpr int OS_ESTALE = -116;
|
||||
constexpr int OS_EUCLEAN = -117;
|
||||
constexpr int OS_ENOTNAM = -118;
|
||||
constexpr int OS_ENAVAIL = -119;
|
||||
constexpr int OS_EISNAM = -120;
|
||||
constexpr int OS_EREMOTEIO = -121;
|
||||
constexpr int OS_EDQUOT = -122;
|
||||
constexpr int OS_ENOMEDIUM = -123;
|
||||
constexpr int OS_EMEDIUMTYPE = -124;
|
||||
constexpr int OS_ECANCELED = -125;
|
||||
constexpr int OS_ENOKEY = -126;
|
||||
constexpr int OS_EKEYEXPIRED = -127;
|
||||
constexpr int OS_EKEYREVOKED = -128;
|
||||
constexpr int OS_EKEYREJECTED = -129;
|
||||
constexpr int OS_EOWNERDEAD = -130;
|
||||
constexpr int OS_ENOTRECOVERABLE = -131;
|
||||
constexpr int OS_ERFKILL = -132;
|
||||
constexpr int OS_EHWPOISON = -133;
|
||||
|
||||
const char* str_os_error_name(const int err);
|
||||
const char* str_os_error_msg(const int err);
|
||||
int os_errno(const int err);
|
||||
} // end namespace common
|
||||
} // end namespace oceanbase
|
||||
|
||||
#endif /* OBERROR_OS_ERRNO_H */
|
221
tools/ob_error/test/expect_result.result
Normal file
221
tools/ob_error/test/expect_result.result
Normal file
@ -0,0 +1,221 @@
|
||||
$ob_error 1
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-00001
|
||||
Message: unique constraint violated
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_PRIMARY_KEY_DUPLICATE(-5024)
|
||||
OB_ER_DUPLICATED_VALUE_IN_TYPE(-5334)
|
||||
OB_ERR_CONSTRAINT_DUPLICATE(-5562)
|
||||
OB_ERR_DUP_KEY(-5595)
|
||||
$ob_error 13
|
||||
|
||||
Operating System:
|
||||
Linux Error Code: EACCES(13)
|
||||
Message: Permission denied
|
||||
$ob_error 200
|
||||
|
||||
OceanBase:
|
||||
Error Code 200 not found.
|
||||
$ob_error 600
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-00600
|
||||
Message: auto increment service busy
|
||||
Message: rowid type mismatch
|
||||
Related OceanBase Error Code:
|
||||
OB_AUTOINC_SERVICE_BUSY(-5794)
|
||||
OB_ROWID_TYPE_MISMATCH(-5870)
|
||||
OB_ROWID_NUM_MISMATCH(-5871)
|
||||
$ob_error 1017
|
||||
|
||||
MySQL:
|
||||
MySQL Error Code: 1017 (HY000)
|
||||
Message: File not exist
|
||||
Related OceanBase Error Code:
|
||||
OB_FILE_NOT_EXIST(-4027)
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-01017
|
||||
Message: invalid username/password; logon deniedd
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_LOGIN_DENIED(-5845)
|
||||
$ob_error 5858
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_ERR_CONFLICTING_DECLARATIONS(-5858)
|
||||
Message: Conflicting declarations
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
$ob_error 4001
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_OBJ_TYPE_ERROR(-4001)
|
||||
Message: Object type error
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-04001
|
||||
Message: sequence parameter must be an integer
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_SEQ_OPTION_MUST_BE_INTEGER(-4317)
|
||||
$ob_error 20000
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_SP_RAISE_APPLICATION_ERROR(-20000)
|
||||
Message: The stored procedure 'raise_application_error' was called which causes this error to be generated
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-20000
|
||||
Message: The stored procedure 'raise_application_error' was called which causes this error to be generated
|
||||
Related OceanBase Error Code:
|
||||
OB_SP_RAISE_APPLICATION_ERROR(-20000)
|
||||
$ob_error 24761
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-24761
|
||||
Message: transaction rolled back
|
||||
Message: transaction rolled back: transaction is killed
|
||||
Message: transaction rolled back: transaction context does not exist
|
||||
Message: transaction rolled back: partition is frozen
|
||||
Message: transaction rolled back: Transaction exiting
|
||||
Message: transaction rolled back: transaction needs rollback
|
||||
Message: transaction rolled back: transaction context count reach limit
|
||||
Related OceanBase Error Code:
|
||||
OB_TRANS_ROLLBACKED(-6002)
|
||||
OB_TRANS_KILLED(-6211)
|
||||
OB_TRANS_CTX_NOT_EXIST(-6213)
|
||||
OB_PARTITION_IS_FROZEN(-6214)
|
||||
OB_TRANS_IS_EXITING(-6223)
|
||||
OB_TRANS_NEED_ROLLBACK(-6224)
|
||||
OB_TRANS_CTX_COUNT_REACH_LIMIT(-6234)
|
||||
$ob_error 5727
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_ERR_PROXY_REROUTE(-5727)
|
||||
Message: SQL request should be rerouted
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
$ob_error 5133
|
||||
|
||||
MySQL:
|
||||
MySQL Error Code: 5133 (42000)
|
||||
Message: No such grant defined
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_CANNOT_REVOKE_PRIVILEGES_YOU_DID_NOT_GRANT(-5362)
|
||||
$ob_error 1210
|
||||
|
||||
MySQL:
|
||||
MySQL Error Code: 1210 (HY000)
|
||||
Message: Invalid argument
|
||||
Message: Miss argument
|
||||
Message: Incorrect arguments to ESCAPE
|
||||
Related OceanBase Error Code:
|
||||
OB_INVALID_ARGUMENT(-4002)
|
||||
OB_MISS_ARGUMENT(-4277)
|
||||
INCORRECT_ARGUMENTS_TO_ESCAPE(-5832)
|
||||
$ob_error 700 -a 1000
|
||||
error: '-a ARG' is unsupport in this scene
|
||||
Use 'ob_error ora 600 -a ARG'.
|
||||
Use 'ob_error --help' for help.
|
||||
$ob_error my 6000
|
||||
|
||||
MySQL:
|
||||
Error Code 6000 not found.
|
||||
$ob_error my 4000
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_ERROR(-4000)
|
||||
Message: Common error
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
$ob_error my 5133
|
||||
|
||||
MySQL:
|
||||
MySQL Error Code: 5133 (42000)
|
||||
Message: No such grant defined
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_CANNOT_REVOKE_PRIVILEGES_YOU_DID_NOT_GRANT(-5362)
|
||||
$ob_error my 1210
|
||||
|
||||
MySQL:
|
||||
MySQL Error Code: 1210 (HY000)
|
||||
Message: Invalid argument
|
||||
Message: Miss argument
|
||||
Message: Incorrect arguments to ESCAPE
|
||||
Related OceanBase Error Code:
|
||||
OB_INVALID_ARGUMENT(-4002)
|
||||
OB_MISS_ARGUMENT(-4277)
|
||||
INCORRECT_ARGUMENTS_TO_ESCAPE(-5832)
|
||||
$ob_error ora 00051
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-00051
|
||||
Message: timeout occurred while waiting for a resource
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_TIMEOUT_ON_RESOURCE(-5848)
|
||||
$ob_error ora 900
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-00900
|
||||
Message: invalid SQL statement
|
||||
Message: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_PARSE_SQL(-5001)
|
||||
OB_ERR_PARSER_SYNTAX(-5006)
|
||||
$ob_error ora 600 -a 5858
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_ERR_CONFLICTING_DECLARATIONS(-5858)
|
||||
Message: Conflicting declarations
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-00600
|
||||
Message: internal error code, arguments: -5858, Conflicting declarations
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_CONFLICTING_DECLARATIONS(-5858)
|
||||
$ob_error ora 600 -a 5727
|
||||
|
||||
OceanBase:
|
||||
OceanBase Error Code: OB_ERR_PROXY_REROUTE(-5727)
|
||||
Message: SQL request should be rerouted
|
||||
Cause: Internal Error
|
||||
Solution: Contact OceanBase Support
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: ORA-00600
|
||||
Message: internal error code, arguments: -5727, SQL request should be rerouted
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_PROXY_REROUTE(-5727)
|
||||
$ob_error -a 100 ora 600
|
||||
error: '-a ARG' is unsupport in this scene
|
||||
Use 'ob_error ora 600 -a ARG'.
|
||||
Use 'ob_error --help' for help.
|
||||
$ob_error ora -a 100 600
|
||||
error: '-a ARG' is unsupport in this scene
|
||||
Use 'ob_error ora 600 -a ARG'.
|
||||
Use 'ob_error --help' for help.
|
||||
$ob_error ora 600 -a 100
|
||||
|
||||
OceanBase:
|
||||
Error Code 100 not found.
|
||||
|
||||
Oracle:
|
||||
Error Code ORA-00600 arguments: -100 not found.
|
||||
$ob_error pls 100
|
||||
|
||||
Oracle:
|
||||
Error Code PLS-00100 not found.
|
||||
$ob_error pls 201
|
||||
|
||||
Oracle:
|
||||
Oracle Error Code: PLS-00201
|
||||
Message: identifier must be declared
|
||||
Related OceanBase Error Code:
|
||||
OB_ERR_SP_UNDECLARED_VAR(-5543)
|
||||
OB_ERR_SP_LILABEL_MISMATCH(-5546)
|
26
tools/ob_error/test/ob_error_test.test
Normal file
26
tools/ob_error/test/ob_error_test.test
Normal file
@ -0,0 +1,26 @@
|
||||
ob_error 1
|
||||
ob_error 13
|
||||
ob_error 200
|
||||
ob_error 600
|
||||
ob_error 1017
|
||||
ob_error 5858
|
||||
ob_error 4001
|
||||
ob_error 20000
|
||||
ob_error 24761
|
||||
ob_error 5727
|
||||
ob_error 5133
|
||||
ob_error 1210
|
||||
ob_error 700 -a 1000
|
||||
ob_error my 6000
|
||||
ob_error my 4000
|
||||
ob_error my 5133
|
||||
ob_error my 1210
|
||||
ob_error ora 00051
|
||||
ob_error ora 900
|
||||
ob_error ora 600 -a 5858
|
||||
ob_error ora 600 -a 5727
|
||||
ob_error -a 100 ora 600
|
||||
ob_error ora -a 100 600
|
||||
ob_error ora 600 -a 100
|
||||
ob_error pls 100
|
||||
ob_error pls 201
|
21
tools/ob_error/test/test.sh
Executable file
21
tools/ob_error/test/test.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
CURRENT_DIR="$(cd $(dirname $0); pwd)"
|
||||
test_file=${CURRENT_DIR}/ob_error_test.test
|
||||
test_result_file=${CURRENT_DIR}/expect_result.result
|
||||
result_file=${CURRENT_DIR}/test.result
|
||||
|
||||
rm -f $result_file
|
||||
|
||||
while read line
|
||||
do
|
||||
echo "$"$line >> $result_file
|
||||
eval $line >> $result_file
|
||||
done < $test_file
|
||||
|
||||
if cmp -s $result_file $test_result_file
|
||||
then
|
||||
echo "test finish. success."
|
||||
else
|
||||
echo "test finish. failed."
|
||||
fi
|
@ -28,3 +28,4 @@ add_subdirectory(election)
|
||||
add_subdirectory(observer)
|
||||
add_subdirectory(share)
|
||||
add_subdirectory(rootserver)
|
||||
add_subdirectory(tools)
|
||||
|
1
unittest/tools/CMakeLists.txt
Normal file
1
unittest/tools/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(ob_error)
|
6
unittest/tools/ob_error/CMakeLists.txt
Normal file
6
unittest/tools/ob_error/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
add_executable(test_ob_error test_ob_error.cpp)
|
||||
add_test(test_ob_error test_ob_error)
|
||||
target_link_libraries(test_ob_error PRIVATE oberror ${DEP_DIR}/lib/libgtest.a ${DEP_DIR}/lib/libgmock.a -lpthread)
|
||||
target_include_directories(test_ob_error
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/unittest ${CMAKE_SOURCE_DIR}/deps/oblib/unittest ${DEP_DIR}/include
|
||||
${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/deps/oblib/src)
|
127
unittest/tools/ob_error/test_ob_error.cpp
Normal file
127
unittest/tools/ob_error/test_ob_error.cpp
Normal file
@ -0,0 +1,127 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "tools/ob_error/src/ob_error.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
namespace oceanbase {
|
||||
namespace unittest {
|
||||
class TestObError : public ::testing::Test {
|
||||
public:
|
||||
virtual void SetUp()
|
||||
{}
|
||||
virtual void TearDown()
|
||||
{}
|
||||
};
|
||||
|
||||
TEST_F(TestObError, test_mgr)
|
||||
{
|
||||
ObErrorInfoMgr mgr;
|
||||
|
||||
EXPECT_FALSE(mgr.insert_os_error(nullptr, "abc", 1));
|
||||
EXPECT_FALSE(mgr.insert_os_error("abc", nullptr, 1));
|
||||
EXPECT_FALSE(mgr.insert_mysql_error(nullptr, "abc", 1, "abc", "abc", "abc", 1));
|
||||
EXPECT_FALSE(mgr.insert_mysql_error("abc", nullptr, 1, "abc", "abc", "abc", 1));
|
||||
EXPECT_FALSE(mgr.insert_mysql_error("abc", "abc", 1, nullptr, "abc", "abc", 1));
|
||||
EXPECT_FALSE(mgr.insert_mysql_error("abc", "abc", 1, "abc", nullptr, "abc", 1));
|
||||
EXPECT_FALSE(mgr.insert_mysql_error("abc", "abc", 1, "abc", "abc", nullptr, 1));
|
||||
EXPECT_FALSE(mgr.insert_oracle_error(nullptr, "abc", "abc", "abc", ORA, 1, 1));
|
||||
EXPECT_FALSE(mgr.insert_oracle_error("abc", nullptr, "abc", "abc", ORA, 1, 1));
|
||||
EXPECT_FALSE(mgr.insert_oracle_error("abc", "abc", nullptr, "abc", ORA, 1, 1));
|
||||
EXPECT_FALSE(mgr.insert_oracle_error("abc", "abc", "abc", nullptr, ORA, 1, 1));
|
||||
EXPECT_FALSE(mgr.insert_oracle_error("abc", "abc", "abc", "abc", NONE, 1, 1));
|
||||
EXPECT_FALSE(mgr.insert_ob_error(nullptr, "abc", "abc", "abc", 1));
|
||||
EXPECT_FALSE(mgr.insert_ob_error("abc", nullptr, "abc", "abc", 1));
|
||||
EXPECT_FALSE(mgr.insert_ob_error("abc", "abc", nullptr, "abc", 1));
|
||||
EXPECT_FALSE(mgr.insert_ob_error("abc", "abc", "abc", nullptr, 1));
|
||||
}
|
||||
|
||||
TEST_F(TestObError, test_adder)
|
||||
{
|
||||
ObErrorInfoMgr mgr;
|
||||
EXPECT_TRUE(init_global_info());
|
||||
// test_add_os_info
|
||||
EXPECT_FALSE(add_os_info(-1, &mgr));
|
||||
EXPECT_FALSE(add_os_info(OS_MAX_ERROR_CODE, &mgr));
|
||||
|
||||
EXPECT_TRUE(add_os_info(1, nullptr));
|
||||
EXPECT_TRUE(add_os_info(100, &mgr));
|
||||
EXPECT_TRUE(add_os_info(0, &mgr));
|
||||
|
||||
// test_add_oracle_info
|
||||
EXPECT_FALSE(add_oracle_info(NONE, -1, -1, &mgr));
|
||||
EXPECT_FALSE(add_oracle_info(ORA, 100, -1, &mgr));
|
||||
EXPECT_FALSE(add_oracle_info(PLS, 100, -1, &mgr));
|
||||
EXPECT_FALSE(add_oracle_info(ORA, 600, 3000, &mgr));
|
||||
EXPECT_FALSE(add_oracle_info(MY, 600, 3000, &mgr));
|
||||
EXPECT_FALSE(add_oracle_info(NONE, 100, -1, &mgr));
|
||||
|
||||
EXPECT_TRUE(add_oracle_info(ORA, 600, -1, nullptr));
|
||||
EXPECT_TRUE(add_oracle_info(ORA, 600, -1, &mgr));
|
||||
EXPECT_TRUE(add_oracle_info(ORA, 600, 4000, &mgr));
|
||||
EXPECT_TRUE(add_oracle_info(ORA, 100, 4000, &mgr));
|
||||
EXPECT_TRUE(add_oracle_info(PLS, 100, 4000, &mgr));
|
||||
EXPECT_TRUE(add_oracle_info(NONE, 600, 3000, &mgr));
|
||||
|
||||
// test_add_mysql_info
|
||||
EXPECT_FALSE(add_mysql_info(-1, &mgr));
|
||||
EXPECT_FALSE(add_mysql_info(OB_MAX_ERROR_CODE, &mgr));
|
||||
EXPECT_FALSE(add_mysql_info(1000, &mgr));
|
||||
EXPECT_FALSE(add_mysql_info(6300, &mgr));
|
||||
|
||||
EXPECT_TRUE(add_mysql_info(1017, &mgr));
|
||||
|
||||
// test_add_ob_info
|
||||
EXPECT_FALSE(add_ob_info(-1, &mgr));
|
||||
EXPECT_FALSE(add_ob_info(OB_MAX_ERROR_CODE, &mgr));
|
||||
EXPECT_FALSE(add_ob_info(1000, &mgr));
|
||||
EXPECT_FALSE(add_ob_info(6500, &mgr));
|
||||
|
||||
EXPECT_TRUE(add_ob_info(4100, &mgr));
|
||||
}
|
||||
|
||||
TEST_F(TestObError, test_parser)
|
||||
{
|
||||
// test_parse_error_code
|
||||
int error_code = -1;
|
||||
parse_error_code("abc123", error_code);
|
||||
EXPECT_EQ(-1, error_code);
|
||||
parse_error_code(nullptr, error_code);
|
||||
EXPECT_EQ(-1, error_code);
|
||||
parse_error_code("9999999999999", error_code); // overflow
|
||||
EXPECT_EQ(-1, error_code);
|
||||
parse_error_code("123", error_code);
|
||||
EXPECT_EQ(123, error_code);
|
||||
|
||||
// test_parse_facility
|
||||
Fac facility = NONE;
|
||||
parse_facility("ABC", facility);
|
||||
EXPECT_EQ(NONE, facility);
|
||||
|
||||
facility = NONE;
|
||||
parse_facility("ORa", facility);
|
||||
EXPECT_EQ(ORA, facility);
|
||||
|
||||
facility = NONE;
|
||||
parse_facility("mY", facility);
|
||||
EXPECT_EQ(MY, facility);
|
||||
}
|
||||
} // end namespace unittest
|
||||
} // end namespace oceanbase
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user