feat(ob_error): add ob_error tool (#192)
This commit is contained in:
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 */
|
||||
Reference in New Issue
Block a user