Commit 7464c9f3 authored by unknown's avatar unknown

ndb - blob tables vs dict cache : patch 2 - bug#17761 (maybe)


storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  by-pass dict cache when creating blob event op
  does get event using table stored under main event op
  in preparation to remove blob tables from dict cache
storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp:
  by-pass dict cache when creating blob event op
  does get event using table stored under main event op
  in preparation to remove blob tables from dict cache
storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp:
  by-pass dict cache when creating blob event op
  does get event using table stored under main event op
  in preparation to remove blob tables from dict cache
storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp:
  by-pass dict cache when creating blob event op
  does get event using table stored under main event op
  in preparation to remove blob tables from dict cache
parent 104b9e78
...@@ -3480,7 +3480,7 @@ NdbDictInterface::stopSubscribeEvent(class Ndb & ndb, ...@@ -3480,7 +3480,7 @@ NdbDictInterface::stopSubscribeEvent(class Ndb & ndb,
} }
NdbEventImpl * NdbEventImpl *
NdbDictionaryImpl::getEvent(const char * eventName) NdbDictionaryImpl::getEvent(const char * eventName, NdbTableImpl* tab)
{ {
DBUG_ENTER("NdbDictionaryImpl::getEvent"); DBUG_ENTER("NdbDictionaryImpl::getEvent");
DBUG_PRINT("enter",("eventName= %s", eventName)); DBUG_PRINT("enter",("eventName= %s", eventName));
...@@ -3499,6 +3499,7 @@ NdbDictionaryImpl::getEvent(const char * eventName) ...@@ -3499,6 +3499,7 @@ NdbDictionaryImpl::getEvent(const char * eventName)
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
if (tab == NULL) {
// We only have the table name with internal name // We only have the table name with internal name
DBUG_PRINT("info",("table %s", ev->getTableName())); DBUG_PRINT("info",("table %s", ev->getTableName()));
Ndb_local_table_info *info; Ndb_local_table_info *info;
...@@ -3520,7 +3521,10 @@ NdbDictionaryImpl::getEvent(const char * eventName) ...@@ -3520,7 +3521,10 @@ NdbDictionaryImpl::getEvent(const char * eventName)
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
} }
ev->setTable(info->m_table_impl); tab = info->m_table_impl;
}
ev->setTable(tab);
ev->setTable(m_ndb.externalizeTableName(ev->getTableName())); ev->setTable(m_ndb.externalizeTableName(ev->getTableName()));
// get the columns from the attrListBitmask // get the columns from the attrListBitmask
NdbTableImpl &table = *ev->m_tableImpl; NdbTableImpl &table = *ev->m_tableImpl;
...@@ -3568,6 +3572,26 @@ NdbDictionaryImpl::getEvent(const char * eventName) ...@@ -3568,6 +3572,26 @@ NdbDictionaryImpl::getEvent(const char * eventName)
DBUG_RETURN(ev); DBUG_RETURN(ev);
} }
// ev is main event and has been retrieved previously
NdbEventImpl *
NdbDictionaryImpl::getBlobEvent(const NdbEventImpl& ev, uint col_no)
{
DBUG_ENTER("NdbDictionaryImpl::getBlobEvent");
DBUG_PRINT("enter", ("ev=%s col=%u", ev.m_name.c_str(), col_no));
NdbTableImpl* tab = ev.m_tableImpl;
assert(tab != NULL && col_no < tab->m_columns.size());
NdbColumnImpl* col = tab->m_columns[col_no];
assert(col != NULL && col->getBlobType() && col->getPartSize() != 0);
NdbTableImpl* blob_tab = col->m_blobTable;
assert(blob_tab != NULL);
char bename[MAX_TAB_NAME_SIZE];
NdbBlob::getBlobEventName(bename, &ev, col);
NdbEventImpl* blob_ev = getEvent(bename, blob_tab);
DBUG_RETURN(blob_ev);
}
void void
NdbDictInterface::execCREATE_EVNT_CONF(NdbApiSignal * signal, NdbDictInterface::execCREATE_EVNT_CONF(NdbApiSignal * signal,
LinearSectionPtr ptr[3]) LinearSectionPtr ptr[3])
......
...@@ -577,7 +577,8 @@ public: ...@@ -577,7 +577,8 @@ public:
const BaseString& internalTableName, bool do_add_blob_tables); const BaseString& internalTableName, bool do_add_blob_tables);
NdbIndexImpl * getIndex(const char * indexName, NdbIndexImpl * getIndex(const char * indexName,
const char * tableName); const char * tableName);
NdbEventImpl * getEvent(const char * eventName); NdbEventImpl * getEvent(const char * eventName, NdbTableImpl* = NULL);
NdbEventImpl * getBlobEvent(const NdbEventImpl& ev, uint col_no);
NdbEventImpl * getEventImpl(const char * internalName); NdbEventImpl * getEventImpl(const char * internalName);
int createDatafile(const NdbDatafileImpl &, bool force = false); int createDatafile(const NdbDatafileImpl &, bool force = false);
......
...@@ -88,18 +88,55 @@ print_std(const SubTableData * sdata, LinearSectionPtr ptr[3]) ...@@ -88,18 +88,55 @@ print_std(const SubTableData * sdata, LinearSectionPtr ptr[3])
// todo handle several ndb objects // todo handle several ndb objects
// todo free allocated data when closing NdbEventBuffer // todo free allocated data when closing NdbEventBuffer
NdbEventOperationImpl::NdbEventOperationImpl(NdbEventOperation &N, NdbEventOperationImpl::NdbEventOperationImpl(NdbEventOperation &f,
Ndb *theNdb, Ndb *theNdb,
const char* eventName) const char* eventName) :
: NdbEventOperation(*this), m_facade(&N), m_magic_number(0), NdbEventOperation(*this),
m_ndb(theNdb), m_state(EO_ERROR), mi_type(0), m_oid(~(Uint32)0), m_facade(&f),
m_change_mask(0), m_ndb(theNdb),
#ifdef VM_TRACE m_state(EO_ERROR)
m_data_done_count(0), m_data_count(0),
#endif
m_next(0), m_prev(0)
{ {
DBUG_ENTER("NdbEventOperationImpl::NdbEventOperationImpl"); DBUG_ENTER("NdbEventOperationImpl::NdbEventOperationImpl");
assert(m_ndb != NULL);
NdbDictionary::Dictionary *myDict = m_ndb->getDictionary();
assert(myDict != NULL);
const NdbDictionary::Event *myEvnt = myDict->getEvent(eventName);
if (!myEvnt) { m_error.code= myDict->getNdbError().code; DBUG_VOID_RETURN; }
init(myEvnt->m_impl);
DBUG_VOID_RETURN;
}
NdbEventOperationImpl::NdbEventOperationImpl(Ndb *theNdb,
NdbEventImpl& evnt) :
NdbEventOperation(*this),
m_facade(this),
m_ndb(theNdb),
m_state(EO_ERROR)
{
DBUG_ENTER("NdbEventOperationImpl::NdbEventOperationImpl [evnt]");
init(evnt);
DBUG_VOID_RETURN;
}
void
NdbEventOperationImpl::init(NdbEventImpl& evnt)
{
DBUG_ENTER("NdbEventOperationImpl::init");
m_magic_number = 0;
mi_type = 0;
m_oid = ~(Uint32)0;
m_change_mask = 0;
#ifdef VM_TRACE
m_data_done_count = 0;
m_data_count = 0;
#endif
m_next = 0;
m_prev = 0;
m_eventId = 0; m_eventId = 0;
theFirstPkAttrs[0] = NULL; theFirstPkAttrs[0] = NULL;
theCurrentPkAttrs[0] = NULL; theCurrentPkAttrs[0] = NULL;
...@@ -123,15 +160,7 @@ NdbEventOperationImpl::NdbEventOperationImpl(NdbEventOperation &N, ...@@ -123,15 +160,7 @@ NdbEventOperationImpl::NdbEventOperationImpl(NdbEventOperation &N,
// we should lookup id in Dictionary, TODO // we should lookup id in Dictionary, TODO
// also make sure we only have one listener on each event // also make sure we only have one listener on each event
if (!m_ndb) abort(); m_eventImpl = &evnt;
NdbDictionary::Dictionary *myDict = m_ndb->getDictionary();
if (!myDict) { m_error.code= m_ndb->getNdbError().code; DBUG_VOID_RETURN; }
const NdbDictionary::Event *myEvnt = myDict->getEvent(eventName);
if (!myEvnt) { m_error.code= myDict->getNdbError().code; DBUG_VOID_RETURN; }
m_eventImpl = &myEvnt->m_impl;
m_eventId = m_eventImpl->m_eventId; m_eventId = m_eventImpl->m_eventId;
...@@ -347,18 +376,27 @@ NdbEventOperationImpl::getBlobHandle(const NdbColumnImpl *tAttrInfo, int n) ...@@ -347,18 +376,27 @@ NdbEventOperationImpl::getBlobHandle(const NdbColumnImpl *tAttrInfo, int n)
// create blob event op if not found // create blob event op if not found
if (tBlobOp == NULL) { if (tBlobOp == NULL) {
// to hide blob op it is linked under main op, not under m_ndb // get blob event
NdbEventOperation* tmp = NdbDictionaryImpl& dict =
m_ndb->theEventBuffer->createEventOperation(bename, m_error); NdbDictionaryImpl::getImpl(*m_ndb->getDictionary());
if (tmp == NULL) NdbEventImpl* blobEvnt =
dict.getBlobEvent(*this->m_eventImpl, tAttrInfo->m_column_no);
if (blobEvnt == NULL) {
m_error.code = dict.m_error.code;
DBUG_RETURN(NULL);
}
// create blob event operation
tBlobOp =
m_ndb->theEventBuffer->createEventOperation(*blobEvnt, m_error);
if (tBlobOp == NULL)
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
tBlobOp = &tmp->m_impl;
// pointer to main table op // pointer to main table op
tBlobOp->theMainOp = this; tBlobOp->theMainOp = this;
tBlobOp->m_mergeEvents = m_mergeEvents; tBlobOp->m_mergeEvents = m_mergeEvents;
// add to list end // to hide blob op it is linked under main op, not under m_ndb
if (tLastBlopOp == NULL) if (tLastBlopOp == NULL)
theBlobOpList = tBlobOp; theBlobOpList = tBlobOp;
else else
...@@ -2131,6 +2169,25 @@ NdbEventBuffer::createEventOperation(const char* eventName, ...@@ -2131,6 +2169,25 @@ NdbEventBuffer::createEventOperation(const char* eventName,
DBUG_RETURN(tOp); DBUG_RETURN(tOp);
} }
NdbEventOperationImpl*
NdbEventBuffer::createEventOperation(NdbEventImpl& evnt,
NdbError &theError)
{
DBUG_ENTER("NdbEventBuffer::createEventOperation [evnt]");
NdbEventOperationImpl* tOp= new NdbEventOperationImpl(m_ndb, evnt);
if (tOp == 0)
{
theError.code= 4000;
DBUG_RETURN(NULL);
}
if (tOp->getState() != NdbEventOperation::EO_CREATED) {
theError.code= tOp->getNdbError().code;
delete tOp;
DBUG_RETURN(NULL);
}
DBUG_RETURN(tOp);
}
void void
NdbEventBuffer::dropEventOperation(NdbEventOperation* tOp) NdbEventBuffer::dropEventOperation(NdbEventOperation* tOp)
{ {
......
...@@ -202,9 +202,12 @@ struct Gci_container ...@@ -202,9 +202,12 @@ struct Gci_container
class NdbEventOperationImpl : public NdbEventOperation { class NdbEventOperationImpl : public NdbEventOperation {
public: public:
NdbEventOperationImpl(NdbEventOperation &N, NdbEventOperationImpl(NdbEventOperation &f,
Ndb *theNdb, Ndb *theNdb,
const char* eventName); const char* eventName);
NdbEventOperationImpl(Ndb *theNdb,
NdbEventImpl& evnt);
void init(NdbEventImpl& evnt);
NdbEventOperationImpl(NdbEventOperationImpl&); //unimplemented NdbEventOperationImpl(NdbEventOperationImpl&); //unimplemented
NdbEventOperationImpl& operator=(const NdbEventOperationImpl&); //unimplemented NdbEventOperationImpl& operator=(const NdbEventOperationImpl&); //unimplemented
~NdbEventOperationImpl(); ~NdbEventOperationImpl();
...@@ -293,6 +296,8 @@ public: ...@@ -293,6 +296,8 @@ public:
Vector<Gci_container> m_active_gci; Vector<Gci_container> m_active_gci;
NdbEventOperation *createEventOperation(const char* eventName, NdbEventOperation *createEventOperation(const char* eventName,
NdbError &); NdbError &);
NdbEventOperationImpl *createEventOperation(NdbEventImpl& evnt,
NdbError &);
void dropEventOperation(NdbEventOperation *); void dropEventOperation(NdbEventOperation *);
static NdbEventOperationImpl* getEventOperationImpl(NdbEventOperation* tOp); static NdbEventOperationImpl* getEventOperationImpl(NdbEventOperation* tOp);
......
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