未验证 提交 a6d5591d 编写于 作者: A a1iive 提交者: GitHub

feat(ob_error): add ob_error tool (#192)

上级 b20901e8
......@@ -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 common
namespace oceanbase {
namespace common {
const char *ob_error_name(const int err)
{
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;
}
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_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_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_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_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_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;
}
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;
}
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;
}
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_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_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_mysql_errno(const int err)
{
int ret = -1;
if (OB_LIKELY(0 >= err && err > -OB_MAX_ERROR_CODE)) {
ret = MYSQL_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;
return ret;
}
int ob_mysql_errno_with_check(const int err)
{
int ret = ob_mysql_errno(err);
if (ret < 0) {
ret = -err;
}
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;
}
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_oracle_errno_with_check(const int err)
{
int ret = ob_oracle_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;
}
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));
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_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
......
此差异已折叠。
......@@ -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);
......
add_subdirectory(ob_error)
\ No newline at end of file
add_subdirectory(src)
\ No newline at end of file
# 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`.
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})
\ No newline at end of file
#!/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
';
此差异已折叠。
/**
* 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 */
此差异已折叠。
//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");
\ No newline at end of file
/**
* 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 */
$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)
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
#!/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)
add_subdirectory(ob_error)
\ No newline at end of file
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)
\ No newline at end of file
/**
* 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();
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册