mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
BUG#9626 Several serious errors reported by Valgrind in latest 5.0 bk tree
- Fix several valgrind warnings. ndb/include/kernel/AttributeList.hpp: Include ndb_limits.h ndb/include/ndbapi/Ndb.hpp: Add new function internalize_table_name Proper formatting ndb/include/util/SimpleProperties.hpp: Add function "add" for adding strings/data to word buffers without reading after the string/data Fix comment for UtilBufferWriter ndb/src/common/util/SimpleProperties.cpp: Add function "add" for adding strings/data to word buffers without reading after the string/data ndb/src/ndbapi/DictCache.cpp: Add DBUG printouts to all functions in GlobalDictCache Change ndbout_c to DBUG_PRINT Add function GlobalDictCache::printCache ndb/src/ndbapi/DictCache.hpp: Add function GlobalDictCache::printCache ndb/src/ndbapi/Ndb.cpp: Change DEBUG_TRACE to DBUG_PRINT, DBUG_ENTER Use new function internalize_table_name, and create internal tabname on stack ndb/src/ndbapi/NdbDictionary.cpp: Add DBUG_ENTER calls ndb/src/ndbapi/NdbDictionaryImpl.cpp: Pass BaseString as reference when passing internal table name to internal functions. Remove check for exceeding MAX_SECTION_SIZE. Remove pekkas fix that saves internalName in save_me variable, not needed when tablename is stack variable. NdbDictInterface::gettable(int tableid, ...) - Not used ndb/src/ndbapi/NdbDictionaryImpl.hpp: Remove include of ndb_limits.h Use BaseString& for internal functions Remove m_namebuf, not needed, uses m_buffer Formatting NdbDictInterface::getTable(int tableId, ...) - Not used ndb/src/ndbapi/NdbImpl.hpp: Remove buffer for m_internalname, placed on stack of caller. Moved impl of internalize_table_name and internalize_index_anme to Ndb::internalize_table_name and Ndb::internalize_index_name ndb/src/ndbapi/NdbLinHash.hpp: Save also the terminating null character in chain->str to get nicer printouts. ndb/src/ndbapi/NdbTransaction.cpp: Remove hardcoded buffer sizes. Remove include of ndb_limits.h sql/ha_ndbcluster.cc: Fix "typo", use file_name var since that is the current files name,
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
#ifndef ATTRIBUTE_LIST_HPP
|
#ifndef ATTRIBUTE_LIST_HPP
|
||||||
#define ATTRIBUTE_LIST_HPP
|
#define ATTRIBUTE_LIST_HPP
|
||||||
|
|
||||||
|
#include "ndb_limits.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Masks and lists used by index and trigger. Must be plain old Uint32 data.
|
* Masks and lists used by index and trigger. Must be plain old Uint32 data.
|
||||||
* XXX depends on other headers XXX move to some common file
|
* XXX depends on other headers XXX move to some common file
|
||||||
|
@@ -1583,15 +1583,17 @@ private:
|
|||||||
void abortTransactionsAfterNodeFailure(Uint16 aNodeId);
|
void abortTransactionsAfterNodeFailure(Uint16 aNodeId);
|
||||||
|
|
||||||
static
|
static
|
||||||
const char * externalizeTableName(const char * internalTableName, bool fullyQualifiedNames);
|
const char * externalizeTableName(const char * internalTableName,
|
||||||
|
bool fullyQualifiedNames);
|
||||||
const char * externalizeTableName(const char * internalTableName);
|
const char * externalizeTableName(const char * internalTableName);
|
||||||
const char * internalizeTableName(const char * externalTableName);
|
const BaseString internalize_table_name(const char * external_name) const;
|
||||||
|
|
||||||
static
|
static
|
||||||
const char * externalizeIndexName(const char * internalIndexName, bool fullyQualifiedNames);
|
const char * externalizeIndexName(const char * internalIndexName,
|
||||||
|
bool fullyQualifiedNames);
|
||||||
const char * externalizeIndexName(const char * internalIndexName);
|
const char * externalizeIndexName(const char * internalIndexName);
|
||||||
const char * internalizeIndexName(const NdbTableImpl * table,
|
const BaseString internalize_index_name(const NdbTableImpl * table,
|
||||||
const char * externalIndexName);
|
const char * external_name) const;
|
||||||
|
|
||||||
static
|
static
|
||||||
const BaseString getDatabaseFromInternalName(const char * internalName);
|
const BaseString getDatabaseFromInternalName(const char * internalName);
|
||||||
|
@@ -172,6 +172,8 @@ public:
|
|||||||
virtual bool reset() = 0;
|
virtual bool reset() = 0;
|
||||||
virtual bool putWord(Uint32 val) = 0;
|
virtual bool putWord(Uint32 val) = 0;
|
||||||
virtual bool putWords(const Uint32 * src, Uint32 len) = 0;
|
virtual bool putWords(const Uint32 * src, Uint32 len) = 0;
|
||||||
|
private:
|
||||||
|
bool add(const char* value, int len);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -211,7 +213,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writer for linear memory
|
* Writer for UtilBuffer
|
||||||
*/
|
*/
|
||||||
class UtilBufferWriter : public SimpleProperties::Writer {
|
class UtilBufferWriter : public SimpleProperties::Writer {
|
||||||
public:
|
public:
|
||||||
|
@@ -36,6 +36,28 @@ SimpleProperties::Writer::add(Uint16 key, Uint32 value){
|
|||||||
return putWord(htonl(value));
|
return putWord(htonl(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SimpleProperties::Writer::add(const char * value, int len){
|
||||||
|
const Uint32 valLen = (len + 3) / 4;
|
||||||
|
|
||||||
|
if ((len % 4) == 0)
|
||||||
|
return putWords((Uint32*)value, valLen);
|
||||||
|
|
||||||
|
const Uint32 putLen= valLen - 1;
|
||||||
|
if (!putWords((Uint32*)value, putLen))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Special handling of last bytes
|
||||||
|
union {
|
||||||
|
Uint32 lastWord;
|
||||||
|
char lastBytes[4];
|
||||||
|
};
|
||||||
|
memcpy(lastBytes,
|
||||||
|
value + putLen*4,
|
||||||
|
len - putLen*4);
|
||||||
|
return putWord(lastWord);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SimpleProperties::Writer::add(Uint16 key, const char * value){
|
SimpleProperties::Writer::add(Uint16 key, const char * value){
|
||||||
Uint32 head = StringValue;
|
Uint32 head = StringValue;
|
||||||
@@ -47,8 +69,8 @@ SimpleProperties::Writer::add(Uint16 key, const char * value){
|
|||||||
if(!putWord(htonl(strLen)))
|
if(!putWord(htonl(strLen)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Uint32 valLen = (strLen + 3) / 4;
|
return add(value, (int)strLen);
|
||||||
return putWords((Uint32*)value, valLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -61,8 +83,7 @@ SimpleProperties::Writer::add(Uint16 key, const void* value, int len){
|
|||||||
if(!putWord(htonl(len)))
|
if(!putWord(htonl(len)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Uint32 valLen = (len + 3) / 4;
|
return add((const char*)value, len);
|
||||||
return putWords((Uint32*)value, valLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleProperties::Reader::Reader(){
|
SimpleProperties::Reader::Reader(){
|
||||||
@@ -392,6 +413,7 @@ UtilBufferWriter::putWords(const Uint32 * src, Uint32 len){
|
|||||||
return (m_buf.append(src, 4 * len) == 0);
|
return (m_buf.append(src, 4 * len) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Uint32
|
Uint32
|
||||||
UtilBufferWriter::getWordsUsed() const { return m_buf.length() / 4;}
|
UtilBufferWriter::getWordsUsed() const { return m_buf.length() / 4;}
|
||||||
|
|
||||||
|
@@ -79,11 +79,14 @@ LocalDictCache::drop(const char * name){
|
|||||||
* Global cache
|
* Global cache
|
||||||
*/
|
*/
|
||||||
GlobalDictCache::GlobalDictCache(){
|
GlobalDictCache::GlobalDictCache(){
|
||||||
|
DBUG_ENTER("GlobalDictCache::GlobalDictCache");
|
||||||
m_tableHash.createHashTable();
|
m_tableHash.createHashTable();
|
||||||
m_waitForTableCondition = NdbCondition_Create();
|
m_waitForTableCondition = NdbCondition_Create();
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalDictCache::~GlobalDictCache(){
|
GlobalDictCache::~GlobalDictCache(){
|
||||||
|
DBUG_ENTER("GlobalDictCache::~GlobalDictCache");
|
||||||
NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
|
NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
|
||||||
while(curr != 0){
|
while(curr != 0){
|
||||||
Vector<TableVersion> * vers = curr->theData;
|
Vector<TableVersion> * vers = curr->theData;
|
||||||
@@ -93,18 +96,50 @@ GlobalDictCache::~GlobalDictCache(){
|
|||||||
delete (* vers)[i].m_impl;
|
delete (* vers)[i].m_impl;
|
||||||
}
|
}
|
||||||
delete curr->theData;
|
delete curr->theData;
|
||||||
|
curr->theData= NULL;
|
||||||
curr = m_tableHash.getNext(curr);
|
curr = m_tableHash.getNext(curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tableHash.releaseHashTable();
|
m_tableHash.releaseHashTable();
|
||||||
NdbCondition_Destroy(m_waitForTableCondition);
|
NdbCondition_Destroy(m_waitForTableCondition);
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <NdbOut.hpp>
|
void GlobalDictCache::printCache()
|
||||||
|
{
|
||||||
|
DBUG_ENTER("GlobalDictCache::printCache");
|
||||||
|
NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
|
||||||
|
while(curr != 0){
|
||||||
|
DBUG_PRINT("curr", ("len: %d, hash: %d, lk: %d, str: %s",
|
||||||
|
curr->len, curr->hash, curr->localkey1, curr->str));
|
||||||
|
if (curr->theData){
|
||||||
|
Vector<TableVersion> * vers = curr->theData;
|
||||||
|
const unsigned sz = vers->size();
|
||||||
|
for(unsigned i = 0; i<sz ; i++){
|
||||||
|
TableVersion tv= (*vers)[i];
|
||||||
|
DBUG_PRINT(" ", ("vers[%d]: ver: %d, refCount: %d, status: %d",
|
||||||
|
sz, tv.m_version, tv.m_refCount, tv.m_status));
|
||||||
|
if(tv.m_impl != 0)
|
||||||
|
{
|
||||||
|
DBUG_PRINT(" ", ("m_impl: internalname: %s",
|
||||||
|
tv.m_impl->m_internalName.c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBUG_PRINT(" ", ("NULL"));
|
||||||
|
}
|
||||||
|
curr = m_tableHash.getNext(curr);
|
||||||
|
}
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
NdbTableImpl *
|
NdbTableImpl *
|
||||||
GlobalDictCache::get(const char * name)
|
GlobalDictCache::get(const char * name)
|
||||||
{
|
{
|
||||||
|
DBUG_ENTER("GlobalDictCache::get");
|
||||||
|
DBUG_PRINT("enter", ("name: %s", name));
|
||||||
|
|
||||||
const Uint32 len = strlen(name);
|
const Uint32 len = strlen(name);
|
||||||
Vector<TableVersion> * versions = 0;
|
Vector<TableVersion> * versions = 0;
|
||||||
versions = m_tableHash.getData(name, len);
|
versions = m_tableHash.getData(name, len);
|
||||||
@@ -121,7 +156,7 @@ GlobalDictCache::get(const char * name)
|
|||||||
switch(ver->m_status){
|
switch(ver->m_status){
|
||||||
case OK:
|
case OK:
|
||||||
ver->m_refCount++;
|
ver->m_refCount++;
|
||||||
return ver->m_impl;
|
DBUG_RETURN(ver->m_impl);
|
||||||
case DROPPED:
|
case DROPPED:
|
||||||
retreive = true; // Break loop
|
retreive = true; // Break loop
|
||||||
break;
|
break;
|
||||||
@@ -140,24 +175,28 @@ GlobalDictCache::get(const char * name)
|
|||||||
tmp.m_status = RETREIVING;
|
tmp.m_status = RETREIVING;
|
||||||
tmp.m_refCount = 1; // The one retreiving it
|
tmp.m_refCount = 1; // The one retreiving it
|
||||||
versions->push_back(tmp);
|
versions->push_back(tmp);
|
||||||
return 0;
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
NdbTableImpl *
|
NdbTableImpl *
|
||||||
GlobalDictCache::put(const char * name, NdbTableImpl * tab)
|
GlobalDictCache::put(const char * name, NdbTableImpl * tab)
|
||||||
{
|
{
|
||||||
|
DBUG_ENTER("GlobalDictCache::put");
|
||||||
|
DBUG_PRINT("enter", ("name: %s, internal_name: %s",
|
||||||
|
name, tab ? tab->m_internalName.c_str() : "tab NULL"));
|
||||||
|
|
||||||
const Uint32 len = strlen(name);
|
const Uint32 len = strlen(name);
|
||||||
Vector<TableVersion> * vers = m_tableHash.getData(name, len);
|
Vector<TableVersion> * vers = m_tableHash.getData(name, len);
|
||||||
if(vers == 0){
|
if(vers == 0){
|
||||||
// Should always tried to retreive it first
|
// Should always tried to retreive it first
|
||||||
// and then there should be a record
|
// and thus there should be a record
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Uint32 sz = vers->size();
|
const Uint32 sz = vers->size();
|
||||||
if(sz == 0){
|
if(sz == 0){
|
||||||
// Should always tried to retreive it first
|
// Should always tried to retreive it first
|
||||||
// and then there should be a record
|
// and thus there should be a record
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +209,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(tab == 0){
|
if(tab == 0){
|
||||||
// No table found in db
|
DBUG_PRINT("info", ("No table found in db"));
|
||||||
vers->erase(sz - 1);
|
vers->erase(sz - 1);
|
||||||
} else {
|
} else {
|
||||||
ver.m_impl = tab;
|
ver.m_impl = tab;
|
||||||
@@ -179,26 +218,29 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NdbCondition_Broadcast(m_waitForTableCondition);
|
NdbCondition_Broadcast(m_waitForTableCondition);
|
||||||
return tab;
|
DBUG_RETURN(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalDictCache::drop(NdbTableImpl * tab)
|
GlobalDictCache::drop(NdbTableImpl * tab)
|
||||||
{
|
{
|
||||||
|
DBUG_ENTER("GlobalDictCache::drop");
|
||||||
|
DBUG_PRINT("enter", ("internal_name: %s", tab->m_internalName.c_str()));
|
||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
const Uint32 len = strlen(tab->m_internalName.c_str());
|
const Uint32 len = strlen(tab->m_internalName.c_str());
|
||||||
Vector<TableVersion> * vers =
|
Vector<TableVersion> * vers =
|
||||||
m_tableHash.getData(tab->m_internalName.c_str(), len);
|
m_tableHash.getData(tab->m_internalName.c_str(), len);
|
||||||
if(vers == 0){
|
if(vers == 0){
|
||||||
// Should always tried to retreive it first
|
// Should always tried to retreive it first
|
||||||
// and then there should be a record
|
// and thus there should be a record
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Uint32 sz = vers->size();
|
const Uint32 sz = vers->size();
|
||||||
if(sz == 0){
|
if(sz == 0){
|
||||||
// Should always tried to retreive it first
|
// Should always tried to retreive it first
|
||||||
// and then there should be a record
|
// and thus there should be a record
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,46 +249,53 @@ GlobalDictCache::drop(NdbTableImpl * tab)
|
|||||||
if(ver.m_impl == tab){
|
if(ver.m_impl == tab){
|
||||||
if(ver.m_refCount == 0 || ver.m_status == RETREIVING ||
|
if(ver.m_refCount == 0 || ver.m_status == RETREIVING ||
|
||||||
ver.m_version != tab->m_version){
|
ver.m_version != tab->m_version){
|
||||||
ndbout_c("Dropping with refCount=%d status=%d impl=%p",
|
DBUG_PRINT("info", ("Dropping with refCount=%d status=%d impl=%p",
|
||||||
ver.m_refCount, ver.m_status, ver.m_impl);
|
ver.m_refCount, ver.m_status, ver.m_impl));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
DBUG_PRINT("info", ("Found table to drop, i: %d, name: %s",
|
||||||
|
i, ver.m_impl->m_internalName.c_str()));
|
||||||
ver.m_refCount--;
|
ver.m_refCount--;
|
||||||
ver.m_status = DROPPED;
|
ver.m_status = DROPPED;
|
||||||
if(ver.m_refCount == 0){
|
if(ver.m_refCount == 0){
|
||||||
|
DBUG_PRINT("info", ("refCount is zero, deleting m_impl"))
|
||||||
delete ver.m_impl;
|
delete ver.m_impl;
|
||||||
vers->erase(i);
|
vers->erase(i);
|
||||||
}
|
}
|
||||||
return;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i<sz; i++){
|
for(i = 0; i<sz; i++){
|
||||||
TableVersion & ver = (* vers)[i];
|
TableVersion & ver = (* vers)[i];
|
||||||
ndbout_c("%d: version: %d refCount: %d status: %d impl: %p",
|
DBUG_PRINT("info", ("%d: version: %d refCount: %d status: %d impl: %p",
|
||||||
i, ver.m_version, ver.m_refCount, ver.m_status, ver.m_impl);
|
i, ver.m_version, ver.m_refCount,
|
||||||
|
ver.m_status, ver.m_impl));
|
||||||
}
|
}
|
||||||
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalDictCache::release(NdbTableImpl * tab){
|
GlobalDictCache::release(NdbTableImpl * tab)
|
||||||
|
{
|
||||||
|
DBUG_ENTER("GlobalDictCache::release");
|
||||||
|
DBUG_PRINT("enter", ("internal_name: %s", tab->m_internalName.c_str()));
|
||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
const Uint32 len = strlen(tab->m_internalName.c_str());
|
const Uint32 len = strlen(tab->m_internalName.c_str());
|
||||||
Vector<TableVersion> * vers =
|
Vector<TableVersion> * vers =
|
||||||
m_tableHash.getData(tab->m_internalName.c_str(), len);
|
m_tableHash.getData(tab->m_internalName.c_str(), len);
|
||||||
if(vers == 0){
|
if(vers == 0){
|
||||||
// Should always tried to retreive it first
|
// Should always tried to retreive it first
|
||||||
// and then there should be a record
|
// and thus there should be a record
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Uint32 sz = vers->size();
|
const Uint32 sz = vers->size();
|
||||||
if(sz == 0){
|
if(sz == 0){
|
||||||
// Should always tried to retreive it first
|
// Should always tried to retreive it first
|
||||||
// and then there should be a record
|
// and thus there should be a record
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,20 +304,21 @@ GlobalDictCache::release(NdbTableImpl * tab){
|
|||||||
if(ver.m_impl == tab){
|
if(ver.m_impl == tab){
|
||||||
if(ver.m_refCount == 0 || ver.m_status == RETREIVING ||
|
if(ver.m_refCount == 0 || ver.m_status == RETREIVING ||
|
||||||
ver.m_version != tab->m_version){
|
ver.m_version != tab->m_version){
|
||||||
ndbout_c("Releasing with refCount=%d status=%d impl=%p",
|
DBUG_PRINT("info", ("Releasing with refCount=%d status=%d impl=%p",
|
||||||
ver.m_refCount, ver.m_status, ver.m_impl);
|
ver.m_refCount, ver.m_status, ver.m_impl));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ver.m_refCount--;
|
ver.m_refCount--;
|
||||||
return;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i<sz; i++){
|
for(i = 0; i<sz; i++){
|
||||||
TableVersion & ver = (* vers)[i];
|
TableVersion & ver = (* vers)[i];
|
||||||
ndbout_c("%d: version: %d refCount: %d status: %d impl: %p",
|
DBUG_PRINT("info", ("%d: version: %d refCount: %d status: %d impl: %p",
|
||||||
i, ver.m_version, ver.m_refCount, ver.m_status, ver.m_impl);
|
i, ver.m_version, ver.m_refCount,
|
||||||
|
ver.m_status, ver.m_impl));
|
||||||
}
|
}
|
||||||
|
|
||||||
abort();
|
abort();
|
||||||
|
@@ -76,6 +76,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void printCache();
|
||||||
|
|
||||||
struct TableVersion {
|
struct TableVersion {
|
||||||
Uint32 m_version;
|
Uint32 m_version;
|
||||||
Uint32 m_refCount;
|
Uint32 m_refCount;
|
||||||
|
@@ -750,16 +750,14 @@ Remark: Returns a new TupleId to the application.
|
|||||||
The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
|
The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
|
||||||
It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
|
It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#define DEBUG_TRACE(msg) \
|
|
||||||
// ndbout << __FILE__ << " line: " << __LINE__ << " msg: " << msg << endl
|
|
||||||
|
|
||||||
Uint64
|
Uint64
|
||||||
Ndb::getAutoIncrementValue(const char* aTableName, Uint32 cacheSize)
|
Ndb::getAutoIncrementValue(const char* aTableName, Uint32 cacheSize)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("getAutoIncrementValue");
|
DBUG_ENTER("getAutoIncrementValue");
|
||||||
const char * internalTableName = internalizeTableName(aTableName);
|
BaseString internal_tabname(internalize_table_name(aTableName));
|
||||||
|
|
||||||
Ndb_local_table_info *info=
|
Ndb_local_table_info *info=
|
||||||
theDictionary->get_local_table_info(internalTableName, false);
|
theDictionary->get_local_table_info(internal_tabname, false);
|
||||||
if (info == 0)
|
if (info == 0)
|
||||||
DBUG_RETURN(~(Uint64)0);
|
DBUG_RETURN(~(Uint64)0);
|
||||||
const NdbTableImpl *table= info->m_table_impl;
|
const NdbTableImpl *table= info->m_table_impl;
|
||||||
@@ -811,7 +809,7 @@ Ndb::getTupleIdFromNdb(Uint32 aTableId, Uint32 cacheSize)
|
|||||||
Uint64
|
Uint64
|
||||||
Ndb::readAutoIncrementValue(const char* aTableName)
|
Ndb::readAutoIncrementValue(const char* aTableName)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("readtAutoIncrementValue");
|
DBUG_ENTER("readAutoIncrementValue");
|
||||||
const NdbTableImpl* table = theDictionary->getTable(aTableName);
|
const NdbTableImpl* table = theDictionary->getTable(aTableName);
|
||||||
if (table == 0) {
|
if (table == 0) {
|
||||||
theError= theDictionary->getNdbError();
|
theError= theDictionary->getNdbError();
|
||||||
@@ -825,7 +823,7 @@ Ndb::readAutoIncrementValue(const char* aTableName)
|
|||||||
Uint64
|
Uint64
|
||||||
Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable)
|
Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("readtAutoIncrementValue");
|
DBUG_ENTER("readAutoIncrementValue");
|
||||||
if (aTable == 0)
|
if (aTable == 0)
|
||||||
DBUG_RETURN(~(Uint64)0);
|
DBUG_RETURN(~(Uint64)0);
|
||||||
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
|
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
|
||||||
@@ -847,62 +845,63 @@ Ndb::readTupleIdFromNdb(Uint32 aTableId)
|
|||||||
bool
|
bool
|
||||||
Ndb::setAutoIncrementValue(const char* aTableName, Uint64 val, bool increase)
|
Ndb::setAutoIncrementValue(const char* aTableName, Uint64 val, bool increase)
|
||||||
{
|
{
|
||||||
DEBUG_TRACE("setAutoIncrementValue " << val);
|
DBUG_ENTER("setAutoIncrementValue");
|
||||||
const char * internalTableName= internalizeTableName(aTableName);
|
BaseString internal_tabname(internalize_table_name(aTableName));
|
||||||
|
|
||||||
Ndb_local_table_info *info=
|
Ndb_local_table_info *info=
|
||||||
theDictionary->get_local_table_info(internalTableName, false);
|
theDictionary->get_local_table_info(internal_tabname, false);
|
||||||
if (info == 0) {
|
if (info == 0) {
|
||||||
theError= theDictionary->getNdbError();
|
theError= theDictionary->getNdbError();
|
||||||
return false;
|
DBUG_RETURN(false);
|
||||||
}
|
}
|
||||||
const NdbTableImpl* table= info->m_table_impl;
|
const NdbTableImpl* table= info->m_table_impl;
|
||||||
return setTupleIdInNdb(table->m_tableId, val, increase);
|
DBUG_RETURN(setTupleIdInNdb(table->m_tableId, val, increase));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 val, bool increase)
|
Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 val, bool increase)
|
||||||
{
|
{
|
||||||
DEBUG_TRACE("setAutoIncrementValue " << val);
|
DBUG_ENTER("setAutoIncrementValue");
|
||||||
if (aTable == 0)
|
if (aTable == 0)
|
||||||
return ~(Uint64)0;
|
DBUG_RETURN(~(Uint64)0);
|
||||||
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
|
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
|
||||||
return setTupleIdInNdb(table->m_tableId, val, increase);
|
DBUG_RETURN(setTupleIdInNdb(table->m_tableId, val, increase));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Ndb::setTupleIdInNdb(const char* aTableName, Uint64 val, bool increase )
|
Ndb::setTupleIdInNdb(const char* aTableName, Uint64 val, bool increase )
|
||||||
{
|
{
|
||||||
DEBUG_TRACE("setTupleIdInNdb");
|
DBUG_ENTER("setTupleIdInNdb(const char*, ...)");
|
||||||
const NdbTableImpl* table = theDictionary->getTable(aTableName);
|
const NdbTableImpl* table = theDictionary->getTable(aTableName);
|
||||||
if (table == 0) {
|
if (table == 0) {
|
||||||
theError= theDictionary->getNdbError();
|
theError= theDictionary->getNdbError();
|
||||||
return false;
|
DBUG_RETURN(false);
|
||||||
}
|
}
|
||||||
return setTupleIdInNdb(table->m_tableId, val, increase);
|
DBUG_RETURN(setTupleIdInNdb(table->m_tableId, val, increase));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Ndb::setTupleIdInNdb(Uint32 aTableId, Uint64 val, bool increase )
|
Ndb::setTupleIdInNdb(Uint32 aTableId, Uint64 val, bool increase )
|
||||||
{
|
{
|
||||||
DEBUG_TRACE("setTupleIdInNdb");
|
DBUG_ENTER("setTupleIdInNdb(Uint32, ...)");
|
||||||
if (increase)
|
if (increase)
|
||||||
{
|
{
|
||||||
if (theFirstTupleId[aTableId] != theLastTupleId[aTableId])
|
if (theFirstTupleId[aTableId] != theLastTupleId[aTableId])
|
||||||
{
|
{
|
||||||
// We have a cache sequence
|
// We have a cache sequence
|
||||||
if (val <= theFirstTupleId[aTableId]+1)
|
if (val <= theFirstTupleId[aTableId]+1)
|
||||||
return false;
|
DBUG_RETURN(false);
|
||||||
if (val <= theLastTupleId[aTableId])
|
if (val <= theLastTupleId[aTableId])
|
||||||
{
|
{
|
||||||
theFirstTupleId[aTableId] = val - 1;
|
theFirstTupleId[aTableId] = val - 1;
|
||||||
return true;
|
DBUG_RETURN(true);
|
||||||
}
|
}
|
||||||
// else continue;
|
// else continue;
|
||||||
}
|
}
|
||||||
return (opTupleIdOnNdb(aTableId, val, 2) == val);
|
DBUG_RETURN((opTupleIdOnNdb(aTableId, val, 2) == val));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return (opTupleIdOnNdb(aTableId, val, 1) == val);
|
DBUG_RETURN((opTupleIdOnNdb(aTableId, val, 1) == val));
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint64
|
Uint64
|
||||||
@@ -1142,25 +1141,63 @@ Ndb::externalizeIndexName(const char * internalIndexName)
|
|||||||
return externalizeIndexName(internalIndexName, usingFullyQualifiedNames());
|
return externalizeIndexName(internalIndexName, usingFullyQualifiedNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
|
||||||
Ndb::internalizeTableName(const char * externalTableName)
|
const BaseString
|
||||||
|
Ndb::internalize_table_name(const char *external_name) const
|
||||||
{
|
{
|
||||||
|
BaseString ret;
|
||||||
|
DBUG_ENTER("internalize_table_name");
|
||||||
|
DBUG_PRINT("enter", ("external_name: %s", external_name));
|
||||||
|
|
||||||
if (fullyQualifiedNames)
|
if (fullyQualifiedNames)
|
||||||
return theImpl->internalize_table_name(externalTableName);
|
{
|
||||||
|
/* Internal table name format <db>/<schema>/<table>
|
||||||
|
<db>/<schema> is already available in m_prefix
|
||||||
|
so just concat the two strings
|
||||||
|
*/
|
||||||
|
ret.assfmt("%s%s",
|
||||||
|
theImpl->m_prefix.c_str(),
|
||||||
|
external_name);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return externalTableName;
|
ret.assign(external_name);
|
||||||
|
|
||||||
|
DBUG_PRINT("exit", ("internal_name: %s", ret.c_str()));
|
||||||
|
DBUG_RETURN(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
|
||||||
Ndb::internalizeIndexName(const NdbTableImpl * table,
|
const BaseString
|
||||||
const char * externalIndexName)
|
Ndb::internalize_index_name(const NdbTableImpl * table,
|
||||||
|
const char * external_name) const
|
||||||
{
|
{
|
||||||
if (fullyQualifiedNames)
|
BaseString ret;
|
||||||
return theImpl->internalize_index_name(table, externalIndexName);
|
DBUG_ENTER("internalize_index_name");
|
||||||
else
|
DBUG_PRINT("enter", ("external_name: %s, table_id: %d",
|
||||||
return externalIndexName;
|
external_name, table ? table->m_tableId : ~0));
|
||||||
|
if (!table)
|
||||||
|
{
|
||||||
|
DBUG_PRINT("error", ("!table"));
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fullyQualifiedNames)
|
||||||
|
{
|
||||||
|
/* Internal index name format <db>/<schema>/<tabid>/<table> */
|
||||||
|
ret.assfmt("%s%d%c%s",
|
||||||
|
theImpl->m_prefix.c_str(),
|
||||||
|
table->m_tableId,
|
||||||
|
table_name_separator,
|
||||||
|
external_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret.assign(external_name);
|
||||||
|
|
||||||
|
DBUG_PRINT("exit", ("internal_name: %s", ret.c_str()));
|
||||||
|
DBUG_RETURN(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const BaseString
|
const BaseString
|
||||||
Ndb::getDatabaseFromInternalName(const char * internalName)
|
Ndb::getDatabaseFromInternalName(const char * internalName)
|
||||||
{
|
{
|
||||||
|
@@ -773,9 +773,11 @@ NdbDictionary::Dictionary::getTable(const char * name) const
|
|||||||
|
|
||||||
void
|
void
|
||||||
NdbDictionary::Dictionary::invalidateTable(const char * name){
|
NdbDictionary::Dictionary::invalidateTable(const char * name){
|
||||||
|
DBUG_ENTER("NdbDictionaryImpl::invalidateTable");
|
||||||
NdbTableImpl * t = m_impl.getTable(name);
|
NdbTableImpl * t = m_impl.getTable(name);
|
||||||
if(t)
|
if(t)
|
||||||
m_impl.invalidateObject(* t);
|
m_impl.invalidateObject(* t);
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -811,11 +813,13 @@ NdbDictionary::Dictionary::getIndex(const char * indexName,
|
|||||||
void
|
void
|
||||||
NdbDictionary::Dictionary::invalidateIndex(const char * indexName,
|
NdbDictionary::Dictionary::invalidateIndex(const char * indexName,
|
||||||
const char * tableName){
|
const char * tableName){
|
||||||
|
DBUG_ENTER("NdbDictionaryImpl::invalidateIndex");
|
||||||
NdbIndexImpl * i = m_impl.getIndex(indexName, tableName);
|
NdbIndexImpl * i = m_impl.getIndex(indexName, tableName);
|
||||||
if(i) {
|
if(i) {
|
||||||
assert(i->m_table != 0);
|
assert(i->m_table != 0);
|
||||||
m_impl.invalidateObject(* i->m_table);
|
m_impl.invalidateObject(* i->m_table);
|
||||||
}
|
}
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -735,19 +735,19 @@ NdbDictionaryImpl::~NdbDictionaryImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ndb_local_table_info *
|
Ndb_local_table_info *
|
||||||
NdbDictionaryImpl::fetchGlobalTableImpl(const char * internalTableName)
|
NdbDictionaryImpl::fetchGlobalTableImpl(const BaseString& internalTableName)
|
||||||
{
|
{
|
||||||
NdbTableImpl *impl;
|
NdbTableImpl *impl;
|
||||||
|
|
||||||
m_globalHash->lock();
|
m_globalHash->lock();
|
||||||
impl = m_globalHash->get(internalTableName);
|
impl = m_globalHash->get(internalTableName.c_str());
|
||||||
m_globalHash->unlock();
|
m_globalHash->unlock();
|
||||||
|
|
||||||
if (impl == 0){
|
if (impl == 0){
|
||||||
impl = m_receiver.getTable(internalTableName,
|
impl = m_receiver.getTable(internalTableName,
|
||||||
m_ndb.usingFullyQualifiedNames());
|
m_ndb.usingFullyQualifiedNames());
|
||||||
m_globalHash->lock();
|
m_globalHash->lock();
|
||||||
m_globalHash->put(internalTableName, impl);
|
m_globalHash->put(internalTableName.c_str(), impl);
|
||||||
m_globalHash->unlock();
|
m_globalHash->unlock();
|
||||||
|
|
||||||
if(impl == 0){
|
if(impl == 0){
|
||||||
@@ -758,7 +758,7 @@ NdbDictionaryImpl::fetchGlobalTableImpl(const char * internalTableName)
|
|||||||
Ndb_local_table_info *info=
|
Ndb_local_table_info *info=
|
||||||
Ndb_local_table_info::create(impl, m_local_table_data_size);
|
Ndb_local_table_info::create(impl, m_local_table_data_size);
|
||||||
|
|
||||||
m_localHash.put(internalTableName, info);
|
m_localHash.put(internalTableName.c_str(), info);
|
||||||
|
|
||||||
m_ndb.theFirstTupleId[impl->getTableId()] = ~0;
|
m_ndb.theFirstTupleId[impl->getTableId()] = ~0;
|
||||||
m_ndb.theLastTupleId[impl->getTableId()] = ~0;
|
m_ndb.theLastTupleId[impl->getTableId()] = ~0;
|
||||||
@@ -810,10 +810,9 @@ NdbTableImpl *
|
|||||||
NdbDictionaryImpl::getIndexTable(NdbIndexImpl * index,
|
NdbDictionaryImpl::getIndexTable(NdbIndexImpl * index,
|
||||||
NdbTableImpl * table)
|
NdbTableImpl * table)
|
||||||
{
|
{
|
||||||
const char * internalName =
|
const BaseString internalName(
|
||||||
m_ndb.internalizeIndexName(table, index->getName());
|
m_ndb.internalize_index_name(table, index->getName()));
|
||||||
|
return getTable(m_ndb.externalizeTableName(internalName.c_str()));
|
||||||
return getTable(m_ndb.externalizeTableName(internalName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1055,7 +1054,7 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal,
|
|||||||
}
|
}
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
Get dictionary information for a table using table id as reference
|
Get dictionary information for a table using table id as reference
|
||||||
|
|
||||||
@@ -1079,6 +1078,7 @@ NdbDictInterface::getTable(int tableId, bool fullyQualifiedNames)
|
|||||||
|
|
||||||
return getTable(&tSignal, 0, 0, fullyQualifiedNames);
|
return getTable(&tSignal, 0, 0, fullyQualifiedNames);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1090,36 +1090,31 @@ NdbDictInterface::getTable(int tableId, bool fullyQualifiedNames)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
NdbTableImpl *
|
NdbTableImpl *
|
||||||
NdbDictInterface::getTable(const char * name, bool fullyQualifiedNames)
|
NdbDictInterface::getTable(const BaseString& name, bool fullyQualifiedNames)
|
||||||
{
|
{
|
||||||
NdbApiSignal tSignal(m_reference);
|
NdbApiSignal tSignal(m_reference);
|
||||||
GetTabInfoReq* const req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend());
|
GetTabInfoReq* const req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend());
|
||||||
|
|
||||||
const Uint32 str_len= strlen(name) + 1; // NULL terminated
|
const Uint32 namelen= name.length() + 1; // NULL terminated
|
||||||
const Uint32 str_len_words= (str_len + 3) / 4; // Size in words
|
const Uint32 namelen_words= (namelen + 3) >> 2; // Size in words
|
||||||
|
|
||||||
if (str_len > MAX_SECTION_SIZE)
|
|
||||||
{
|
|
||||||
m_error.code= 4307;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_namebuf.clear();
|
|
||||||
m_namebuf.grow(str_len_words*4); // Word size aligned number of bytes
|
|
||||||
m_namebuf.append(name, str_len);
|
|
||||||
|
|
||||||
req->senderRef= m_reference;
|
req->senderRef= m_reference;
|
||||||
req->senderData= 0;
|
req->senderData= 0;
|
||||||
req->requestType=
|
req->requestType=
|
||||||
GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf;
|
GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf;
|
||||||
req->tableNameLen= str_len;
|
req->tableNameLen= namelen;
|
||||||
tSignal.theReceiversBlockNumber= DBDICT;
|
tSignal.theReceiversBlockNumber= DBDICT;
|
||||||
tSignal.theVerId_signalNumber= GSN_GET_TABINFOREQ;
|
tSignal.theVerId_signalNumber= GSN_GET_TABINFOREQ;
|
||||||
tSignal.theLength= GetTabInfoReq::SignalLength;
|
tSignal.theLength= GetTabInfoReq::SignalLength;
|
||||||
|
|
||||||
|
// Copy name to m_buffer to get a word sized buffer
|
||||||
|
m_buffer.clear();
|
||||||
|
m_buffer.grow(namelen_words*4);
|
||||||
|
m_buffer.append(name.c_str(), namelen);
|
||||||
|
|
||||||
LinearSectionPtr ptr[1];
|
LinearSectionPtr ptr[1];
|
||||||
ptr[0].p= (Uint32*)m_namebuf.get_data();
|
ptr[0].p= (Uint32*)m_buffer.get_data();
|
||||||
ptr[0].sz= str_len_words;
|
ptr[0].sz= namelen_words;
|
||||||
|
|
||||||
return getTable(&tSignal, ptr, 1, fullyQualifiedNames);
|
return getTable(&tSignal, ptr, 1, fullyQualifiedNames);
|
||||||
}
|
}
|
||||||
@@ -1463,7 +1458,7 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t)
|
|||||||
return 0;
|
return 0;
|
||||||
// update table def from DICT
|
// update table def from DICT
|
||||||
Ndb_local_table_info *info=
|
Ndb_local_table_info *info=
|
||||||
get_local_table_info(t.m_internalName.c_str(),false);
|
get_local_table_info(t.m_internalName,false);
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
m_error.code= 709;
|
m_error.code= 709;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1490,7 +1485,7 @@ NdbDictionaryImpl::createBlobTables(NdbTableImpl &t)
|
|||||||
return -1;
|
return -1;
|
||||||
// Save BLOB table handle
|
// Save BLOB table handle
|
||||||
Ndb_local_table_info *info=
|
Ndb_local_table_info *info=
|
||||||
get_local_table_info(bt.m_internalName.c_str(), false);
|
get_local_table_info(bt.m_internalName, false);
|
||||||
if (info == 0) {
|
if (info == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1534,12 +1529,11 @@ NdbDictInterface::createTable(Ndb & ndb,
|
|||||||
|
|
||||||
int NdbDictionaryImpl::alterTable(NdbTableImpl &impl)
|
int NdbDictionaryImpl::alterTable(NdbTableImpl &impl)
|
||||||
{
|
{
|
||||||
BaseString internalName = impl.m_internalName;
|
BaseString internalName(impl.m_internalName);
|
||||||
const char * originalInternalName = internalName.c_str();
|
const char * originalInternalName = internalName.c_str();
|
||||||
BaseString externalName = impl.m_externalName;
|
|
||||||
|
|
||||||
DBUG_ENTER("NdbDictionaryImpl::alterTable");
|
DBUG_ENTER("NdbDictionaryImpl::alterTable");
|
||||||
if(!get_local_table_info(originalInternalName, false)){
|
if(!get_local_table_info(internalName, false)){
|
||||||
m_error.code= 709;
|
m_error.code= 709;
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
}
|
}
|
||||||
@@ -1594,14 +1588,14 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
|
|||||||
//validate();
|
//validate();
|
||||||
//aggregate();
|
//aggregate();
|
||||||
|
|
||||||
const char * internalName =
|
const BaseString internalName(
|
||||||
ndb.internalizeTableName(impl.m_externalName.c_str());
|
ndb.internalize_table_name(impl.m_externalName.c_str()));
|
||||||
impl.m_internalName.assign(internalName);
|
impl.m_internalName.assign(internalName);
|
||||||
UtilBufferWriter w(m_buffer);
|
UtilBufferWriter w(m_buffer);
|
||||||
DictTabInfo::Table tmpTab; tmpTab.init();
|
DictTabInfo::Table tmpTab; tmpTab.init();
|
||||||
BaseString::snprintf(tmpTab.TableName,
|
BaseString::snprintf(tmpTab.TableName,
|
||||||
sizeof(tmpTab.TableName),
|
sizeof(tmpTab.TableName),
|
||||||
internalName);
|
internalName.c_str());
|
||||||
|
|
||||||
bool haveAutoIncrement = false;
|
bool haveAutoIncrement = false;
|
||||||
Uint64 autoIncrementValue = 0;
|
Uint64 autoIncrementValue = 0;
|
||||||
@@ -1859,10 +1853,10 @@ NdbDictionaryImpl::dropTable(const char * name)
|
|||||||
// If table stored in cache is incompatible with the one in the kernel
|
// If table stored in cache is incompatible with the one in the kernel
|
||||||
// we must clear the cache and try again
|
// we must clear the cache and try again
|
||||||
if (ret == INCOMPATIBLE_VERSION) {
|
if (ret == INCOMPATIBLE_VERSION) {
|
||||||
const char * internalTableName = m_ndb.internalizeTableName(name);
|
const BaseString internalTableName(m_ndb.internalize_table_name(name));
|
||||||
|
|
||||||
DBUG_PRINT("info",("INCOMPATIBLE_VERSION internal_name: %s", internalTableName));
|
DBUG_PRINT("info",("INCOMPATIBLE_VERSION internal_name: %s", internalTableName.c_str()));
|
||||||
m_localHash.drop(internalTableName);
|
m_localHash.drop(internalTableName.c_str());
|
||||||
m_globalHash->lock();
|
m_globalHash->lock();
|
||||||
tab->m_status = NdbDictionary::Object::Invalid;
|
tab->m_status = NdbDictionary::Object::Invalid;
|
||||||
m_globalHash->drop(tab);
|
m_globalHash->drop(tab);
|
||||||
@@ -2007,13 +2001,14 @@ int
|
|||||||
NdbDictionaryImpl::invalidateObject(NdbTableImpl & impl)
|
NdbDictionaryImpl::invalidateObject(NdbTableImpl & impl)
|
||||||
{
|
{
|
||||||
const char * internalTableName = impl.m_internalName.c_str();
|
const char * internalTableName = impl.m_internalName.c_str();
|
||||||
|
DBUG_ENTER("NdbDictionaryImpl::invalidateObject");
|
||||||
|
DBUG_PRINT("enter", ("internal_name: %s", internalTableName));
|
||||||
m_localHash.drop(internalTableName);
|
m_localHash.drop(internalTableName);
|
||||||
m_globalHash->lock();
|
m_globalHash->lock();
|
||||||
impl.m_status = NdbDictionary::Object::Invalid;
|
impl.m_status = NdbDictionary::Object::Invalid;
|
||||||
m_globalHash->drop(&impl);
|
m_globalHash->drop(&impl);
|
||||||
m_globalHash->unlock();
|
m_globalHash->unlock();
|
||||||
return 0;
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -2033,7 +2028,7 @@ NdbDictionaryImpl::removeCachedObject(NdbTableImpl & impl)
|
|||||||
*/
|
*/
|
||||||
NdbIndexImpl*
|
NdbIndexImpl*
|
||||||
NdbDictionaryImpl::getIndexImpl(const char * externalName,
|
NdbDictionaryImpl::getIndexImpl(const char * externalName,
|
||||||
const char * internalName)
|
const BaseString& internalName)
|
||||||
{
|
{
|
||||||
Ndb_local_table_info * info = get_local_table_info(internalName,
|
Ndb_local_table_info * info = get_local_table_info(internalName,
|
||||||
false);
|
false);
|
||||||
@@ -2049,21 +2044,11 @@ NdbDictionaryImpl::getIndexImpl(const char * externalName,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* internalName may be pointer to m_ndb.theImpl->m_internalname.c_str()
|
|
||||||
* and may get deallocated in next call.
|
|
||||||
*
|
|
||||||
* Passing around pointers to volatile internal members may not be
|
|
||||||
* optimal. Suggest use BaseString instances passed by value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
BaseString save_me(internalName);
|
|
||||||
NdbTableImpl* prim = getTable(tab->m_primaryTable.c_str());
|
NdbTableImpl* prim = getTable(tab->m_primaryTable.c_str());
|
||||||
if(prim == 0){
|
if(prim == 0){
|
||||||
m_error.code = 4243;
|
m_error.code = 4243;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
internalName = save_me.c_str();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create index impl
|
* Create index impl
|
||||||
@@ -2169,12 +2154,11 @@ NdbDictInterface::createIndex(Ndb & ndb,
|
|||||||
m_error.code = 4241;
|
m_error.code = 4241;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const char * internalName =
|
const BaseString internalName(
|
||||||
ndb.internalizeIndexName(&table, impl.getName());
|
ndb.internalize_index_name(&table, impl.getName()));
|
||||||
|
|
||||||
impl.m_internalName.assign(internalName);
|
impl.m_internalName.assign(internalName);
|
||||||
|
|
||||||
w.add(DictTabInfo::TableName, internalName);
|
w.add(DictTabInfo::TableName, internalName.c_str());
|
||||||
w.add(DictTabInfo::TableLoggedFlag, impl.m_logging);
|
w.add(DictTabInfo::TableLoggedFlag, impl.m_logging);
|
||||||
|
|
||||||
NdbApiSignal tSignal(m_reference);
|
NdbApiSignal tSignal(m_reference);
|
||||||
@@ -2280,13 +2264,13 @@ NdbDictionaryImpl::dropIndex(const char * indexName,
|
|||||||
// If index stored in cache is incompatible with the one in the kernel
|
// If index stored in cache is incompatible with the one in the kernel
|
||||||
// we must clear the cache and try again
|
// we must clear the cache and try again
|
||||||
if (ret == INCOMPATIBLE_VERSION) {
|
if (ret == INCOMPATIBLE_VERSION) {
|
||||||
const char * internalIndexName = (tableName)
|
const BaseString internalIndexName((tableName)
|
||||||
?
|
?
|
||||||
m_ndb.internalizeIndexName(getTable(tableName), indexName)
|
m_ndb.internalize_index_name(getTable(tableName), indexName)
|
||||||
:
|
:
|
||||||
m_ndb.internalizeTableName(indexName); // Index is also a table
|
m_ndb.internalize_table_name(indexName)); // Index is also a table
|
||||||
|
|
||||||
m_localHash.drop(internalIndexName);
|
m_localHash.drop(internalIndexName.c_str());
|
||||||
m_globalHash->lock();
|
m_globalHash->lock();
|
||||||
idx->m_table->m_status = NdbDictionary::Object::Invalid;
|
idx->m_table->m_status = NdbDictionary::Object::Invalid;
|
||||||
m_globalHash->drop(idx->m_table);
|
m_globalHash->drop(idx->m_table);
|
||||||
@@ -2309,11 +2293,11 @@ NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl, const char * tableName)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * internalIndexName = (tableName)
|
const BaseString internalIndexName((tableName)
|
||||||
?
|
?
|
||||||
m_ndb.internalizeIndexName(getTable(tableName), indexName)
|
m_ndb.internalize_index_name(getTable(tableName), indexName)
|
||||||
:
|
:
|
||||||
m_ndb.internalizeTableName(indexName); // Index is also a table
|
m_ndb.internalize_table_name(indexName)); // Index is also a table
|
||||||
|
|
||||||
if(impl.m_status == NdbDictionary::Object::New){
|
if(impl.m_status == NdbDictionary::Object::New){
|
||||||
return dropIndex(indexName, tableName);
|
return dropIndex(indexName, tableName);
|
||||||
@@ -2321,7 +2305,7 @@ NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl, const char * tableName)
|
|||||||
|
|
||||||
int ret = m_receiver.dropIndex(impl, *timpl);
|
int ret = m_receiver.dropIndex(impl, *timpl);
|
||||||
if(ret == 0){
|
if(ret == 0){
|
||||||
m_localHash.drop(internalIndexName);
|
m_localHash.drop(internalIndexName.c_str());
|
||||||
m_globalHash->lock();
|
m_globalHash->lock();
|
||||||
impl.m_table->m_status = NdbDictionary::Object::Invalid;
|
impl.m_table->m_status = NdbDictionary::Object::Invalid;
|
||||||
m_globalHash->drop(impl.m_table);
|
m_globalHash->drop(impl.m_table);
|
||||||
@@ -2526,8 +2510,12 @@ NdbDictInterface::createEvent(class Ndb & ndb,
|
|||||||
w.add(SimpleProperties::StringValue, evnt.m_externalName.c_str());
|
w.add(SimpleProperties::StringValue, evnt.m_externalName.c_str());
|
||||||
|
|
||||||
if (getFlag == 0)
|
if (getFlag == 0)
|
||||||
|
{
|
||||||
|
const BaseString internal_tabname(
|
||||||
|
ndb.internalize_table_name(evnt.m_tableName.c_str()));
|
||||||
w.add(SimpleProperties::StringValue,
|
w.add(SimpleProperties::StringValue,
|
||||||
ndb.internalizeTableName(evnt.m_tableName.c_str()));
|
internal_tabname.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
LinearSectionPtr ptr[1];
|
LinearSectionPtr ptr[1];
|
||||||
ptr[0].p = (Uint32*)m_buffer.get_data();
|
ptr[0].p = (Uint32*)m_buffer.get_data();
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include <ndb_types.h>
|
#include <ndb_types.h>
|
||||||
#include <kernel_types.h>
|
#include <kernel_types.h>
|
||||||
#include <ndb_limits.h>
|
|
||||||
#include <NdbError.hpp>
|
#include <NdbError.hpp>
|
||||||
#include <BaseString.hpp>
|
#include <BaseString.hpp>
|
||||||
#include <Vector.hpp>
|
#include <Vector.hpp>
|
||||||
@@ -309,8 +308,8 @@ public:
|
|||||||
int listObjects(NdbDictionary::Dictionary::List& list, Uint32 requestData, bool fullyQualifiedNames);
|
int listObjects(NdbDictionary::Dictionary::List& list, Uint32 requestData, bool fullyQualifiedNames);
|
||||||
int listObjects(NdbApiSignal* signal);
|
int listObjects(NdbApiSignal* signal);
|
||||||
|
|
||||||
NdbTableImpl * getTable(int tableId, bool fullyQualifiedNames);
|
/* NdbTableImpl * getTable(int tableId, bool fullyQualifiedNames); */
|
||||||
NdbTableImpl * getTable(const char * name, bool fullyQualifiedNames);
|
NdbTableImpl * getTable(const BaseString& name, bool fullyQualifiedNames);
|
||||||
NdbTableImpl * getTable(class NdbApiSignal * signal,
|
NdbTableImpl * getTable(class NdbApiSignal * signal,
|
||||||
LinearSectionPtr ptr[3],
|
LinearSectionPtr ptr[3],
|
||||||
Uint32 noOfSections, bool fullyQualifiedNames);
|
Uint32 noOfSections, bool fullyQualifiedNames);
|
||||||
@@ -368,8 +367,6 @@ private:
|
|||||||
|
|
||||||
Uint32 m_fragmentId;
|
Uint32 m_fragmentId;
|
||||||
UtilBuffer m_buffer;
|
UtilBuffer m_buffer;
|
||||||
// Buffer used when requesting a table by name
|
|
||||||
UtilBuffer m_namebuf;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class NdbDictionaryImpl : public NdbDictionary::Dictionary {
|
class NdbDictionaryImpl : public NdbDictionary::Dictionary {
|
||||||
@@ -408,11 +405,10 @@ public:
|
|||||||
int listIndexes(List& list, Uint32 indexId);
|
int listIndexes(List& list, Uint32 indexId);
|
||||||
|
|
||||||
NdbTableImpl * getTable(const char * tableName, void **data= 0);
|
NdbTableImpl * getTable(const char * tableName, void **data= 0);
|
||||||
Ndb_local_table_info * get_local_table_info(const char * internalName,
|
Ndb_local_table_info* get_local_table_info(
|
||||||
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);
|
||||||
NdbIndexImpl * getIndexImpl(const char * name, const char * internalName);
|
|
||||||
NdbEventImpl * getEvent(const char * eventName);
|
NdbEventImpl * getEvent(const char * eventName);
|
||||||
NdbEventImpl * getEventImpl(const char * internalName);
|
NdbEventImpl * getEventImpl(const char * internalName);
|
||||||
|
|
||||||
@@ -430,7 +426,9 @@ public:
|
|||||||
NdbDictInterface m_receiver;
|
NdbDictInterface m_receiver;
|
||||||
Ndb & m_ndb;
|
Ndb & m_ndb;
|
||||||
private:
|
private:
|
||||||
Ndb_local_table_info * fetchGlobalTableImpl(const char * internalName);
|
NdbIndexImpl * getIndexImpl(const char * name,
|
||||||
|
const BaseString& internalName);
|
||||||
|
Ndb_local_table_info * fetchGlobalTableImpl(const BaseString& internalName);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@@ -639,25 +637,26 @@ NdbDictionaryImpl::getImpl(const NdbDictionary::Dictionary & t){
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
NdbTableImpl *
|
NdbTableImpl *
|
||||||
NdbDictionaryImpl::getTable(const char * tableName, void **data)
|
NdbDictionaryImpl::getTable(const char * table_name, void **data)
|
||||||
{
|
{
|
||||||
|
const BaseString internal_tabname(m_ndb.internalize_table_name(table_name));
|
||||||
Ndb_local_table_info *info=
|
Ndb_local_table_info *info=
|
||||||
get_local_table_info(m_ndb.internalizeTableName(tableName), true);
|
get_local_table_info(internal_tabname, true);
|
||||||
if (info == 0) {
|
if (info == 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
if (data) {
|
if (data)
|
||||||
*data= info->m_local_data;
|
*data= info->m_local_data;
|
||||||
}
|
|
||||||
return info->m_table_impl;
|
return info->m_table_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
Ndb_local_table_info *
|
Ndb_local_table_info *
|
||||||
NdbDictionaryImpl::get_local_table_info(const char * internalTableName,
|
NdbDictionaryImpl::get_local_table_info(const BaseString& internalTableName,
|
||||||
bool do_add_blob_tables)
|
bool do_add_blob_tables)
|
||||||
{
|
{
|
||||||
Ndb_local_table_info *info= m_localHash.get(internalTableName);
|
Ndb_local_table_info *info= m_localHash.get(internalTableName.c_str());
|
||||||
if (info == 0) {
|
if (info == 0) {
|
||||||
info= fetchGlobalTableImpl(internalTableName);
|
info= fetchGlobalTableImpl(internalTableName);
|
||||||
if (info == 0) {
|
if (info == 0) {
|
||||||
@@ -672,26 +671,27 @@ NdbDictionaryImpl::get_local_table_info(const char * internalTableName,
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
NdbIndexImpl *
|
NdbIndexImpl *
|
||||||
NdbDictionaryImpl::getIndex(const char * indexName,
|
NdbDictionaryImpl::getIndex(const char * index_name,
|
||||||
const char * tableName)
|
const char * table_name)
|
||||||
|
{
|
||||||
|
if (table_name || m_ndb.usingFullyQualifiedNames())
|
||||||
|
{
|
||||||
|
const BaseString internal_indexname(
|
||||||
|
(table_name)
|
||||||
|
?
|
||||||
|
m_ndb.internalize_index_name(getTable(table_name), index_name)
|
||||||
|
:
|
||||||
|
m_ndb.internalize_table_name(index_name)); // Index is also a table
|
||||||
|
|
||||||
|
if (internal_indexname.length())
|
||||||
|
{
|
||||||
|
Ndb_local_table_info * info=
|
||||||
|
get_local_table_info(internal_indexname, false);
|
||||||
|
if (info)
|
||||||
{
|
{
|
||||||
if (tableName || m_ndb.usingFullyQualifiedNames()) {
|
|
||||||
const char * internalIndexName = 0;
|
|
||||||
if (tableName) {
|
|
||||||
NdbTableImpl * t = getTable(tableName);
|
|
||||||
if (t != 0)
|
|
||||||
internalIndexName = m_ndb.internalizeIndexName(t, indexName);
|
|
||||||
} else {
|
|
||||||
internalIndexName =
|
|
||||||
m_ndb.internalizeTableName(indexName); // Index is also a table
|
|
||||||
}
|
|
||||||
if (internalIndexName) {
|
|
||||||
Ndb_local_table_info * info = get_local_table_info(internalIndexName,
|
|
||||||
false);
|
|
||||||
if (info) {
|
|
||||||
NdbTableImpl * tab= info->m_table_impl;
|
NdbTableImpl * tab= info->m_table_impl;
|
||||||
if (tab->m_index == 0)
|
if (tab->m_index == 0)
|
||||||
tab->m_index = getIndexImpl(indexName, internalIndexName);
|
tab->m_index= getIndexImpl(index_name, internal_indexname);
|
||||||
if (tab->m_index != 0)
|
if (tab->m_index != 0)
|
||||||
tab->m_index->m_table= tab;
|
tab->m_index->m_table= tab;
|
||||||
return tab->m_index;
|
return tab->m_index;
|
||||||
|
@@ -65,7 +65,6 @@ public:
|
|||||||
BaseString m_schemaname; // Schema name
|
BaseString m_schemaname; // Schema name
|
||||||
|
|
||||||
BaseString m_prefix; // Buffer for preformatted internal name <db>/<schema>/
|
BaseString m_prefix; // Buffer for preformatted internal name <db>/<schema>/
|
||||||
BaseString m_internalname;
|
|
||||||
|
|
||||||
void update_prefix()
|
void update_prefix()
|
||||||
{
|
{
|
||||||
@@ -73,23 +72,6 @@ public:
|
|||||||
m_schemaname.c_str(), table_name_separator);
|
m_schemaname.c_str(), table_name_separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* internalize_table_name(const char* ext_name)
|
|
||||||
{
|
|
||||||
// Internal table name format <db>/<schema>/<table>
|
|
||||||
return m_internalname.assign(m_prefix).append(ext_name).c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* internalize_index_name(const NdbTableImpl *table,
|
|
||||||
const char* ext_name)
|
|
||||||
{
|
|
||||||
// Internal index name format <db>/<schema>/<tabid>/<table>
|
|
||||||
return m_internalname.assign(m_prefix).appfmt("%d%c%s",
|
|
||||||
table->m_tableId,
|
|
||||||
table_name_separator,
|
|
||||||
ext_name).c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef VM_TRACE
|
#ifdef VM_TRACE
|
||||||
|
@@ -219,6 +219,7 @@ NdbLinHash<C>::insertKey( const char* str, Uint32 len, Uint32 lkey1, C* data )
|
|||||||
chain->localkey1 = lkey1;
|
chain->localkey1 = lkey1;
|
||||||
chain->next = 0;
|
chain->next = 0;
|
||||||
chain->theData = data;
|
chain->theData = data;
|
||||||
|
len++; // Null terminated
|
||||||
chain->str = new Uint32[((len + 3) >> 2)];
|
chain->str = new Uint32[((len + 3) >> 2)];
|
||||||
memcpy( &chain->str[0], str, len);
|
memcpy( &chain->str[0], str, len);
|
||||||
if (oldChain != 0)
|
if (oldChain != 0)
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
#include "TransporterFacade.hpp"
|
#include "TransporterFacade.hpp"
|
||||||
#include "API.hpp"
|
#include "API.hpp"
|
||||||
#include "NdbBlob.hpp"
|
#include "NdbBlob.hpp"
|
||||||
#include <ndb_limits.h>
|
|
||||||
|
|
||||||
#include <signaldata/TcKeyConf.hpp>
|
#include <signaldata/TcKeyConf.hpp>
|
||||||
#include <signaldata/TcIndx.hpp>
|
#include <signaldata/TcIndx.hpp>
|
||||||
@@ -1287,10 +1286,9 @@ NdbTransaction::getNdbIndexOperation(const char* anIndexName,
|
|||||||
{
|
{
|
||||||
// This unique index is defined from SQL level
|
// This unique index is defined from SQL level
|
||||||
static const char* uniqueSuffix= "$unique";
|
static const char* uniqueSuffix= "$unique";
|
||||||
char uniqueIndexName[MAX_TAB_NAME_SIZE];
|
BaseString uniqueIndexName(anIndexName);
|
||||||
|
uniqueIndexName.append(uniqueSuffix);
|
||||||
strxnmov(uniqueIndexName, MAX_TAB_NAME_SIZE, anIndexName, uniqueSuffix, NullS);
|
index = theNdb->theDictionary->getIndex(uniqueIndexName.c_str(),
|
||||||
index = theNdb->theDictionary->getIndex(uniqueIndexName,
|
|
||||||
aTableName);
|
aTableName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -4709,7 +4709,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
|
|||||||
List_iterator_fast<char> it2(create_list);
|
List_iterator_fast<char> it2(create_list);
|
||||||
while ((file_name=it2++))
|
while ((file_name=it2++))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("Table %s need discovery", name));
|
DBUG_PRINT("info", ("Table %s need discovery", file_name));
|
||||||
if (ha_create_table_from_engine(thd, db, file_name, TRUE) == 0)
|
if (ha_create_table_from_engine(thd, db, file_name, TRUE) == 0)
|
||||||
files->push_back(thd->strdup(file_name));
|
files->push_back(thd->strdup(file_name));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user