Commit 9f76f43c authored by unknown's avatar unknown

Restructure of ndb error


ndb/src/kernel/blocks/backup/restore/Makefile:
  better make
parent 93448ea5
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#ifndef NDB_ERROR_HPP #ifndef NDB_ERROR_HPP
#define NDB_ERROR_HPP #define NDB_ERROR_HPP
#include <ndberror.h>
/** /**
* @struct NdbError * @struct NdbError
* @brief Contains error information * @brief Contains error information
...@@ -51,7 +53,7 @@ struct NdbError { ...@@ -51,7 +53,7 @@ struct NdbError {
* The error code indicate success<br> * The error code indicate success<br>
* (Includes classification: NdbError::NoError) * (Includes classification: NdbError::NoError)
*/ */
Success = 0, Success = ndberror_st_success,
/** /**
* The error code indicates a temporary error. * The error code indicates a temporary error.
...@@ -61,7 +63,7 @@ struct NdbError { ...@@ -61,7 +63,7 @@ struct NdbError {
* NdbError::OverloadError, NdbError::NodeShutdown * NdbError::OverloadError, NdbError::NodeShutdown
* and NdbError::TimeoutExpired.) * and NdbError::TimeoutExpired.)
*/ */
TemporaryError = 1, TemporaryError = ndberror_st_temporary,
/** /**
* The error code indicates a permanent error.<br> * The error code indicates a permanent error.<br>
...@@ -71,14 +73,14 @@ struct NdbError { ...@@ -71,14 +73,14 @@ struct NdbError {
* NdbError::UserDefinedError, NdbError::InternalError, and, * NdbError::UserDefinedError, NdbError::InternalError, and,
* NdbError::FunctionNotImplemented.) * NdbError::FunctionNotImplemented.)
*/ */
PermanentError = 2, PermanentError = ndberror_st_permanent,
/** /**
* The result/status is unknown.<br> * The result/status is unknown.<br>
* (Includes classifications: NdbError::UnknownResultError, and * (Includes classifications: NdbError::UnknownResultError, and
* NdbError::UnknownErrorCode.) * NdbError::UnknownErrorCode.)
*/ */
UnknownResult = 3 UnknownResult = ndberror_st_unknown
}; };
/** /**
...@@ -88,85 +90,85 @@ struct NdbError { ...@@ -88,85 +90,85 @@ struct NdbError {
/** /**
* Success. No error occurred. * Success. No error occurred.
*/ */
NoError = 0, NoError = ndberror_cl_none,
/** /**
* Error in application program. * Error in application program.
*/ */
ApplicationError = 1, ApplicationError = ndberror_cl_application,
/** /**
* Read operation failed due to missing record. * Read operation failed due to missing record.
*/ */
NoDataFound = 2, NoDataFound = ndberror_cl_no_data_found,
/** /**
* E.g. inserting a tuple with a primary key already existing * E.g. inserting a tuple with a primary key already existing
* in the table. * in the table.
*/ */
ConstraintViolation = 3, ConstraintViolation = ndberror_cl_constraint_violation,
/** /**
* Error in creating table or usage of table. * Error in creating table or usage of table.
*/ */
SchemaError = 4, SchemaError = ndberror_cl_schema_error,
/** /**
* Error occurred in interpreted program. * Error occurred in interpreted program.
*/ */
UserDefinedError = 5, UserDefinedError = ndberror_cl_user_defined,
/** /**
* E.g. insufficient memory for data or indexes. * E.g. insufficient memory for data or indexes.
*/ */
InsufficientSpace = 6, InsufficientSpace = ndberror_cl_insufficient_space,
/** /**
* E.g. too many active transactions. * E.g. too many active transactions.
*/ */
TemporaryResourceError = 7, TemporaryResourceError = ndberror_cl_temporary_resource,
/** /**
* Temporary failures which are probably inflicted by a node * Temporary failures which are probably inflicted by a node
* recovery in progress. Examples: information sent between * recovery in progress. Examples: information sent between
* application and NDB lost, distribution change. * application and NDB lost, distribution change.
*/ */
NodeRecoveryError = 8, NodeRecoveryError = ndberror_cl_node_recovery,
/** /**
* E.g. out of log file space. * E.g. out of log file space.
*/ */
OverloadError = 9, OverloadError = ndberror_cl_overload,
/** /**
* Timeouts, often inflicted by deadlocks in NDB. * Timeouts, often inflicted by deadlocks in NDB.
*/ */
TimeoutExpired = 10, TimeoutExpired = ndberror_cl_timeout_expired,
/** /**
* Is is unknown whether the transaction was committed or not. * Is is unknown whether the transaction was committed or not.
*/ */
UnknownResultError = 11, UnknownResultError = ndberror_cl_unknown_result,
/** /**
* A serious error in NDB has occurred. * A serious error in NDB has occurred.
*/ */
InternalError = 12, InternalError = ndberror_cl_internal_error,
/** /**
* A function used is not yet implemented. * A function used is not yet implemented.
*/ */
FunctionNotImplemented = 13, FunctionNotImplemented = ndberror_cl_function_not_implemented,
/** /**
* Error handler could not determine correct error code. * Error handler could not determine correct error code.
*/ */
UnknownErrorCode = 14, UnknownErrorCode = ndberror_cl_unknown_error_code,
/** /**
* Node shutdown * Node shutdown
*/ */
NodeShutdown = 15 NodeShutdown = ndberror_cl_node_shutdown
}; };
/** /**
...@@ -204,6 +206,22 @@ struct NdbError { ...@@ -204,6 +206,22 @@ struct NdbError {
message = 0; message = 0;
details = 0; details = 0;
} }
NdbError(ndberror_struct ndberror){
status = (NdbError::Status) ndberror.status;
classification = (NdbError::Classification) ndberror.classification;
code = ndberror.code;
message = ndberror.message;
details = ndberror.details;
}
operator ndberror_struct() const {
ndberror_struct ndberror;
ndberror.status = (ndberror_status_enum) status;
ndberror.classification = (ndberror_classification_enum) classification;
ndberror.code = code;
ndberror.message = message;
ndberror.details = details;
return ndberror;
}
}; };
class NdbOut& operator <<(class NdbOut&, const NdbError &); class NdbOut& operator <<(class NdbOut&, const NdbError &);
......
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef NDBERROR_H
#define NDBERROR_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
ndberror_st_success = 0,
ndberror_st_temporary = 1,
ndberror_st_permanent = 2,
ndberror_st_unknown = 3
} ndberror_status_enum;
typedef enum
{
ndberror_cl_none = 0,
ndberror_cl_application = 1,
ndberror_cl_no_data_found = 2,
ndberror_cl_constraint_violation = 3,
ndberror_cl_schema_error = 4,
ndberror_cl_user_defined = 5,
ndberror_cl_insufficient_space = 6,
ndberror_cl_temporary_resource = 7,
ndberror_cl_node_recovery = 8,
ndberror_cl_overload = 9,
ndberror_cl_timeout_expired = 10,
ndberror_cl_unknown_result = 11,
ndberror_cl_internal_error = 12,
ndberror_cl_function_not_implemented = 13,
ndberror_cl_unknown_error_code = 14,
ndberror_cl_node_shutdown = 15
} ndberror_classification_enum;
typedef struct {
/**
* Error status.
*/
ndberror_status_enum status;
/**
* Error type
*/
ndberror_classification_enum classification;
/**
* Error code
*/
int code;
/**
* Error message
*/
const char * message;
/**
* The detailed description. This is extra information regarding the
* error which is not included in the error message.
*
* @note Is NULL when no details specified
*/
char * details;
} ndberror_struct;
typedef ndberror_status_enum ndberror_status;
typedef ndberror_classification_enum ndberror_classification;
const char *ndberror_status_message(const ndberror_status);
const char *ndberror_classification_message(const ndberror_classification);
void ndberror_update(ndberror_struct *);
int ndb_error_string(int err_no, char *str, size_t size);
#ifdef __cplusplus
}
#endif
#endif
include .defs.mk include .defs.mk
TYPE := ndbapi ndbapiclient TYPE := *
BIN_TARGET := restore BIN_TARGET := restore
BIN_TARGET_LIBS := BIN_TARGET_LIBS :=
BIN_TARGET_ARCHIVES := NDB_API general BIN_TARGET_ARCHIVES := NDB_API
CCFLAGS_LOC = -I.. -I$(NDB_TOP)/src/ndbapi CCFLAGS_LOC = -I.. -I$(NDB_TOP)/src/ndbapi -I$(NDB_TOP)/include/ndbapi -I$(NDB_TOP)/include/util -I$(NDB_TOP)/include/portlib -I$(NDB_TOP)/include/kernel
#ifneq ($(MYSQLCLUSTER_TOP),) #ifneq ($(MYSQLCLUSTER_TOP),)
#CCFLAGS_LOC +=-I$(MYSQLCLUSTER_TOP)/include -D USE_MYSQL #CCFLAGS_LOC +=-I$(MYSQLCLUSTER_TOP)/include -D USE_MYSQL
......
...@@ -32,6 +32,7 @@ SOURCES = \ ...@@ -32,6 +32,7 @@ SOURCES = \
Ndbif.cpp \ Ndbif.cpp \
Ndbinit.cpp \ Ndbinit.cpp \
Ndberror.cpp \ Ndberror.cpp \
ndberror.c \
NdbErrorOut.cpp \ NdbErrorOut.cpp \
NdbConnection.cpp \ NdbConnection.cpp \
NdbConnectionScan.cpp \ NdbConnectionScan.cpp \
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <NdbError.hpp>
#include <NdbStdio.h> #include <NdbStdio.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -23,10 +22,7 @@ ...@@ -23,10 +22,7 @@
#include <NdbOut.hpp> #include <NdbOut.hpp>
const char *ndberror_status_message(const NdbError::Status & status); #include <NdbError.hpp>
const char *ndberror_classification_message(const NdbError::Classification & classification);
int ndb_error_string(int err_no, char *str, size_t size);
void ndberror_update(const NdbError & _err);
/** /**
* operators * operators
...@@ -42,66 +38,11 @@ operator<<(NdbOut & out, const NdbError & error){ ...@@ -42,66 +38,11 @@ operator<<(NdbOut & out, const NdbError & error){
NdbOut & NdbOut &
operator<<(NdbOut & out, const NdbError::Status & status){ operator<<(NdbOut & out, const NdbError::Status & status){
return out << ndberror_status_message(status); return out << ndberror_status_message((ndberror_status)status);
} }
NdbOut & NdbOut &
operator<<(NdbOut & out, const NdbError::Classification & classification){ operator<<(NdbOut & out, const NdbError::Classification & classification){
return out << ndberror_classification_message(classification); return out << ndberror_classification_message((ndberror_classification)classification);
}
/******************************************************
*
*/
#include "NdbImpl.hpp"
#include "NdbDictionaryImpl.hpp"
#include <NdbSchemaCon.hpp>
#include <NdbOperation.hpp>
#include <NdbConnection.hpp>
const
NdbError &
Ndb::getNdbError(int code){
theError.code = code;
ndberror_update(theError);
return theError;
} }
const
NdbError &
Ndb::getNdbError() const {
ndberror_update(theError);
return theError;
}
const
NdbError &
NdbDictionaryImpl::getNdbError() const {
ndberror_update(m_error);
return m_error;
}
const
NdbError &
NdbConnection::getNdbError() const {
ndberror_update(theError);
return theError;
}
const
NdbError &
NdbOperation::getNdbError() const {
ndberror_update(theError);
return theError;
}
const
NdbError &
NdbSchemaCon::getNdbError() const {
ndberror_update(theError);
return theError;
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment