summaryrefslogtreecommitdiff
path: root/storage/ndb
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-08-27 17:12:44 +0300
committerMichael Widenius <monty@askmonty.org>2010-08-27 17:12:44 +0300
commitad6d95d3cb420557cfc7efa658181a8d20b4c154 (patch)
tree984bb45ca187a6cc38c7132a9600d91515df564e /storage/ndb
parent9bc9855c16f815e71223398ef17cd6052becc44e (diff)
parent7909541953de43c7b7d16513c8d612cfe405af67 (diff)
downloadmariadb-git-ad6d95d3cb420557cfc7efa658181a8d20b4c154.tar.gz
Merge with MySQL 5.1.50
- Changed to still use bcmp() in certain cases becasue - Faster for short unaligneed strings than memcmp() - Bettern when using valgrind - Changed to use my_sprintf() instead of sprintf() to get higher portability for old systems - Changed code to use MariaDB version of select->skip_record() - Removed -%::SCCS/s.% from Makefile.am:s to remove automake warnings
Diffstat (limited to 'storage/ndb')
-rw-r--r--storage/ndb/src/common/portlib/NdbMutex.c21
-rw-r--r--storage/ndb/src/ndbapi/DictCache.cpp32
2 files changed, 34 insertions, 19 deletions
diff --git a/storage/ndb/src/common/portlib/NdbMutex.c b/storage/ndb/src/common/portlib/NdbMutex.c
index c9184e5d1f2..5595baba7c4 100644
--- a/storage/ndb/src/common/portlib/NdbMutex.c
+++ b/storage/ndb/src/common/portlib/NdbMutex.c
@@ -24,36 +24,31 @@ NdbMutex* NdbMutex_Create(void)
{
NdbMutex* pNdbMutex;
int result;
- DBUG_ENTER("NdbMutex_Create");
-
+
pNdbMutex = (NdbMutex*)NdbMem_Allocate(sizeof(NdbMutex));
- DBUG_PRINT("info",("NdbMem_Allocate 0x%lx", (long) pNdbMutex));
-
+
if (pNdbMutex == NULL)
- DBUG_RETURN(NULL);
-
+ return NULL;
+
result = pthread_mutex_init(pNdbMutex, NULL);
assert(result == 0);
-
- DBUG_RETURN(pNdbMutex);
+
+ return pNdbMutex;
}
int NdbMutex_Destroy(NdbMutex* p_mutex)
{
int result;
- DBUG_ENTER("NdbMutex_Destroy");
if (p_mutex == NULL)
- DBUG_RETURN(-1);
+ return -1;
result = pthread_mutex_destroy(p_mutex);
- DBUG_PRINT("info",("NdbMem_Free 0x%lx", (long) p_mutex));
NdbMem_Free(p_mutex);
-
- DBUG_RETURN(result);
+ return result;
}
diff --git a/storage/ndb/src/ndbapi/DictCache.cpp b/storage/ndb/src/ndbapi/DictCache.cpp
index 04be3711847..9c66b2be9d2 100644
--- a/storage/ndb/src/ndbapi/DictCache.cpp
+++ b/storage/ndb/src/ndbapi/DictCache.cpp
@@ -20,8 +20,10 @@
#include <NdbCondition.h>
#include <NdbSleep.h>
-static NdbTableImpl f_invalid_table;
-static NdbTableImpl f_altered_table;
+static NdbTableImpl * f_invalid_table = 0;
+static NdbTableImpl * f_altered_table = 0;
+
+static int ndb_dict_cache_count = 0;
Ndb_local_table_info *
Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz)
@@ -93,11 +95,29 @@ GlobalDictCache::GlobalDictCache(){
DBUG_ENTER("GlobalDictCache::GlobalDictCache");
m_tableHash.createHashTable();
m_waitForTableCondition = NdbCondition_Create();
+ if (f_invalid_table == NULL)
+ f_invalid_table = new NdbTableImpl();
+ if (f_altered_table == NULL)
+ f_altered_table = new NdbTableImpl();
+ ndb_dict_cache_count++;
DBUG_VOID_RETURN;
}
GlobalDictCache::~GlobalDictCache(){
DBUG_ENTER("GlobalDictCache::~GlobalDictCache");
+ if (--ndb_dict_cache_count == 0)
+ {
+ if (f_invalid_table)
+ {
+ delete f_invalid_table;
+ f_invalid_table = 0;
+ }
+ if (f_altered_table)
+ {
+ delete f_altered_table;
+ f_altered_table = 0;
+ }
+ }
NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
while(curr != 0){
Vector<TableVersion> * vers = curr->theData;
@@ -254,7 +274,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab)
TableVersion & ver = vers->back();
if(ver.m_status != RETREIVING ||
!(ver.m_impl == 0 ||
- ver.m_impl == &f_invalid_table || ver.m_impl == &f_altered_table) ||
+ ver.m_impl == f_invalid_table || ver.m_impl == f_altered_table) ||
ver.m_version != 0 ||
ver.m_refCount == 0){
abort();
@@ -271,7 +291,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab)
ver.m_version = tab->m_version;
ver.m_status = OK;
}
- else if (ver.m_impl == &f_invalid_table)
+ else if (ver.m_impl == f_invalid_table)
{
DBUG_PRINT("info", ("Table DROPPED invalid"));
ver.m_impl = tab;
@@ -279,7 +299,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab)
ver.m_status = DROPPED;
ver.m_impl->m_status = NdbDictionary::Object::Invalid;
}
- else if(ver.m_impl == &f_altered_table)
+ else if(ver.m_impl == f_altered_table)
{
DBUG_PRINT("info", ("Table DROPPED altered"));
ver.m_impl = tab;
@@ -440,7 +460,7 @@ GlobalDictCache::alter_table_rep(const char * name,
if(i == sz - 1 && ver.m_status == RETREIVING)
{
- ver.m_impl = altered ? &f_altered_table : &f_invalid_table;
+ ver.m_impl = altered ? f_altered_table : f_invalid_table;
DBUG_VOID_RETURN;
}
}