Commit bec9de67 authored by unknown's avatar unknown

added classification "schema object already exists"


ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  added classification "schema object already exists"
  retrieved error from sub_stop_ref correctly
ndb/src/ndbapi/NdbEventOperationImpl.cpp:
  added classification "schema object already exists"
  + added error code for failed prepare drop subscribe event
parent 5ebc648e
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
*/ */
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <ndberror.h>
// Used for cout // Used for cout
#include <stdio.h> #include <stdio.h>
...@@ -251,7 +250,8 @@ int myCreateEvent(Ndb* myNdb, ...@@ -251,7 +250,8 @@ int myCreateEvent(Ndb* myNdb,
// Add event to database // Add event to database
if (myDict->createEvent(myEvent) == 0) if (myDict->createEvent(myEvent) == 0)
myEvent.print(); myEvent.print();
else if (myDict->getNdbError().code == NDBERR_EVENT_NAME_ALEADY_EXISTS) { else if (myDict->getNdbError().classification ==
NdbError::SchemaObjectExists) {
printf("Event creation failed, event exists\n"); printf("Event creation failed, event exists\n");
printf("dropping Event...\n"); printf("dropping Event...\n");
if (myDict->dropEvent(eventName)) APIERROR(myDict->getNdbError()); if (myDict->dropEvent(eventName)) APIERROR(myDict->getNdbError());
......
...@@ -366,7 +366,7 @@ struct CreateEvntRef { ...@@ -366,7 +366,7 @@ struct CreateEvntRef {
SeizeError = 703, SeizeError = 703,
TooManyEvents = 4707, TooManyEvents = 4707,
EventNameTooLong = 4708, EventNameTooLong = 4708,
EventNameExists = NDBERR_EVENT_NAME_ALEADY_EXISTS, EventNameExists = 746,
EventNotFound = 4731, EventNotFound = 4731,
AttributeNotStored = 4245, AttributeNotStored = 4245,
AttributeNullable = 4246, AttributeNullable = 4246,
......
...@@ -168,7 +168,12 @@ struct NdbError { ...@@ -168,7 +168,12 @@ struct NdbError {
/** /**
* Node shutdown * Node shutdown
*/ */
NodeShutdown = ndberror_cl_node_shutdown NodeShutdown = ndberror_cl_node_shutdown,
/**
* Schema object already exists
*/
SchemaObjectExists = ndberror_cl_schema_object_already_exists
}; };
/** /**
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
#ifndef NDBERROR_H #ifndef NDBERROR_H
#define NDBERROR_H #define NDBERROR_H
#define NDBERR_EVENT_NAME_ALEADY_EXISTS 746
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
...@@ -49,7 +47,8 @@ typedef enum ...@@ -49,7 +47,8 @@ typedef enum
ndberror_cl_function_not_implemented = 13, ndberror_cl_function_not_implemented = 13,
ndberror_cl_unknown_error_code = 14, ndberror_cl_unknown_error_code = 14,
ndberror_cl_node_shutdown = 15, ndberror_cl_node_shutdown = 15,
ndberror_cl_configuration = 16 ndberror_cl_configuration = 16,
ndberror_cl_schema_object_already_exists = 17
} ndberror_classification_enum; } ndberror_classification_enum;
......
...@@ -2602,6 +2602,7 @@ void ...@@ -2602,6 +2602,7 @@ void
NdbDictInterface::execSUB_STOP_CONF(NdbApiSignal * signal, NdbDictInterface::execSUB_STOP_CONF(NdbApiSignal * signal,
LinearSectionPtr ptr[3]) LinearSectionPtr ptr[3])
{ {
DBUG_ENTER("NdbDictInterface::execSUB_STOP_REF");
#ifdef EVENT_DEBUG #ifdef EVENT_DEBUG
ndbout << "Got GSN_SUB_STOP_CONF" << endl; ndbout << "Got GSN_SUB_STOP_CONF" << endl;
#endif #endif
...@@ -2618,17 +2619,21 @@ void ...@@ -2618,17 +2619,21 @@ void
NdbDictInterface::execSUB_STOP_REF(NdbApiSignal * signal, NdbDictInterface::execSUB_STOP_REF(NdbApiSignal * signal,
LinearSectionPtr ptr[3]) LinearSectionPtr ptr[3])
{ {
DBUG_ENTER("NdbDictInterface::execSUB_STOP_REF");
#ifdef EVENT_DEBUG #ifdef EVENT_DEBUG
ndbout << "Got GSN_SUB_STOP_REF" << endl; ndbout << "Got GSN_SUB_STOP_REF" << endl;
#endif #endif
// SubRemoveConf * const sumaRemoveRef = CAST_CONSTPTR(SubRemoveRef, signal->getDataPtr()); const SubRemoveRef * const sumaRemoveRef=
CAST_CONSTPTR(SubRemoveRef, signal->getDataPtr());
// Uint32 subscriptionId = sumaRemoveRef->subscriptionId; // Uint32 subscriptionId = sumaRemoveRef->subscriptionId;
// Uint32 subscriptionKey = sumaRemoveRef->subscriptionKey; // Uint32 subscriptionKey = sumaRemoveRef->subscriptionKey;
// Uint32 senderData = sumaRemoveRef->senderData; // Uint32 senderData = sumaRemoveRef->senderData;
m_error.code = 1; m_error.code= sumaRemoveRef->errorCode;
m_waiter.signal(NO_WAIT); m_waiter.signal(NO_WAIT);
DBUG_VOID_RETURN;
} }
void void
......
...@@ -260,15 +260,16 @@ NdbEventOperationImpl::execute() ...@@ -260,15 +260,16 @@ NdbEventOperationImpl::execute()
int int
NdbEventOperationImpl::stop() NdbEventOperationImpl::stop()
{ {
DBUG_ENTER("NdbEventOperationImpl::stop");
if (m_state != NdbEventOperation::EXECUTING) if (m_state != NdbEventOperation::EXECUTING)
return -1; DBUG_RETURN(-1);
// ndbout_c("NdbEventOperation::stopping()"); // ndbout_c("NdbEventOperation::stopping()");
NdbDictionary::Dictionary *myDict = m_ndb->getDictionary(); NdbDictionary::Dictionary *myDict = m_ndb->getDictionary();
if (!myDict) { if (!myDict) {
ndbout_c("NdbEventOperation::stop(): getDictionary=NULL"); ndbout_c("NdbEventOperation::stop(): getDictionary=NULL");
return 0; DBUG_RETURN(-1);
} }
NdbDictionaryImpl & myDictImpl = NdbDictionaryImpl::getImpl(*myDict); NdbDictionaryImpl & myDictImpl = NdbDictionaryImpl::getImpl(*myDict);
...@@ -279,8 +280,8 @@ NdbEventOperationImpl::stop() ...@@ -279,8 +280,8 @@ NdbEventOperationImpl::stop()
hasSubscriber /* return value */); hasSubscriber /* return value */);
if (ret < 0) { if (ret < 0) {
ndbout_c("prepareDropSubscribeEvent failed"); m_error.code= 4712;
return -1; DBUG_RETURN(-1);
} }
// m_eventImpl->m_bufferId = m_bufferId; // m_eventImpl->m_bufferId = m_bufferId;
...@@ -297,6 +298,7 @@ NdbEventOperationImpl::stop() ...@@ -297,6 +298,7 @@ NdbEventOperationImpl::stop()
if (r) { if (r) {
//Error //Error
m_bufferHandle->unprepareDropSubscribeEvent(m_bufferId); m_bufferHandle->unprepareDropSubscribeEvent(m_bufferId);
m_error.code= myDictImpl.m_error.code;
m_state = NdbEventOperation::ERROR; m_state = NdbEventOperation::ERROR;
} else { } else {
#ifdef EVENT_DEBUG #ifdef EVENT_DEBUG
...@@ -306,8 +308,7 @@ NdbEventOperationImpl::stop() ...@@ -306,8 +308,7 @@ NdbEventOperationImpl::stop()
m_state = NdbEventOperation::CREATED; m_state = NdbEventOperation::CREATED;
} }
DBUG_RETURN(r);
return r;
} }
bool bool
...@@ -955,7 +956,7 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent ...@@ -955,7 +956,7 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent
} else { } else {
ndbout_c("prepareAddSubscribeEvent: Can't accept more subscribers"); ndbout_c("prepareAddSubscribeEvent: Can't accept more subscribers");
// add_drop_unlock(); // add_drop_unlock();
return -1; DBUG_RETURN(-1);
} }
} }
bufferId = NO_ID(ni, bufferId); bufferId = NO_ID(ni, bufferId);
...@@ -1047,6 +1048,7 @@ int ...@@ -1047,6 +1048,7 @@ int
NdbGlobalEventBuffer::real_prepareDropSubscribeEvent(int bufferId, NdbGlobalEventBuffer::real_prepareDropSubscribeEvent(int bufferId,
int& hasSubscriber) int& hasSubscriber)
{ {
DBUG_ENTER("NdbGlobalEventBuffer::real_prepareDropSubscribeEvent");
// add_drop_lock(); // only one thread can do add or drop at a time // add_drop_lock(); // only one thread can do add or drop at a time
BufItem &b = m_buf[ID(bufferId)]; BufItem &b = m_buf[ID(bufferId)];
...@@ -1062,9 +1064,9 @@ NdbGlobalEventBuffer::real_prepareDropSubscribeEvent(int bufferId, ...@@ -1062,9 +1064,9 @@ NdbGlobalEventBuffer::real_prepareDropSubscribeEvent(int bufferId,
else if (n == 1) else if (n == 1)
hasSubscriber = 0; hasSubscriber = 0;
else else
return -1; DBUG_RETURN(-1);
return 0; DBUG_RETURN(0);
} }
void void
......
...@@ -55,6 +55,8 @@ typedef struct ErrorBundle { ...@@ -55,6 +55,8 @@ typedef struct ErrorBundle {
#define NI ndberror_cl_function_not_implemented #define NI ndberror_cl_function_not_implemented
#define UE ndberror_cl_unknown_error_code #define UE ndberror_cl_unknown_error_code
#define OE ndberror_cl_schema_object_already_exists
static const char REDO_BUFFER_MSG[]= static const char REDO_BUFFER_MSG[]=
"REDO log buffers overloaded, consult online manual (increase RedoBuffer, and|or decrease TimeBetweenLocalCheckpoints, and|or increase NoOfFragmentLogFiles)"; "REDO log buffers overloaded, consult online manual (increase RedoBuffer, and|or decrease TimeBetweenLocalCheckpoints, and|or increase NoOfFragmentLogFiles)";
...@@ -304,9 +306,10 @@ ErrorBundle ErrorCodes[] = { ...@@ -304,9 +306,10 @@ ErrorBundle ErrorCodes[] = {
{ 4707, AE, "Too many event have been defined"}, { 4707, AE, "Too many event have been defined"},
{ 4708, AE, "Event name is too long"}, { 4708, AE, "Event name is too long"},
{ 4709, AE, "Can't accept more subscribers"}, { 4709, AE, "Can't accept more subscribers"},
{ NDBERR_EVENT_NAME_ALEADY_EXISTS, AE, "Event name already exists"}, { 746, OE, "Event name already exists"},
{ 4710, AE, "Event not found"}, { 4710, AE, "Event not found"},
{ 4711, AE, "Creation of event failed"}, { 4711, AE, "Creation of event failed"},
{ 4712, AE, "Stopped event operation does not exist. Already stopped?"},
/** /**
* Event internal errors * Event internal errors
...@@ -324,7 +327,7 @@ ErrorBundle ErrorCodes[] = { ...@@ -324,7 +327,7 @@ ErrorBundle ErrorCodes[] = {
{ 707, SE, "No more table metadata records" }, { 707, SE, "No more table metadata records" },
{ 708, SE, "No more attribute metadata records" }, { 708, SE, "No more attribute metadata records" },
{ 709, SE, "No such table existed" }, { 709, SE, "No such table existed" },
{ 721, SE, "Table or index with given name already exists" }, { 721, OE, "Table or index with given name already exists" },
{ 723, SE, "No such table existed" }, { 723, SE, "No such table existed" },
{ 736, SE, "Unsupported array size" }, { 736, SE, "Unsupported array size" },
{ 737, SE, "Attribute array size too big" }, { 737, SE, "Attribute array size too big" },
...@@ -484,7 +487,7 @@ ErrorBundle ErrorCodes[] = { ...@@ -484,7 +487,7 @@ ErrorBundle ErrorCodes[] = {
{ 4241, AE, "Index name too long" }, { 4241, AE, "Index name too long" },
{ 4242, AE, "Too many indexes" }, { 4242, AE, "Too many indexes" },
{ 4243, AE, "Index not found" }, { 4243, AE, "Index not found" },
{ 4244, AE, "Index or table with given name already exists" }, { 4244, OE, "Index or table with given name already exists" },
{ 4245, AE, "Index attribute must be defined as stored, i.e. the StorageAttributeType must be defined as NormalStorageAttribute"}, { 4245, AE, "Index attribute must be defined as stored, i.e. the StorageAttributeType must be defined as NormalStorageAttribute"},
{ 4247, AE, "Illegal index/trigger create/drop/alter request" }, { 4247, AE, "Illegal index/trigger create/drop/alter request" },
{ 4248, AE, "Trigger/index name invalid" }, { 4248, AE, "Trigger/index name invalid" },
......
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