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