Commit 3bd46ad8 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into neptunus.(none):/home/msvensson/mysql/bug9626

parents f87f0450 50bb2039
...@@ -85,6 +85,7 @@ void init_thr_alarm(uint max_alarms) ...@@ -85,6 +85,7 @@ void init_thr_alarm(uint max_alarms)
#else #else
{ {
struct sigaction sact; struct sigaction sact;
sact.sa_flags = 0;
bzero((char*) &sact, sizeof(sact)); bzero((char*) &sact, sizeof(sact));
sact.sa_handler = thread_alarm; sact.sa_handler = thread_alarm;
sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0); sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#ifndef NDB_LIMITS_H #ifndef NDB_LIMITS_H
#define NDB_LIMITS_H #define NDB_LIMITS_H
#include <mysql.h>
#define RNIL 0xffffff00 #define RNIL 0xffffff00
/** /**
...@@ -52,7 +54,7 @@ ...@@ -52,7 +54,7 @@
#define MAX_TUPLES_BITS 13 /* 13 bits = 8191 tuples per page */ #define MAX_TUPLES_BITS 13 /* 13 bits = 8191 tuples per page */
#define MAX_TABLES 20320 /* SchemaFile.hpp */ #define MAX_TABLES 20320 /* SchemaFile.hpp */
#define MAX_TAB_NAME_SIZE 128 #define MAX_TAB_NAME_SIZE 128
#define MAX_ATTR_NAME_SIZE 32 #define MAX_ATTR_NAME_SIZE NAME_LEN /* From mysql_com.h */
#define MAX_ATTR_DEFAULT_VALUE_SIZE 128 #define MAX_ATTR_DEFAULT_VALUE_SIZE 128
#define MAX_ATTRIBUTES_IN_TABLE 128 #define MAX_ATTRIBUTES_IN_TABLE 128
#define MAX_ATTRIBUTES_IN_INDEX 32 #define MAX_ATTRIBUTES_IN_INDEX 32
......
...@@ -39,22 +39,15 @@ class GetTabInfoReq { ...@@ -39,22 +39,15 @@ class GetTabInfoReq {
friend bool printGET_TABINFO_REQ(FILE *, const Uint32 *, Uint32, Uint16); friend bool printGET_TABINFO_REQ(FILE *, const Uint32 *, Uint32, Uint16);
public: public:
STATIC_CONST( SignalLength = 5 ); STATIC_CONST( SignalLength = 5 );
// STATIC_CONST( MaxTableNameLengthInWords = 20 );
public: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 requestType; // Bitmask of GetTabInfoReq::RequestType
/**
* 0 = request by id, 1 = request by name
*/
Uint32 requestType;
union { union {
Uint32 tableId; Uint32 tableId;
Uint32 tableNameLen; Uint32 tableNameLen;
}; };
Uint32 unused; // This is located here so that Req & Ref have the same format Uint32 unused; // This is located here so that Req & Ref have the same format
// Uint32 tableName[MaxTableNameLengthInWords];
enum RequestType { enum RequestType {
RequestById = 0, RequestById = 0,
...@@ -79,11 +72,10 @@ class GetTabInfoRef { ...@@ -79,11 +72,10 @@ class GetTabInfoRef {
friend bool printGET_TABINFO_REF(FILE *, const Uint32 *, Uint32, Uint16); friend bool printGET_TABINFO_REF(FILE *, const Uint32 *, Uint32, Uint16);
public: public:
STATIC_CONST( SignalLength = 5 ); STATIC_CONST( SignalLength = 5 );
public: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 requestType; // 0 = request by id, 1 = request by name Uint32 requestType; // Bitmask of GetTabInfoReq::RequestType
union { union {
Uint32 tableId; Uint32 tableId;
Uint32 tableNameLen; Uint32 tableNameLen;
......
...@@ -999,10 +999,6 @@ typedef void (* NdbEventCallback)(NdbEventOperation*, Ndb*, void*); ...@@ -999,10 +999,6 @@ typedef void (* NdbEventCallback)(NdbEventOperation*, Ndb*, void*);
#define WAITFOR_RESPONSE_TIMEOUT 120000 // Milliseconds #define WAITFOR_RESPONSE_TIMEOUT 120000 // Milliseconds
#endif #endif
#define NDB_MAX_INTERNAL_TABLE_LENGTH NDB_MAX_DATABASE_NAME_SIZE + \
NDB_MAX_SCHEMA_NAME_SIZE + \
NDB_MAX_TAB_NAME_SIZE*2
/** /**
* @class Ndb * @class Ndb
* @brief Represents the NDB kernel and is the main class of the NDB API. * @brief Represents the NDB kernel and is the main class of the NDB API.
...@@ -1626,12 +1622,7 @@ private: ...@@ -1626,12 +1622,7 @@ private:
bool fullyQualifiedNames; bool fullyQualifiedNames;
// Ndb database name.
char theDataBase[NDB_MAX_DATABASE_NAME_SIZE];
// Ndb database schema name.
char theDataBaseSchema[NDB_MAX_SCHEMA_NAME_SIZE];
char prefixName[NDB_MAX_INTERNAL_TABLE_LENGTH];
char * prefixEnd;
class NdbImpl * theImpl; class NdbImpl * theImpl;
class NdbDictionaryImpl* theDictionary; class NdbDictionaryImpl* theDictionary;
......
...@@ -19,10 +19,6 @@ ...@@ -19,10 +19,6 @@
#define NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY 32 #define NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY 32
#define NDB_MAX_ATTRIBUTES_IN_INDEX NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY #define NDB_MAX_ATTRIBUTES_IN_INDEX NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY
#define NDB_MAX_DATABASE_NAME_SIZE 128
#define NDB_MAX_SCHEMA_NAME_SIZE 128
#define NDB_MAX_TAB_NAME_SIZE 128
#define NDB_MAX_ATTR_NAME_SIZE 32
#define NDB_MAX_ATTRIBUTES_IN_TABLE 128 #define NDB_MAX_ATTRIBUTES_IN_TABLE 128
#define NDB_MAX_TUPLE_SIZE_IN_WORDS 2013 #define NDB_MAX_TUPLE_SIZE_IN_WORDS 2013
......
...@@ -93,6 +93,7 @@ TransporterRegistry::unpack(Uint32 * readPtr, ...@@ -93,6 +93,7 @@ TransporterRegistry::unpack(Uint32 * readPtr,
signalHeader.theSendersSignalId = * signalData; signalHeader.theSendersSignalId = * signalData;
signalData ++; signalData ++;
}//if }//if
signalHeader.theSignalId= ~0;
Uint32 * sectionPtr = signalData + signalHeader.theLength; Uint32 * sectionPtr = signalData + signalHeader.theLength;
Uint32 * sectionData = sectionPtr + signalHeader.m_noOfSections; Uint32 * sectionData = sectionPtr + signalHeader.m_noOfSections;
......
...@@ -1041,39 +1041,31 @@ convertEndian(Uint32 Data) ...@@ -1041,39 +1041,31 @@ convertEndian(Uint32 Data)
} }
const char * Ndb::getCatalogName() const const char * Ndb::getCatalogName() const
{ {
return theDataBase; return theImpl->m_dbname.c_str();
} }
void Ndb::setCatalogName(const char * a_catalog_name) void Ndb::setCatalogName(const char * a_catalog_name)
{ {
if (a_catalog_name) { if (a_catalog_name)
BaseString::snprintf(theDataBase, sizeof(theDataBase), "%s", {
a_catalog_name ? a_catalog_name : ""); theImpl->m_dbname.assign(a_catalog_name);
theImpl->update_prefix();
int len = BaseString::snprintf(prefixName, sizeof(prefixName), "%s%c%s%c",
theDataBase, table_name_separator,
theDataBaseSchema, table_name_separator);
prefixEnd = prefixName + (len < (int) sizeof(prefixName) ? len :
sizeof(prefixName) - 1);
} }
} }
const char * Ndb::getSchemaName() const const char * Ndb::getSchemaName() const
{ {
return theDataBaseSchema; return theImpl->m_schemaname.c_str();
} }
void Ndb::setSchemaName(const char * a_schema_name) void Ndb::setSchemaName(const char * a_schema_name)
{ {
if (a_schema_name) { if (a_schema_name) {
BaseString::snprintf(theDataBaseSchema, sizeof(theDataBase), "%s", theImpl->m_schemaname.assign(a_schema_name);
a_schema_name ? a_schema_name : ""); theImpl->update_prefix();
int len = BaseString::snprintf(prefixName, sizeof(prefixName), "%s%c%s%c",
theDataBase, table_name_separator,
theDataBaseSchema, table_name_separator);
prefixEnd = prefixName + (len < (int) sizeof(prefixName) ? len :
sizeof(prefixName) - 1);
} }
} }
...@@ -1153,10 +1145,8 @@ Ndb::externalizeIndexName(const char * internalIndexName) ...@@ -1153,10 +1145,8 @@ Ndb::externalizeIndexName(const char * internalIndexName)
const char * const char *
Ndb::internalizeTableName(const char * externalTableName) Ndb::internalizeTableName(const char * externalTableName)
{ {
if (fullyQualifiedNames) { if (fullyQualifiedNames)
strncpy(prefixEnd, externalTableName, NDB_MAX_TAB_NAME_SIZE); return theImpl->internalize_table_name(externalTableName);
return prefixName;
}
else else
return externalTableName; return externalTableName;
} }
...@@ -1165,16 +1155,8 @@ const char * ...@@ -1165,16 +1155,8 @@ const char *
Ndb::internalizeIndexName(const NdbTableImpl * table, Ndb::internalizeIndexName(const NdbTableImpl * table,
const char * externalIndexName) const char * externalIndexName)
{ {
if (fullyQualifiedNames) { if (fullyQualifiedNames)
char tableId[10]; return theImpl->internalize_index_name(table, externalIndexName);
sprintf(tableId, "%d", table->m_tableId);
Uint32 tabIdLen = strlen(tableId);
strncpy(prefixEnd, tableId, tabIdLen);
prefixEnd[tabIdLen] = table_name_separator;
strncpy(prefixEnd + tabIdLen + 1,
externalIndexName, NDB_MAX_TAB_NAME_SIZE);
return prefixName;
}
else else
return externalIndexName; return externalIndexName;
} }
......
...@@ -172,6 +172,7 @@ NdbColumnImpl::init(Type t) ...@@ -172,6 +172,7 @@ NdbColumnImpl::init(Type t)
m_length = 1; // legal m_length = 1; // legal
m_cs = NULL; m_cs = NULL;
break; break;
default:
case Undefined: case Undefined:
assert(false); assert(false);
break; break;
...@@ -299,22 +300,25 @@ NdbTableImpl::~NdbTableImpl() ...@@ -299,22 +300,25 @@ NdbTableImpl::~NdbTableImpl()
void void
NdbTableImpl::init(){ NdbTableImpl::init(){
clearNewProperties(); m_changeMask= 0;
m_tableId= RNIL;
m_frm.clear(); m_frm.clear();
m_fragmentType = NdbDictionary::Object::FragAllSmall; m_fragmentType= NdbDictionary::Object::FragAllSmall;
m_logging = true; m_hashValueMask= 0;
m_kvalue = 6; m_hashpointerValue= 0;
m_minLoadFactor = 78; m_logging= true;
m_maxLoadFactor = 80; m_kvalue= 6;
m_minLoadFactor= 78;
m_index = 0; m_maxLoadFactor= 80;
m_indexType = NdbDictionary::Index::Undefined; m_keyLenInWords= 0;
m_fragmentCount= 0;
m_noOfKeys = 0; m_dictionary= NULL;
m_noOfDistributionKeys = 0; m_index= NULL;
m_fragmentCount = 0; m_indexType= NdbDictionary::Index::Undefined;
m_keyLenInWords = 0; m_noOfKeys= 0;
m_noOfBlobs = 0; m_noOfDistributionKeys= 0;
m_noOfBlobs= 0;
m_replicaCount= 0;
} }
bool bool
...@@ -428,19 +432,6 @@ NdbTableImpl::getName() const ...@@ -428,19 +432,6 @@ NdbTableImpl::getName() const
return m_newExternalName.c_str(); return m_newExternalName.c_str();
} }
void NdbTableImpl::clearNewProperties()
{
m_newExternalName.assign("");
m_changeMask = 0;
}
void NdbTableImpl::copyNewProperties()
{
if (!m_newExternalName.empty()) {
m_externalName.assign(m_newExternalName);
AlterTableReq::setNameFlag(m_changeMask, true);
}
}
void void
NdbTableImpl::buildColumnHash(){ NdbTableImpl::buildColumnHash(){
...@@ -537,14 +528,22 @@ NdbIndexImpl::NdbIndexImpl() : ...@@ -537,14 +528,22 @@ NdbIndexImpl::NdbIndexImpl() :
NdbDictionary::Index(* this), NdbDictionary::Index(* this),
m_facade(this) m_facade(this)
{ {
m_logging = true; init();
} }
NdbIndexImpl::NdbIndexImpl(NdbDictionary::Index & f) : NdbIndexImpl::NdbIndexImpl(NdbDictionary::Index & f) :
NdbDictionary::Index(* this), NdbDictionary::Index(* this),
m_facade(&f) m_facade(&f)
{ {
m_logging = true; init();
}
void NdbIndexImpl::init()
{
m_indexId= RNIL;
m_type= NdbDictionary::Index::Undefined;
m_logging= true;
m_table= NULL;
} }
NdbIndexImpl::~NdbIndexImpl(){ NdbIndexImpl::~NdbIndexImpl(){
...@@ -589,20 +588,26 @@ NdbEventImpl::NdbEventImpl() : ...@@ -589,20 +588,26 @@ NdbEventImpl::NdbEventImpl() :
NdbDictionary::Event(* this), NdbDictionary::Event(* this),
m_facade(this) m_facade(this)
{ {
mi_type = 0; init();
m_dur = NdbDictionary::Event::ED_UNDEFINED;
eventOp = NULL;
m_tableImpl = NULL;
} }
NdbEventImpl::NdbEventImpl(NdbDictionary::Event & f) : NdbEventImpl::NdbEventImpl(NdbDictionary::Event & f) :
NdbDictionary::Event(* this), NdbDictionary::Event(* this),
m_facade(&f) m_facade(&f)
{ {
mi_type = 0; init();
m_dur = NdbDictionary::Event::ED_UNDEFINED; }
eventOp = NULL;
m_tableImpl = NULL; void NdbEventImpl::init()
{
m_eventId= RNIL;
m_eventKey= RNIL;
m_tableId= RNIL;
mi_type= 0;
m_dur= NdbDictionary::Event::ED_UNDEFINED;
m_tableImpl= NULL;
m_bufferId= RNIL;
eventOp= NULL;
} }
NdbEventImpl::~NdbEventImpl() NdbEventImpl::~NdbEventImpl()
...@@ -715,11 +720,13 @@ NdbDictionaryImpl::~NdbDictionaryImpl() ...@@ -715,11 +720,13 @@ NdbDictionaryImpl::~NdbDictionaryImpl()
delete NdbDictionary::Column::ROW_COUNT; delete NdbDictionary::Column::ROW_COUNT;
delete NdbDictionary::Column::COMMIT_COUNT; delete NdbDictionary::Column::COMMIT_COUNT;
delete NdbDictionary::Column::ROW_SIZE; delete NdbDictionary::Column::ROW_SIZE;
delete NdbDictionary::Column::RANGE_NO;
NdbDictionary::Column::FRAGMENT= 0; NdbDictionary::Column::FRAGMENT= 0;
NdbDictionary::Column::FRAGMENT_MEMORY= 0; NdbDictionary::Column::FRAGMENT_MEMORY= 0;
NdbDictionary::Column::ROW_COUNT= 0; NdbDictionary::Column::ROW_COUNT= 0;
NdbDictionary::Column::COMMIT_COUNT= 0; NdbDictionary::Column::COMMIT_COUNT= 0;
NdbDictionary::Column::ROW_SIZE= 0; NdbDictionary::Column::ROW_SIZE= 0;
NdbDictionary::Column::RANGE_NO= 0;
} }
m_globalHash->unlock(); m_globalHash->unlock();
} else { } else {
...@@ -1049,14 +1056,17 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal, ...@@ -1049,14 +1056,17 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
/***************************************************************** /*
* get tab info Get dictionary information for a table using table id as reference
DESCRIPTION
Sends a GET_TABINFOREQ signal containing the table id
*/ */
NdbTableImpl * NdbTableImpl *
NdbDictInterface::getTable(int tableId, bool fullyQualifiedNames) NdbDictInterface::getTable(int tableId, 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());
req->senderRef = m_reference; req->senderRef = m_reference;
req->senderData = 0; req->senderData = 0;
...@@ -1070,40 +1080,51 @@ NdbDictInterface::getTable(int tableId, bool fullyQualifiedNames) ...@@ -1070,40 +1080,51 @@ NdbDictInterface::getTable(int tableId, bool fullyQualifiedNames)
return getTable(&tSignal, 0, 0, fullyQualifiedNames); return getTable(&tSignal, 0, 0, fullyQualifiedNames);
} }
/*
Get dictionary information for a table using table name as the reference
DESCRIPTION
Send GET_TABINFOREQ signal with the table name in the first
long section part
*/
NdbTableImpl * NdbTableImpl *
NdbDictInterface::getTable(const char * name, bool fullyQualifiedNames) NdbDictInterface::getTable(const char * 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 strLen = strlen(name) + 1; // NULL Terminated const Uint32 str_len= strlen(name) + 1; // NULL terminated
if(strLen > MAX_TAB_NAME_SIZE) {//sizeof(req->tableName)){
m_error.code= 4307;
return 0;
}
req->senderRef = m_reference; /* Note! It might be a good idea to check that the length of
req->senderData = 0; table name does not exceed the max size of a long signal */
req->requestType =
m_namebuf.clear();
m_namebuf.grow(str_len+(4-str_len%4)); // Round up to word size
m_namebuf.append(name, str_len);
req->senderRef= m_reference;
req->senderData= 0;
req->requestType=
GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf; GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf;
req->tableNameLen = strLen; req->tableNameLen= str_len;
tSignal.theReceiversBlockNumber = DBDICT; tSignal.theReceiversBlockNumber= DBDICT;
tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ; tSignal.theVerId_signalNumber= GSN_GET_TABINFOREQ;
// tSignal.theLength = GetTabInfoReq::HeaderLength + ((strLen + 3) / 4); tSignal.theLength= GetTabInfoReq::SignalLength;
tSignal.theLength = GetTabInfoReq::SignalLength;
LinearSectionPtr ptr[1]; LinearSectionPtr ptr[1];
ptr[0].p = (Uint32*)name; ptr[0].p= (Uint32*)m_namebuf.get_data();
ptr[0].sz = strLen; ptr[0].sz= (str_len + 3)/ 4; // Size in words
return getTable(&tSignal, ptr, 1, fullyQualifiedNames); return getTable(&tSignal, ptr, 1, fullyQualifiedNames);
} }
NdbTableImpl * NdbTableImpl *
NdbDictInterface::getTable(class NdbApiSignal * signal, NdbDictInterface::getTable(class NdbApiSignal * signal,
LinearSectionPtr ptr[3], LinearSectionPtr ptr[3],
Uint32 noOfSections, bool fullyQualifiedNames) Uint32 noOfSections, bool fullyQualifiedNames)
{ {
//GetTabInfoReq * const req = CAST_PTR(GetTabInfoReq, signal->getDataPtrSend());
int errCodes[] = {GetTabInfoRef::Busy }; int errCodes[] = {GetTabInfoRef::Busy };
int r = dictSignal(signal,ptr,noOfSections, int r = dictSignal(signal,ptr,noOfSections,
...@@ -1464,7 +1485,7 @@ NdbDictionaryImpl::createBlobTables(NdbTableImpl &t) ...@@ -1464,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.c_str(), false);
if (info == 0) { if (info == 0) {
return -1; return -1;
} }
...@@ -1560,7 +1581,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, ...@@ -1560,7 +1581,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
impl.copyNewProperties(); if (!impl.m_newExternalName.empty()) {
impl.m_externalName.assign(impl.m_newExternalName);
AlterTableReq::setNameFlag(impl.m_changeMask, true);
}
//validate(); //validate();
//aggregate(); //aggregate();
...@@ -1677,7 +1702,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, ...@@ -1677,7 +1702,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
NdbApiSignal tSignal(m_reference); NdbApiSignal tSignal(m_reference);
tSignal.theReceiversBlockNumber = DBDICT; tSignal.theReceiversBlockNumber = DBDICT;
LinearSectionPtr ptr[3]; LinearSectionPtr ptr[1];
ptr[0].p = (Uint32*)m_buffer.get_data(); ptr[0].p = (Uint32*)m_buffer.get_data();
ptr[0].sz = m_buffer.length() / 4; ptr[0].sz = m_buffer.length() / 4;
int ret; int ret;
...@@ -2182,7 +2207,7 @@ NdbDictInterface::createIndex(Ndb & ndb, ...@@ -2182,7 +2207,7 @@ NdbDictInterface::createIndex(Ndb & ndb,
} }
attributeList.id[i] = col->m_attrId; attributeList.id[i] = col->m_attrId;
} }
LinearSectionPtr ptr[3]; LinearSectionPtr ptr[2];
ptr[0].p = (Uint32*)&attributeList; ptr[0].p = (Uint32*)&attributeList;
ptr[0].sz = 1 + attributeList.sz; ptr[0].sz = 1 + attributeList.sz;
ptr[1].p = (Uint32*)m_buffer.get_data(); ptr[1].p = (Uint32*)m_buffer.get_data();
...@@ -2489,7 +2514,7 @@ NdbDictInterface::createEvent(class Ndb & ndb, ...@@ -2489,7 +2514,7 @@ NdbDictInterface::createEvent(class Ndb & ndb,
w.add(SimpleProperties::StringValue, w.add(SimpleProperties::StringValue,
ndb.internalizeTableName(evnt.m_tableName.c_str())); ndb.internalizeTableName(evnt.m_tableName.c_str()));
LinearSectionPtr ptr[3]; LinearSectionPtr ptr[1];
ptr[0].p = (Uint32*)m_buffer.get_data(); ptr[0].p = (Uint32*)m_buffer.get_data();
ptr[0].sz = (m_buffer.length()+3) >> 2; ptr[0].sz = (m_buffer.length()+3) >> 2;
......
...@@ -161,8 +161,6 @@ public: ...@@ -161,8 +161,6 @@ public:
*/ */
bool equal(const NdbTableImpl&) const; bool equal(const NdbTableImpl&) const;
void assign(const NdbTableImpl&); void assign(const NdbTableImpl&);
void clearNewProperties();
void copyNewProperties();
static NdbTableImpl & getImpl(NdbDictionary::Table & t); static NdbTableImpl & getImpl(NdbDictionary::Table & t);
static NdbTableImpl & getImpl(const NdbDictionary::Table & t); static NdbTableImpl & getImpl(const NdbDictionary::Table & t);
...@@ -180,6 +178,7 @@ public: ...@@ -180,6 +178,7 @@ public:
NdbIndexImpl(NdbDictionary::Index &); NdbIndexImpl(NdbDictionary::Index &);
~NdbIndexImpl(); ~NdbIndexImpl();
void init();
void setName(const char * name); void setName(const char * name);
const char * getName() const; const char * getName() const;
void setTable(const char * table); void setTable(const char * table);
...@@ -209,6 +208,7 @@ public: ...@@ -209,6 +208,7 @@ public:
NdbEventImpl(NdbDictionary::Event &); NdbEventImpl(NdbDictionary::Event &);
~NdbEventImpl(); ~NdbEventImpl();
void init();
void setName(const char * name); void setName(const char * name);
const char * getName() const; const char * getName() const;
void setTable(const NdbDictionary::Table& table); void setTable(const NdbDictionary::Table& table);
...@@ -368,6 +368,8 @@ private: ...@@ -368,6 +368,8 @@ 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 {
...@@ -560,7 +562,7 @@ NdbTableImpl::getColumn(const char * name){ ...@@ -560,7 +562,7 @@ NdbTableImpl::getColumn(const char * name){
do { do {
if(hashValue == (tmp & 0xFFFE)){ if(hashValue == (tmp & 0xFFFE)){
NdbColumnImpl* col = cols[tmp >> 16]; NdbColumnImpl* col = cols[tmp >> 16];
if(strncmp(name, col->m_name.c_str(), NDB_MAX_ATTR_NAME_SIZE-1) == 0){ if(strncmp(name, col->m_name.c_str(), col->m_name.length()) == 0){
return col; return col;
} }
} }
...@@ -578,7 +580,7 @@ NdbTableImpl::getColumn(const char * name){ ...@@ -578,7 +580,7 @@ NdbTableImpl::getColumn(const char * name){
} else { } else {
for(Uint32 i = 0; i<sz; i++){ for(Uint32 i = 0; i<sz; i++){
NdbColumnImpl* col = * cols++; NdbColumnImpl* col = * cols++;
if(col != 0 && strncmp(name, col->m_name.c_str(), NDB_MAX_ATTR_NAME_SIZE-1) == 0) if(col != 0 && strcmp(name, col->m_name.c_str()) == 0)
return col; return col;
} }
} }
......
...@@ -59,6 +59,37 @@ public: ...@@ -59,6 +59,37 @@ public:
NdbWaiter theWaiter; NdbWaiter theWaiter;
int m_optimized_node_selection; int m_optimized_node_selection;
BaseString m_dbname; // Database name
BaseString m_schemaname; // Schema name
BaseString m_prefix; // Buffer for preformatted internal name <db>/<schema>/
BaseString m_internalname;
void update_prefix()
{
m_prefix.assfmt("%s%c%s%c", m_dbname.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
......
...@@ -62,7 +62,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, ...@@ -62,7 +62,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection,
theNoOfAllocatedTransactions= 0; theNoOfAllocatedTransactions= 0;
theMaxNoOfTransactions= 0; theMaxNoOfTransactions= 0;
theMinNoOfEventsToWakeUp= 0; theMinNoOfEventsToWakeUp= 0;
prefixEnd= NULL;
theConIdleList= NULL; theConIdleList= NULL;
theOpIdleList= NULL; theOpIdleList= NULL;
theScanOpIdleList= NULL; theScanOpIdleList= NULL;
...@@ -110,16 +109,9 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, ...@@ -110,16 +109,9 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection,
theLastTupleId[i] = 0; theLastTupleId[i] = 0;
}//for }//for
BaseString::snprintf(theDataBase, sizeof(theDataBase), "%s", theImpl->m_dbname.assign(aDataBase);
aDataBase ? aDataBase : ""); theImpl->m_schemaname.assign(aSchema);
BaseString::snprintf(theDataBaseSchema, sizeof(theDataBaseSchema), "%s", theImpl->update_prefix();
aSchema ? aSchema : "");
int len = BaseString::snprintf(prefixName, sizeof(prefixName), "%s%c%s%c",
theDataBase, table_name_separator,
theDataBaseSchema, table_name_separator);
prefixEnd = prefixName + (len < (int) sizeof(prefixName) ? len :
sizeof(prefixName) - 1);
theImpl->theWaiter.m_mutex = TransporterFacade::instance()->theMutexPtr; theImpl->theWaiter.m_mutex = TransporterFacade::instance()->theMutexPtr;
......
...@@ -265,14 +265,11 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * ...@@ -265,14 +265,11 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
m_connect_callback= 0; m_connect_callback= 0;
if (ndb_global_event_buffer_mutex == NULL) if (ndb_global_event_buffer_mutex == NULL)
{
ndb_global_event_buffer_mutex= NdbMutex_Create(); ndb_global_event_buffer_mutex= NdbMutex_Create();
}
#ifdef VM_TRACE #ifdef VM_TRACE
if (ndb_print_state_mutex == NULL) if (ndb_print_state_mutex == NULL)
{
ndb_print_state_mutex= NdbMutex_Create(); ndb_print_state_mutex= NdbMutex_Create();
}
#endif #endif
m_config_retriever= m_config_retriever=
new ConfigRetriever(connect_string, NDB_VERSION, NODE_TYPE_API); new ConfigRetriever(connect_string, NDB_VERSION, NODE_TYPE_API);
...@@ -294,7 +291,6 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * ...@@ -294,7 +291,6 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl()
{ {
DBUG_ENTER("~Ndb_cluster_connection"); DBUG_ENTER("~Ndb_cluster_connection");
DBUG_PRINT("enter",("~Ndb_cluster_connection this=0x%x", this));
TransporterFacade::stop_instance(); TransporterFacade::stop_instance();
if (m_connect_thread) if (m_connect_thread)
{ {
...@@ -312,10 +308,22 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() ...@@ -312,10 +308,22 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl()
TransporterFacade::theFacadeInstance= 0; TransporterFacade::theFacadeInstance= 0;
} }
if (m_config_retriever) if (m_config_retriever)
{
delete m_config_retriever; delete m_config_retriever;
m_config_retriever= NULL;
// fragmentToNodeMap.release(); }
if (ndb_global_event_buffer_mutex != NULL)
{
NdbMutex_Destroy(ndb_global_event_buffer_mutex);
ndb_global_event_buffer_mutex= NULL;
}
#ifdef VM_TRACE
if (ndb_print_state_mutex != NULL)
{
NdbMutex_Destroy(ndb_print_state_mutex);
ndb_print_state_mutex= NULL;
}
#endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -985,16 +985,13 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data, ...@@ -985,16 +985,13 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
for (unsigned i= 0; key_part != end; key_part++, i++) for (unsigned i= 0; key_part != end; key_part++, i++)
{ {
const char *field_name= key_part->field->field_name; const char *field_name= key_part->field->field_name;
unsigned name_sz= strlen(field_name);
if (name_sz >= NDB_MAX_ATTR_NAME_SIZE)
name_sz= NDB_MAX_ATTR_NAME_SIZE-1;
#ifndef DBUG_OFF #ifndef DBUG_OFF
data.unique_index_attrid_map[i]= 255; data.unique_index_attrid_map[i]= 255;
#endif #endif
for (unsigned j= 0; j < sz; j++) for (unsigned j= 0; j < sz; j++)
{ {
const NDBCOL *c= index->getColumn(j); const NDBCOL *c= index->getColumn(j);
if (strncmp(field_name, c->getName(), name_sz) == 0) if (strcmp(field_name, c->getName()) == 0)
{ {
data.unique_index_attrid_map[i]= j; data.unique_index_attrid_map[i]= j;
break; break;
...@@ -3545,12 +3542,7 @@ static int create_ndb_column(NDBCOL &col, ...@@ -3545,12 +3542,7 @@ static int create_ndb_column(NDBCOL &col,
HA_CREATE_INFO *info) HA_CREATE_INFO *info)
{ {
// Set name // Set name
{ col.setName(field->field_name);
char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE];
strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name));
truncated_field_name[sizeof(truncated_field_name)-1]= '\0';
col.setName(truncated_field_name);
}
// Get char set // Get char set
CHARSET_INFO *cs= field->charset(); CHARSET_INFO *cs= field->charset();
// Set type and sizes // Set type and sizes
...@@ -4040,12 +4032,7 @@ int ha_ndbcluster::create_index(const char *name, ...@@ -4040,12 +4032,7 @@ int ha_ndbcluster::create_index(const char *name,
{ {
Field *field= key_part->field; Field *field= key_part->field;
DBUG_PRINT("info", ("attr: %s", field->field_name)); DBUG_PRINT("info", ("attr: %s", field->field_name));
{ ndb_index.addColumnName(field->field_name);
char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE];
strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name));
truncated_field_name[sizeof(truncated_field_name)-1]= '\0';
ndb_index.addColumnName(truncated_field_name);
}
} }
if (dict->createIndex(ndb_index)) if (dict->createIndex(ndb_index))
...@@ -5507,6 +5494,7 @@ ndb_get_table_statistics(Ndb* ndb, const char * table, ...@@ -5507,6 +5494,7 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
DBUG_RETURN(0); DBUG_RETURN(0);
} while(0); } while(0);
if (pTrans)
ndb->closeTransaction(pTrans); ndb->closeTransaction(pTrans);
DBUG_PRINT("exit", ("failed")); DBUG_PRINT("exit", ("failed"));
DBUG_RETURN(-1); DBUG_RETURN(-1);
......
...@@ -713,7 +713,8 @@ SQL_SELECT::~SQL_SELECT() ...@@ -713,7 +713,8 @@ SQL_SELECT::~SQL_SELECT()
QUICK_SELECT_I::QUICK_SELECT_I() QUICK_SELECT_I::QUICK_SELECT_I()
:max_used_key_length(0), :max_used_key_length(0),
used_key_parts(0) used_key_parts(0),
records(0)
{} {}
QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr, QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
......
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