Commit 660afeae authored by unknown's avatar unknown

Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11

- try to catch as many malloc failures as possible and give error messages


ndb/src/ndbapi/ObjectMap.cpp:
  New BitKeeper file ``ndb/src/ndbapi/ObjectMap.cpp''
parent 2501c71a
......@@ -1051,6 +1051,18 @@ class Ndb
friend class NdbDictionaryImpl;
friend class NdbDictInterface;
friend class NdbBlob;
friend class Ndb_free_list_t<NdbRecAttr>;
friend class Ndb_free_list_t<NdbApiSignal>;
friend class Ndb_free_list_t<NdbLabel>;
friend class Ndb_free_list_t<NdbBranch>;
friend class Ndb_free_list_t<NdbSubroutine>;
friend class Ndb_free_list_t<NdbCall>;
friend class Ndb_free_list_t<NdbBlob>;
friend class Ndb_free_list_t<NdbReceiver>;
friend class Ndb_free_list_t<NdbIndexScanOperation>;
friend class Ndb_free_list_t<NdbOperation>;
friend class Ndb_free_list_t<NdbIndexOperation>;
friend class Ndb_free_list_t<NdbTransaction>;
#endif
public:
......@@ -1091,7 +1103,7 @@ public:
*
* @param aCatalogName is the new name of the current catalog
*/
void setCatalogName(const char * aCatalogName);
int setCatalogName(const char * aCatalogName);
/**
* The current schema name can be fetched by getSchemaName.
......@@ -1105,7 +1117,7 @@ public:
*
* @param aSchemaName is the new name of the current schema
*/
void setSchemaName(const char * aSchemaName);
int setSchemaName(const char * aSchemaName);
#endif
/**
......@@ -1120,7 +1132,7 @@ public:
*
* @param aDatabaseName is the new name of the current database
*/
void setDatabaseName(const char * aDatabaseName);
int setDatabaseName(const char * aDatabaseName);
/**
* The current database schema name can be fetched by getDatabaseSchemaName.
......@@ -1134,7 +1146,7 @@ public:
*
* @param aDatabaseSchemaName is the new name of the current database schema
*/
void setDatabaseSchemaName(const char * aDatabaseSchemaName);
int setDatabaseSchemaName(const char * aDatabaseSchemaName);
/**
* Initializes the Ndb object
......
......@@ -358,7 +358,7 @@ public:
* Set name of column
* @param name Name of the column
*/
void setName(const char * name);
int setName(const char * name);
/**
* Set whether column is nullable or not
......@@ -446,7 +446,7 @@ public:
void setAutoIncrement(bool);
bool getAutoIncrement() const;
void setAutoIncrementInitialValue(Uint64 val);
void setDefaultValue(const char*);
int setDefaultValue(const char*);
const char* getDefaultValue() const;
static const Column * FRAGMENT;
......@@ -661,13 +661,13 @@ public:
* Name of table
* @param name Name of table
*/
void setName(const char * name);
int setName(const char * name);
/**
* Add a column definition to a table
* @note creates a copy
*/
void addColumn(const Column &);
int addColumn(const Column &);
/**
* @see NdbDictionary::Table::getLogging.
......@@ -723,7 +723,7 @@ public:
/**
* Set frm file to store with this table
*/
void setFrm(const void* data, Uint32 len);
int setFrm(const void* data, Uint32 len);
/**
* Set table object type
......@@ -875,26 +875,26 @@ public:
/**
* Set the name of an index
*/
void setName(const char * name);
int setName(const char * name);
/**
* Define the name of the table to be indexed
*/
void setTable(const char * name);
int setTable(const char * name);
/**
* Add a column to the index definition
* Note that the order of columns will be in
* the order they are added (only matters for ordered indexes).
*/
void addColumn(const Column & c);
int addColumn(const Column & c);
/**
* Add a column name to the index definition
* Note that the order of indexes will be in
* the order they are added (only matters for ordered indexes).
*/
void addColumnName(const char * name);
int addColumnName(const char * name);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/**
......@@ -903,7 +903,7 @@ public:
* the order they are added (only matters for ordered indexes).
* Depricated, use addColumnName instead.
*/
void addIndexColumn(const char * name);
int addIndexColumn(const char * name);
#endif
/**
......@@ -911,7 +911,7 @@ public:
* Note that the order of indexes will be in
* the order they are added (only matters for ordered indexes).
*/
void addColumnNames(unsigned noOfNames, const char ** names);
int addColumnNames(unsigned noOfNames, const char ** names);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/**
......@@ -920,7 +920,7 @@ public:
* the order they are added (only matters for ordered indexes).
* Depricated, use addColumnNames instead.
*/
void addIndexColumns(int noOfNames, const char ** names);
int addIndexColumns(int noOfNames, const char ** names);
#endif
/**
......
......@@ -38,7 +38,7 @@ public:
};
NdbReceiver(Ndb *aNdb);
void init(ReceiverType type, void* owner);
int init(ReceiverType type, void* owner);
void release();
~NdbReceiver();
......@@ -75,7 +75,7 @@ private:
* At setup
*/
class NdbRecAttr * getValue(const class NdbColumnImpl*, char * user_dst_ptr);
void do_get_value(NdbReceiver*, Uint32 rows, Uint32 key_size, Uint32 range);
int do_get_value(NdbReceiver*, Uint32 rows, Uint32 key_size, Uint32 range);
void prepareSend();
void calculate_batch_size(Uint32, Uint32, Uint32&, Uint32&, Uint32&);
......
......@@ -585,7 +585,7 @@ private:
NdbTransaction(Ndb* aNdb);
~NdbTransaction();
void init(); // Initialize connection object for new transaction
int init(); // Initialize connection object for new transaction
int executeNoBlobs(ExecType execType,
AbortOption abortOption = AbortOnError,
......
......@@ -185,6 +185,7 @@ public:
private:
char* m_chr;
unsigned m_len;
friend bool operator!(const BaseString& str);
};
inline const char*
......@@ -249,6 +250,12 @@ BaseString::operator!=(const char *str) const
return strcmp(m_chr, str) != 0;
}
inline bool
operator!(const BaseString& str)
{
return str.m_chr == NULL;
}
inline BaseString&
BaseString::assign(const BaseString& str)
{
......
......@@ -29,14 +29,14 @@ public:
const T& operator[](unsigned i) const;
unsigned size() const { return m_size; };
void push_back(const T &);
int push_back(const T &);
T& back();
void erase(unsigned index);
void clear();
void fill(unsigned new_size, T & obj);
int fill(unsigned new_size, T & obj);
Vector<T>& operator=(const Vector<T>&);
......@@ -52,6 +52,14 @@ private:
template<class T>
Vector<T>::Vector(int i){
m_items = new T[i];
if (m_items == NULL)
{
errno = ENOMEM;
m_size = 0;
m_arraySize = 0;
m_incSize = 0;
return;
}
m_size = 0;
m_arraySize = i;
m_incSize = 50;
......@@ -89,12 +97,15 @@ Vector<T>::back(){
}
template<class T>
void
int
Vector<T>::push_back(const T & t){
if(m_size == m_arraySize){
T * tmp = new T [m_arraySize + m_incSize];
if(!tmp)
abort();
if(tmp == NULL)
{
errno = ENOMEM;
return -1;
}
for (unsigned k = 0; k < m_size; k++)
tmp[k] = m_items[k];
delete[] m_items;
......@@ -103,6 +114,8 @@ Vector<T>::push_back(const T & t){
}
m_items[m_size] = t;
m_size++;
return 0;
}
template<class T>
......@@ -123,10 +136,12 @@ Vector<T>::clear(){
}
template<class T>
void
int
Vector<T>::fill(unsigned new_size, T & obj){
while(m_size <= new_size)
push_back(obj);
if (push_back(obj))
return -1;
return 0;
}
template<class T>
......@@ -150,8 +165,8 @@ struct MutexVector : public NdbLockable {
const T& operator[](unsigned i) const;
unsigned size() const { return m_size; };
void push_back(const T &);
void push_back(const T &, bool lockMutex);
int push_back(const T &);
int push_back(const T &, bool lockMutex);
T& back();
void erase(unsigned index);
......@@ -160,7 +175,7 @@ struct MutexVector : public NdbLockable {
void clear();
void clear(bool lockMutex);
void fill(unsigned new_size, T & obj);
int fill(unsigned new_size, T & obj);
private:
T * m_items;
unsigned m_size;
......@@ -171,6 +186,14 @@ private:
template<class T>
MutexVector<T>::MutexVector(int i){
m_items = new T[i];
if (m_items == NULL)
{
errno = ENOMEM;
m_size = 0;
m_arraySize = 0;
m_incSize = 0;
return;
}
m_size = 0;
m_arraySize = i;
m_incSize = 50;
......@@ -208,11 +231,17 @@ MutexVector<T>::back(){
}
template<class T>
void
int
MutexVector<T>::push_back(const T & t){
lock();
if(m_size == m_arraySize){
T * tmp = new T [m_arraySize + m_incSize];
if (tmp == NULL)
{
errno = ENOMEM;
unlock();
return -1;
}
for (unsigned k = 0; k < m_size; k++)
tmp[k] = m_items[k];
delete[] m_items;
......@@ -222,15 +251,23 @@ MutexVector<T>::push_back(const T & t){
m_items[m_size] = t;
m_size++;
unlock();
return 0;
}
template<class T>
void
int
MutexVector<T>::push_back(const T & t, bool lockMutex){
if(lockMutex)
lock();
if(m_size == m_arraySize){
T * tmp = new T [m_arraySize + m_incSize];
if (tmp == NULL)
{
errno = ENOMEM;
if(lockMutex)
unlock();
return -1;
}
for (unsigned k = 0; k < m_size; k++)
tmp[k] = m_items[k];
delete[] m_items;
......@@ -241,6 +278,7 @@ MutexVector<T>::push_back(const T & t, bool lockMutex){
m_size++;
if(lockMutex)
unlock();
return 0;
}
template<class T>
......@@ -288,10 +326,12 @@ MutexVector<T>::clear(bool l){
}
template<class T>
void
int
MutexVector<T>::fill(unsigned new_size, T & obj){
while(m_size <= new_size)
push_back(obj);
if (push_back(obj))
return -1;
return 0;
}
#endif
......@@ -16,19 +16,36 @@
/* -*- c-basic-offset: 4; -*- */
#include <ndb_global.h>
#include <BaseString.hpp>
#include <basestring_vsnprintf.h>
#include "basestring_vsnprintf.h"
BaseString::BaseString()
{
m_chr = new char[1];
if (m_chr == NULL)
{
errno = ENOMEM;
m_len = 0;
return;
}
m_chr[0] = 0;
m_len = 0;
}
BaseString::BaseString(const char* s)
{
if (s == NULL)
{
m_chr = NULL;
m_len = 0;
}
const size_t n = strlen(s);
m_chr = new char[n + 1];
if (m_chr == NULL)
{
errno = ENOMEM;
m_len = 0;
return;
}
memcpy(m_chr, s, n + 1);
m_len = n;
}
......@@ -37,7 +54,20 @@ BaseString::BaseString(const BaseString& str)
{
const char* const s = str.m_chr;
const size_t n = str.m_len;
if (s == NULL)
{
m_chr = NULL;
m_len = 0;
return;
}
char* t = new char[n + 1];
if (t == NULL)
{
errno = ENOMEM;
m_chr = NULL;
m_len = 0;
return;
}
memcpy(t, s, n + 1);
m_chr = t;
m_len = n;
......@@ -51,9 +81,23 @@ BaseString::~BaseString()
BaseString&
BaseString::assign(const char* s)
{
const size_t n = strlen(s);
if (s == NULL)
{
m_chr = NULL;
m_len = 0;
return *this;
}
size_t n = strlen(s);
char* t = new char[n + 1];
if (t)
{
memcpy(t, s, n + 1);
}
else
{
errno = ENOMEM;
n = 0;
}
delete[] m_chr;
m_chr = t;
m_len = n;
......@@ -64,8 +108,16 @@ BaseString&
BaseString::assign(const char* s, size_t n)
{
char* t = new char[n + 1];
if (t)
{
memcpy(t, s, n);
t[n] = 0;
}
else
{
errno = ENOMEM;
n = 0;
}
delete[] m_chr;
m_chr = t;
m_len = n;
......@@ -83,10 +135,19 @@ BaseString::assign(const BaseString& str, size_t n)
BaseString&
BaseString::append(const char* s)
{
const size_t n = strlen(s);
size_t n = strlen(s);
char* t = new char[m_len + n + 1];
if (t)
{
memcpy(t, m_chr, m_len);
memcpy(t + m_len, s, n + 1);
}
else
{
errno = ENOMEM;
m_len = 0;
n = 0;
}
delete[] m_chr;
m_chr = t;
m_len += n;
......@@ -130,8 +191,14 @@ BaseString::assfmt(const char *fmt, ...)
l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
va_end(ap);
if(l > (int)m_len) {
char *t = new char[l];
if (t == NULL)
{
errno = ENOMEM;
return *this;
}
delete[] m_chr;
m_chr = new char[l];
m_chr = t;
}
va_start(ap, fmt);
basestring_vsnprintf(m_chr, l, fmt, ap);
......@@ -155,6 +222,11 @@ BaseString::appfmt(const char *fmt, ...)
l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
va_end(ap);
char *tmp = new char[l];
if (tmp == NULL)
{
errno = ENOMEM;
return *this;
}
va_start(ap, fmt);
basestring_vsnprintf(tmp, l, fmt, ap);
va_end(ap);
......@@ -242,9 +314,28 @@ BaseString::argify(const char *argv0, const char *src) {
Vector<char *> vargv;
if(argv0 != NULL)
vargv.push_back(strdup(argv0));
{
char *t = strdup(argv0);
if (t == NULL)
{
errno = ENOMEM;
return NULL;
}
if (vargv.push_back(t))
{
free(t);
return NULL;
}
}
char *tmp = new char[strlen(src)+1];
if (tmp == NULL)
{
for(size_t i = 0; i < vargv.size(); i++)
free(vargv[i]);
errno = ENOMEM;
return NULL;
}
char *dst = tmp;
const char *end = src + strlen(src);
/* Copy characters from src to destination, while compacting them
......@@ -288,19 +379,47 @@ BaseString::argify(const char *argv0, const char *src) {
*dst++ = '\0';
src++;
vargv.push_back(strdup(begin));
{
char *t = strdup(begin);
if (t == NULL)
{
delete[] tmp;
for(size_t i = 0; i < vargv.size(); i++)
free(vargv[i]);
errno = ENOMEM;
return NULL;
}
if (vargv.push_back(t))
{
free(t);
delete[] tmp;
for(size_t i = 0; i < vargv.size(); i++)
free(vargv[i]);
return NULL;
}
}
}
end:
delete[] tmp;
vargv.push_back(NULL);
if (vargv.push_back(NULL))
{
for(size_t i = 0; i < vargv.size(); i++)
free(vargv[i]);
return NULL;
}
/* Convert the C++ Vector into a C-vector of strings, suitable for
* calling execv().
*/
char **argv = (char **)malloc(sizeof(*argv) * (vargv.size()));
if(argv == NULL)
{
for(size_t i = 0; i < vargv.size(); i++)
free(vargv[i]);
errno = ENOMEM;
return NULL;
}
for(size_t i = 0; i < vargv.size(); i++){
argv[i] = vargv[i];
......
......@@ -141,7 +141,7 @@ void GlobalDictCache::printCache()
}
NdbTableImpl *
GlobalDictCache::get(const char * name)
GlobalDictCache::get(const char * name, int *error)
{
DBUG_ENTER("GlobalDictCache::get");
DBUG_PRINT("enter", ("name: %s", name));
......@@ -151,6 +151,11 @@ GlobalDictCache::get(const char * name)
versions = m_tableHash.getData(name, len);
if(versions == 0){
versions = new Vector<TableVersion>(2);
if (versions == NULL)
{
*error = -1;
DBUG_RETURN(0);
}
m_tableHash.insertKey(name, len, 0, versions);
}
......@@ -180,7 +185,11 @@ GlobalDictCache::get(const char * name)
tmp.m_impl = 0;
tmp.m_status = RETREIVING;
tmp.m_refCount = 1; // The one retreiving it
versions->push_back(tmp);
if (versions->push_back(tmp))
{
*error = -1;
DBUG_RETURN(0);
}
DBUG_RETURN(0);
}
......
......@@ -67,7 +67,7 @@ public:
GlobalDictCache();
~GlobalDictCache();
NdbTableImpl * get(const char * name);
NdbTableImpl * get(const char * name, int *error);
NdbTableImpl* put(const char * name, NdbTableImpl *);
void drop(NdbTableImpl *);
......
......@@ -48,7 +48,8 @@ libndbapi_la_SOURCES = \
DictCache.cpp \
ndb_cluster_connection.cpp \
NdbBlob.cpp \
SignalSender.cpp
SignalSender.cpp \
ObjectMap.cpp
INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi
......
......@@ -182,6 +182,7 @@ Ndb::NDB_connect(Uint32 tNode)
nodeSequence = tp->getNodeSequence(tNode);
bool node_is_alive = tp->get_node_alive(tNode);
if (node_is_alive) {
DBUG_PRINT("info",("Sending signal to node %u", tNode));
tReturnCode = tp->sendSignal(tSignal, tNode);
releaseSignal(tSignal);
if (tReturnCode != -1) {
......@@ -449,7 +450,11 @@ Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId)
theRemainingStartTransactions--;
NdbTransaction* tConNext = theTransactionList;
tConnection->init();
if (tConnection->init())
{
theError.code = tConnection->theError.code;
DBUG_RETURN(NULL);
}
theTransactionList = tConnection; // into a transaction list.
tConnection->next(tConNext); // Add the active connection object
tConnection->setTransactionId(tFirstTransId);
......@@ -1129,27 +1134,35 @@ const char * Ndb::getCatalogName() const
}
void Ndb::setCatalogName(const char * a_catalog_name)
int Ndb::setCatalogName(const char * a_catalog_name)
{
if (a_catalog_name)
{
theImpl->m_dbname.assign(a_catalog_name);
theImpl->update_prefix();
if (!theImpl->m_dbname.assign(a_catalog_name) ||
theImpl->update_prefix())
{
theError.code = 4000;
return -1;
}
}
return 0;
}
const char * Ndb::getSchemaName() const
{
return theImpl->m_schemaname.c_str();
}
void Ndb::setSchemaName(const char * a_schema_name)
int Ndb::setSchemaName(const char * a_schema_name)
{
if (a_schema_name) {
theImpl->m_schemaname.assign(a_schema_name);
theImpl->update_prefix();
if (!theImpl->m_schemaname.assign(a_schema_name) ||
theImpl->update_prefix())
{
theError.code = 4000;
return -1;
}
}
}
......@@ -1161,9 +1174,9 @@ const char * Ndb::getDatabaseName() const
return getCatalogName();
}
void Ndb::setDatabaseName(const char * a_catalog_name)
int Ndb::setDatabaseName(const char * a_catalog_name)
{
setCatalogName(a_catalog_name);
return setCatalogName(a_catalog_name);
}
const char * Ndb::getDatabaseSchemaName() const
......@@ -1171,9 +1184,9 @@ const char * Ndb::getDatabaseSchemaName() const
return getSchemaName();
}
void Ndb::setDatabaseSchemaName(const char * a_schema_name)
int Ndb::setDatabaseSchemaName(const char * a_schema_name)
{
setSchemaName(a_schema_name);
return setSchemaName(a_schema_name);
}
bool Ndb::usingFullyQualifiedNames()
......@@ -1287,6 +1300,11 @@ const BaseString
Ndb::getDatabaseFromInternalName(const char * internalName)
{
char * databaseName = new char[strlen(internalName) + 1];
if (databaseName == NULL)
{
errno = ENOMEM;
return BaseString(NULL);
}
strcpy(databaseName, internalName);
register char *ptr = databaseName;
......@@ -1303,6 +1321,11 @@ const BaseString
Ndb::getSchemaFromInternalName(const char * internalName)
{
char * schemaName = new char[strlen(internalName)];
if (schemaName == NULL)
{
errno = ENOMEM;
return BaseString(NULL);
}
register const char *ptr1 = internalName;
/* Scan name for the second table_name_separator */
......
......@@ -52,9 +52,9 @@ NdbDictionary::Column::operator=(const NdbDictionary::Column& column)
return *this;
}
void
int
NdbDictionary::Column::setName(const char * name){
m_impl.m_name.assign(name);
return !m_impl.m_name.assign(name);
}
const char*
......@@ -208,10 +208,10 @@ NdbDictionary::Column::setAutoIncrementInitialValue(Uint64 val){
m_impl.m_autoIncrementInitialValue = val;
}
void
int
NdbDictionary::Column::setDefaultValue(const char* defaultValue)
{
m_impl.m_defaultValue.assign(defaultValue);
return !m_impl.m_defaultValue.assign(defaultValue);
}
const char*
......@@ -273,9 +273,9 @@ NdbDictionary::Table::operator=(const NdbDictionary::Table& table)
return *this;
}
void
int
NdbDictionary::Table::setName(const char * name){
m_impl.setName(name);
return m_impl.setName(name);
}
const char *
......@@ -288,18 +288,30 @@ NdbDictionary::Table::getTableId() const {
return m_impl.m_tableId;
}
void
int
NdbDictionary::Table::addColumn(const Column & c){
NdbColumnImpl* col = new NdbColumnImpl;
if (col == NULL)
{
errno = ENOMEM;
return -1;
}
(* col) = NdbColumnImpl::getImpl(c);
m_impl.m_columns.push_back(col);
if (m_impl.m_columns.push_back(col))
{
return -1;
}
if(c.getPrimaryKey()){
m_impl.m_noOfKeys++;
}
if (col->getBlobType()) {
m_impl.m_noOfBlobs++;
}
m_impl.buildColumnHash();
if (m_impl.buildColumnHash())
{
return -1;
}
return 0;
}
const NdbDictionary::Column*
......@@ -442,9 +454,9 @@ NdbDictionary::Table::setSingleUserMode(enum NdbDictionary::Table::SingleUserMod
m_impl.m_single_user_mode = (Uint8)mode;
}
void
int
NdbDictionary::Table::setFrm(const void* data, Uint32 len){
m_impl.m_frm.assign(data, len);
return m_impl.m_frm.assign(data, len);
}
NdbDictionary::Object::Status
......@@ -491,6 +503,7 @@ NdbDictionary::Table::createTableInDb(Ndb* pNdb, bool equalOk) const {
/*****************************************************************
* Index facade
*/
NdbDictionary::Index::Index(const char * name)
: m_impl(* new NdbIndexImpl(* this))
{
......@@ -509,9 +522,9 @@ NdbDictionary::Index::~Index(){
}
}
void
int
NdbDictionary::Index::setName(const char * name){
m_impl.setName(name);
return m_impl.setName(name);
}
const char *
......@@ -519,9 +532,9 @@ NdbDictionary::Index::getName() const {
return m_impl.getName();
}
void
int
NdbDictionary::Index::setTable(const char * table){
m_impl.setTable(table);
return m_impl.setTable(table);
}
const char *
......@@ -556,39 +569,56 @@ NdbDictionary::Index::getIndexColumn(int no) const {
return NULL;
}
void
int
NdbDictionary::Index::addColumn(const Column & c){
NdbColumnImpl* col = new NdbColumnImpl;
if (col == NULL)
{
errno = ENOMEM;
return -1;
}
(* col) = NdbColumnImpl::getImpl(c);
m_impl.m_columns.push_back(col);
if (m_impl.m_columns.push_back(col))
{
return -1;
}
return 0;
}
void
int
NdbDictionary::Index::addColumnName(const char * name){
const Column c(name);
addColumn(c);
return addColumn(c);
}
void
int
NdbDictionary::Index::addIndexColumn(const char * name){
const Column c(name);
addColumn(c);
return addColumn(c);
}
void
int
NdbDictionary::Index::addColumnNames(unsigned noOfNames, const char ** names){
for(unsigned i = 0; i < noOfNames; i++) {
const Column c(names[i]);
addColumn(c);
if (addColumn(c))
{
return -1;
}
}
return 0;
}
void
int
NdbDictionary::Index::addIndexColumns(int noOfNames, const char ** names){
for(int i = 0; i < noOfNames; i++) {
const Column c(names[i]);
addColumn(c);
if (addColumn(c))
{
return -1;
}
}
return 0;
}
void
......
......@@ -390,22 +390,34 @@ NdbTableImpl::equal(const NdbTableImpl& obj) const
DBUG_RETURN(true);
}
void
int
NdbTableImpl::assign(const NdbTableImpl& org)
{
m_tableId = org.m_tableId;
m_internalName.assign(org.m_internalName);
m_externalName.assign(org.m_externalName);
m_newExternalName.assign(org.m_newExternalName);
m_frm.assign(org.m_frm.get_data(), org.m_frm.length());
if (!m_internalName.assign(org.m_internalName) ||
!m_externalName.assign(org.m_externalName) ||
!m_newExternalName.assign(org.m_newExternalName) ||
m_frm.assign(org.m_frm.get_data(), org.m_frm.length()))
{
return -1;
}
m_fragmentType = org.m_fragmentType;
m_fragmentCount = org.m_fragmentCount;
for(unsigned i = 0; i<org.m_columns.size(); i++){
NdbColumnImpl * col = new NdbColumnImpl();
if (col == NULL)
{
errno = ENOMEM;
return -1;
}
const NdbColumnImpl * iorg = org.m_columns[i];
(* col) = (* iorg);
m_columns.push_back(col);
if (m_columns.push_back(col))
{
delete col;
return -1;
}
}
m_logging = org.m_logging;
......@@ -428,11 +440,13 @@ NdbTableImpl::assign(const NdbTableImpl& org)
m_max_rows = org.m_max_rows;
m_min_rows = org.m_min_rows;
return 0;
}
void NdbTableImpl::setName(const char * name)
int NdbTableImpl::setName(const char * name)
{
m_newExternalName.assign(name);
return !m_newExternalName.assign(name);
}
const char *
......@@ -445,7 +459,7 @@ NdbTableImpl::getName() const
}
void
int
NdbTableImpl::buildColumnHash(){
const Uint32 size = m_columns.size();
......@@ -458,19 +472,29 @@ NdbTableImpl::buildColumnHash(){
}
Vector<Uint32> hashValues;
Vector<Vector<Uint32> > chains; chains.fill(size, hashValues);
Vector<Vector<Uint32> > chains;
if (chains.fill(size, hashValues))
{
return -1;
}
for(i = 0; i< (int) size; i++){
Uint32 hv = Hash(m_columns[i]->getName()) & 0xFFFE;
Uint32 bucket = hv & m_columnHashMask;
bucket = (bucket < size ? bucket : bucket - size);
assert(bucket < size);
hashValues.push_back(hv);
chains[bucket].push_back(i);
if (hashValues.push_back(hv) ||
chains[bucket].push_back(i))
{
return -1;
}
}
m_columnHash.clear();
Uint32 tmp = 1;
m_columnHash.fill((unsigned)size-1, tmp); // Default no chaining
if (m_columnHash.fill((unsigned)size-1, tmp)) // Default no chaining
{
return -1;
}
Uint32 pos = 0; // In overflow vector
for(i = 0; i< (int) size; i++){
......@@ -490,12 +514,18 @@ NdbTableImpl::buildColumnHash(){
for(size_t j = 0; j<sz; j++, pos++){
Uint32 col = chains[i][j];
Uint32 hv = hashValues[col];
m_columnHash.push_back((col << 16) | hv);
if (m_columnHash.push_back((col << 16) | hv))
{
return -1;
}
}
}
}
m_columnHash.push_back(0); // Overflow when looping in end of array
if (m_columnHash.push_back(0)) // Overflow when looping in end of array
{
return -1;
}
#if 0
for(size_t i = 0; i<m_columnHash.size(); i++){
......@@ -510,6 +540,7 @@ NdbTableImpl::buildColumnHash(){
i, col > 0 ? m_columns[col]->getName() : "" , m_columnHash[i]);
}
#endif
return 0;
}
Uint32
......@@ -563,9 +594,9 @@ NdbIndexImpl::~NdbIndexImpl(){
delete m_columns[i];
}
void NdbIndexImpl::setName(const char * name)
int NdbIndexImpl::setName(const char * name)
{
m_externalName.assign(name);
return !m_externalName.assign(name);
}
const char *
......@@ -574,10 +605,10 @@ NdbIndexImpl::getName() const
return m_externalName.c_str();
}
void
int
NdbIndexImpl::setTable(const char * table)
{
m_tableName.assign(table);
return !m_tableName.assign(table);
}
const char *
......@@ -657,14 +688,18 @@ Ndb_local_table_info *
NdbDictionaryImpl::fetchGlobalTableImpl(const BaseString& internalTableName)
{
NdbTableImpl *impl;
int error= 0;
m_globalHash->lock();
impl = m_globalHash->get(internalTableName.c_str());
impl = m_globalHash->get(internalTableName.c_str(), &error);
m_globalHash->unlock();
if (impl == 0){
if (error == 0)
impl = m_receiver.getTable(internalTableName,
m_ndb.usingFullyQualifiedNames());
else
m_error.code = 4000;
m_globalHash->lock();
m_globalHash->put(internalTableName.c_str(), impl);
m_globalHash->unlock();
......@@ -998,12 +1033,20 @@ NdbDictInterface::getTable(const BaseString& name, bool fullyQualifiedNames)
// Copy name to m_buffer to get a word sized buffer
m_buffer.clear();
m_buffer.grow(namelen_words*4+4);
m_buffer.append(name.c_str(), namelen);
if (m_buffer.grow(namelen_words*4+4) ||
m_buffer.append(name.c_str(), namelen))
{
m_error.code= 4000;
return NULL;
}
#ifndef IGNORE_VALGRIND_WARNINGS
Uint32 pad = 0;
m_buffer.append(&pad, 4);
if (m_buffer.append(&pad, 4))
{
m_error.code= 4000;
return NULL;
}
#endif
LinearSectionPtr ptr[1];
......@@ -1034,7 +1077,14 @@ NdbDictInterface::getTable(class NdbApiSignal * signal,
(Uint32*)m_buffer.get_data(),
m_buffer.length() / 4, fullyQualifiedNames);
if (rt != 0)
rt->buildColumnHash();
{
if (rt->buildColumnHash())
{
m_error.code = 4000;
delete rt;
return NULL;
}
}
return rt;
}
......@@ -1043,18 +1093,25 @@ NdbDictInterface::execGET_TABINFO_CONF(NdbApiSignal * signal,
LinearSectionPtr ptr[3])
{
const GetTabInfoConf* conf = CAST_CONSTPTR(GetTabInfoConf, signal->getDataPtr());
const Uint32 i = GetTabInfoConf::DICT_TAB_INFO;
if(signal->isFirstFragment()){
m_fragmentId = signal->getFragmentId();
m_buffer.grow(4 * conf->totalLen);
if (m_buffer.grow(4 * conf->totalLen))
{
m_error.code= 4000;
goto end;
}
} else {
if(m_fragmentId != signal->getFragmentId()){
abort();
}
}
const Uint32 i = GetTabInfoConf::DICT_TAB_INFO;
m_buffer.append(ptr[i].p, 4 * ptr[i].sz);
if (m_buffer.append(ptr[i].p, 4 * ptr[i].sz))
{
m_error.code= 4000;
}
end:
if(!signal->isLastFragment()){
return;
}
......@@ -1185,10 +1242,12 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
impl->m_tableId = tableDesc.TableId;
impl->m_version = tableDesc.TableVersion;
impl->m_status = NdbDictionary::Object::Retrieved;
impl->m_internalName.assign(internalName);
impl->m_externalName.assign(externalName);
impl->m_frm.assign(tableDesc.FrmData, tableDesc.FrmLen);
if (!impl->m_internalName.assign(internalName) ||
!impl->m_externalName.assign(externalName) ||
impl->m_frm.assign(tableDesc.FrmData, tableDesc.FrmLen))
{
DBUG_RETURN(4000);
}
impl->m_fragmentType = (NdbDictionary::Object::FragmentType)
getApiConstant(tableDesc.FragmentType,
......@@ -1216,7 +1275,10 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
} else {
const char * externalPrimary =
Ndb::externalizeTableName(tableDesc.PrimaryTable, fullyQualifiedNames);
impl->m_primaryTable.assign(externalPrimary);
if (!impl->m_primaryTable.assign(externalPrimary))
{
DBUG_RETURN(4000);
}
}
Uint32 keyInfoPos = 0;
......@@ -1243,6 +1305,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
// check type and compute attribute size and array size
if (! attrDesc.translateExtType()) {
delete col;
delete impl;
DBUG_RETURN(703);
}
......@@ -1254,12 +1317,14 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
unsigned cs_number = (attrDesc.AttributeExtPrecision >> 16);
// charset is defined exactly for char types
if (col->getCharType() != (cs_number != 0)) {
delete col;
delete impl;
DBUG_RETURN(703);
}
if (col->getCharType()) {
col->m_cs = get_charset(cs_number, MYF(0));
if (col->m_cs == NULL) {
delete col;
delete impl;
DBUG_RETURN(743);
}
......@@ -1277,7 +1342,12 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
col->m_nullable = attrDesc.AttributeNullableFlag;
col->m_autoIncrement = (attrDesc.AttributeAutoIncrement ? true : false);
col->m_autoIncrementInitialValue = ~0;
col->m_defaultValue.assign(attrDesc.AttributeDefaultValue);
if (!col->m_defaultValue.assign(attrDesc.AttributeDefaultValue))
{
delete col;
delete impl;
DBUG_RETURN(4000);
}
if(attrDesc.AttributeKeyFlag){
col->m_keyInfoPos = keyInfoPos + 1;
......@@ -1317,7 +1387,11 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
for(i = 0; i<(fragCount*replicaCount); i++)
{
impl->m_fragments.push_back(tableDesc.FragmentData[i+2]);
if (impl->m_fragments.push_back(tableDesc.FragmentData[i+2]))
{
delete impl;
DBUG_RETURN(4000);
}
}
Uint32 topBit = (1 << 31);
......@@ -1481,7 +1555,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
}
if (!impl.m_newExternalName.empty()) {
impl.m_externalName.assign(impl.m_newExternalName);
if (!impl.m_externalName.assign(impl.m_newExternalName))
{
m_error.code= 4000;
DBUG_RETURN(-1);
}
AlterTableReq::setNameFlag(impl.m_changeMask, true);
}
......@@ -1490,7 +1568,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
const BaseString internalName(
ndb.internalize_table_name(impl.m_externalName.c_str()));
impl.m_internalName.assign(internalName);
if (!impl.m_internalName.assign(internalName))
{
m_error.code= 4000;
DBUG_RETURN(-1);
}
UtilBufferWriter w(m_buffer);
DictTabInfo::Table tmpTab; tmpTab.init();
BaseString::snprintf(tmpTab.TableName,
......@@ -1967,13 +2049,19 @@ NdbDictionaryImpl::getIndexImpl(const char * externalName,
NdbIndexImpl* idx;
if(NdbDictInterface::create_index_obj_from_table(&idx, tab, prim) == 0){
idx->m_table = tab;
idx->m_externalName.assign(externalName);
idx->m_internalName.assign(internalName);
if (!idx->m_externalName.assign(externalName) ||
!idx->m_internalName.assign(internalName))
{
delete idx;
m_error.code = 4000;
return 0;
}
// TODO Assign idx to tab->m_index
// Don't do it right now since assign can't asign a table with index
// tab->m_index = idx;
return idx;
}
m_error.code = 4000;
return 0;
}
......@@ -1982,11 +2070,21 @@ NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst,
NdbTableImpl* tab,
const NdbTableImpl* prim){
NdbIndexImpl *idx = new NdbIndexImpl();
if (idx == NULL)
{
errno = ENOMEM;
return -1;
}
idx->m_version = tab->m_version;
idx->m_status = tab->m_status;
idx->m_indexId = tab->m_tableId;
idx->m_externalName.assign(tab->getName());
idx->m_tableName.assign(prim->m_externalName);
if (!idx->m_externalName.assign(tab->getName()) ||
!idx->m_tableName.assign(prim->m_externalName))
{
delete idx;
errno = ENOMEM;
return -1;
}
NdbDictionary::Index::Type type = idx->m_type = tab->m_indexType;
idx->m_logging = tab->m_logging;
// skip last attribute (NDB$PK or NDB$TNODE)
......@@ -1999,9 +2097,20 @@ NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst,
NdbColumnImpl* org = tab->m_columns[i];
NdbColumnImpl* col = new NdbColumnImpl;
if (col == NULL)
{
errno = ENOMEM;
delete idx;
return -1;
}
// Copy column definition
*col = * org;
idx->m_columns.push_back(col);
if (idx->m_columns.push_back(col))
{
delete col;
delete idx;
return -1;
}
/**
* reverse map
......@@ -2067,7 +2176,11 @@ NdbDictInterface::createIndex(Ndb & ndb,
}
const BaseString internalName(
ndb.internalize_index_name(&table, impl.getName()));
impl.m_internalName.assign(internalName);
if (!impl.m_internalName.assign(internalName))
{
m_error.code = 4000;
return -1;
}
w.add(DictTabInfo::TableName, internalName.c_str());
w.add(DictTabInfo::TableLoggedFlag, impl.m_logging);
......@@ -2353,34 +2466,72 @@ NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list,
BaseString databaseName;
BaseString schemaName;
BaseString objectName;
if (!databaseName || !schemaName || !objectName)
{
m_error.code= 4000;
return -1;
}
if ((element.type == NdbDictionary::Object::UniqueHashIndex) ||
(element.type == NdbDictionary::Object::OrderedIndex)) {
char * indexName = new char[n << 2];
if (indexName == NULL)
{
m_error.code= 4000;
return -1;
}
memcpy(indexName, &data[pos], n << 2);
databaseName = Ndb::getDatabaseFromInternalName(indexName);
schemaName = Ndb::getSchemaFromInternalName(indexName);
if (!(databaseName = Ndb::getDatabaseFromInternalName(indexName)) ||
!(schemaName = Ndb::getSchemaFromInternalName(indexName)))
{
delete [] indexName;
m_error.code= 4000;
return -1;
}
objectName = BaseString(Ndb::externalizeIndexName(indexName, fullyQualifiedNames));
delete [] indexName;
} else if ((element.type == NdbDictionary::Object::SystemTable) ||
(element.type == NdbDictionary::Object::UserTable)) {
char * tableName = new char[n << 2];
if (tableName == NULL)
{
m_error.code= 4000;
return -1;
}
memcpy(tableName, &data[pos], n << 2);
databaseName = Ndb::getDatabaseFromInternalName(tableName);
schemaName = Ndb::getSchemaFromInternalName(tableName);
if (!(databaseName = Ndb::getDatabaseFromInternalName(tableName)) ||
!(schemaName = Ndb::getSchemaFromInternalName(tableName)))
{
delete [] tableName;
m_error.code= 4000;
return -1;
}
objectName = BaseString(Ndb::externalizeTableName(tableName, fullyQualifiedNames));
delete [] tableName;
}
else {
char * otherName = new char[n << 2];
if (otherName == NULL)
{
m_error.code= 4000;
return -1;
}
memcpy(otherName, &data[pos], n << 2);
objectName = BaseString(otherName);
if (!(objectName = BaseString(otherName)))
{
m_error.code= 4000;
return -1;
}
delete [] otherName;
}
element.database = new char[databaseName.length() + 1];
if (!(element.database = new char[databaseName.length() + 1]) ||
!(element.schema = new char[schemaName.length() + 1]) ||
!(element.name = new char[objectName.length() + 1]))
{
m_error.code= 4000;
return -1;
}
strcpy(element.database, databaseName.c_str());
element.schema = new char[schemaName.length() + 1];
strcpy(element.schema, schemaName.c_str());
element.name = new char[objectName.length() + 1];
strcpy(element.name, objectName.c_str());
pos += n;
count++;
......@@ -2427,7 +2578,10 @@ NdbDictInterface::execLIST_TABLES_CONF(NdbApiSignal* signal,
{
const unsigned off = ListTablesConf::HeaderLength;
const unsigned len = (signal->getLength() - off);
m_buffer.append(signal->getDataPtr() + off, len << 2);
if (m_buffer.append(signal->getDataPtr() + off, len << 2))
{
m_error.code= 4000;
}
if (signal->getLength() < ListTablesConf::SignalLength) {
// last signal has less than full length
m_waiter.signal(NO_WAIT);
......
......@@ -103,7 +103,7 @@ public:
~NdbTableImpl();
void init();
void setName(const char * name);
int setName(const char * name);
const char * getName() const;
Uint32 m_changeMask;
......@@ -120,7 +120,7 @@ public:
Uint32 m_columnHashMask;
Vector<Uint32> m_columnHash;
Vector<NdbColumnImpl *> m_columns;
void buildColumnHash();
int buildColumnHash();
/**
* Fragment info
......@@ -166,7 +166,7 @@ public:
* Equality/assign
*/
bool equal(const NdbTableImpl&) const;
void assign(const NdbTableImpl&);
int assign(const NdbTableImpl&);
static NdbTableImpl & getImpl(NdbDictionary::Table & t);
static NdbTableImpl & getImpl(const NdbDictionary::Table & t);
......@@ -185,9 +185,9 @@ public:
~NdbIndexImpl();
void init();
void setName(const char * name);
int setName(const char * name);
const char * getName() const;
void setTable(const char * table);
int setTable(const char * table);
const char * getTable() const;
const NdbTableImpl * getIndexTable() const;
......
......@@ -37,7 +37,7 @@ struct Ndb_free_list_t
Ndb_free_list_t();
~Ndb_free_list_t();
void fill(Ndb*, Uint32 cnt);
int fill(Ndb*, Uint32 cnt);
T* seize(Ndb*);
void release(T*);
void clear();
......@@ -79,10 +79,14 @@ public:
BaseString m_prefix; // Buffer for preformatted internal name <db>/<schema>/
void update_prefix()
int update_prefix()
{
m_prefix.assfmt("%s%c%s%c", m_dbname.c_str(), table_name_separator,
m_schemaname.c_str(), table_name_separator);
if (!m_prefix.assfmt("%s%c%s%c", m_dbname.c_str(), table_name_separator,
m_schemaname.c_str(), table_name_separator))
{
return -1;
}
return 0;
}
/**
......@@ -194,7 +198,7 @@ Ndb_free_list_t<T>::~Ndb_free_list_t()
template<class T>
inline
void
int
Ndb_free_list_t<T>::fill(Ndb* ndb, Uint32 cnt)
{
if (m_free_list == 0)
......@@ -202,18 +206,28 @@ Ndb_free_list_t<T>::fill(Ndb* ndb, Uint32 cnt)
m_free_cnt++;
m_alloc_cnt++;
m_free_list = new T(ndb);
if (m_free_list == 0)
{
ndb->theError.code = 4000;
assert(false);
return -1;
}
}
while(m_alloc_cnt < cnt)
{
T* obj= new T(ndb);
if(obj == 0)
return;
{
ndb->theError.code = 4000;
assert(false);
return -1;
}
obj->next(m_free_list);
m_free_cnt++;
m_alloc_cnt++;
m_free_list = obj;
}
return 0;
}
template<class T>
......@@ -234,7 +248,11 @@ Ndb_free_list_t<T>::seize(Ndb* ndb)
{
m_alloc_cnt++;
}
else
{
ndb->theError.code = 4000;
assert(false);
}
return tmp;
}
......
......@@ -176,7 +176,11 @@ NdbOperation::init(const NdbTableImpl* tab, NdbTransaction* myConnection){
tcKeyReq->scanInfo = 0;
theKEYINFOptr = &tcKeyReq->keyInfo[0];
theATTRINFOptr = &tcKeyReq->attrInfo[0];
theReceiver.init(NdbReceiver::NDB_OPERATION, this);
if (theReceiver.init(NdbReceiver::NDB_OPERATION, this))
{
// theReceiver sets the error code of its owner
return -1;
}
return 0;
}
......
......@@ -83,6 +83,7 @@ NdbRecAttr::setup(const NdbColumnImpl* anAttrInfo, char* aValue)
theRef = tRef;
return 0;
}
errno = ENOMEM;
return -1;
}
......@@ -102,7 +103,11 @@ NdbRecAttr::copyout()
NdbRecAttr *
NdbRecAttr::clone() const {
NdbRecAttr * ret = new NdbRecAttr(0);
if (ret == NULL)
{
errno = ENOMEM;
return NULL;
}
ret->theAttrId = theAttrId;
ret->theNULLind = theNULLind;
ret->theAttrSize = theAttrSize;
......@@ -116,6 +121,12 @@ NdbRecAttr::clone() const {
ret->theValue = 0;
} else {
ret->theStorageX = new Uint64[((n + 7) >> 3)];
if (ret->theStorageX == NULL)
{
delete ret;
errno = ENOMEM;
return NULL;
}
ret->theRef = (char*)ret->theStorageX;
ret->theValue = 0;
}
......
......@@ -32,7 +32,7 @@ NdbReceiver::NdbReceiver(Ndb *aNdb) :
{
theCurrentRecAttr = theFirstRecAttr = 0;
m_defined_rows = 0;
m_rows = new NdbRecAttr*[0];
m_rows = NULL;
}
NdbReceiver::~NdbReceiver()
......@@ -45,19 +45,26 @@ NdbReceiver::~NdbReceiver()
DBUG_VOID_RETURN;
}
void
int
NdbReceiver::init(ReceiverType type, void* owner)
{
theMagicNumber = 0x11223344;
m_type = type;
m_owner = owner;
theFirstRecAttr = NULL;
theCurrentRecAttr = NULL;
if (m_id == NdbObjectIdMap::InvalidId) {
if (m_ndb)
{
m_id = m_ndb->theImpl->theNdbObjectIdMap.map(this);
if (m_id == NdbObjectIdMap::InvalidId)
{
setErrorCode(4000);
return -1;
}
theFirstRecAttr = NULL;
theCurrentRecAttr = NULL;
}
}
return 0;
}
void
......@@ -146,7 +153,7 @@ NdbReceiver::calculate_batch_size(Uint32 key_size,
return;
}
void
int
NdbReceiver::do_get_value(NdbReceiver * org,
Uint32 rows,
Uint32 key_size,
......@@ -154,7 +161,11 @@ NdbReceiver::do_get_value(NdbReceiver * org,
if(rows > m_defined_rows){
delete[] m_rows;
m_defined_rows = rows;
m_rows = new NdbRecAttr*[rows + 1];
if ((m_rows = new NdbRecAttr*[rows + 1]) == NULL)
{
setErrorCode(4000);
return -1;
}
}
m_rows[rows] = 0;
......@@ -174,7 +185,7 @@ NdbReceiver::do_get_value(NdbReceiver * org,
// Put key-recAttr fir on each row
if(key_size && !getValue(&key, (char*)0)){
abort();
return ; // -1
return -1;
}
if(range_no &&
......@@ -193,7 +204,7 @@ NdbReceiver::do_get_value(NdbReceiver * org,
if(tRecAttr){
abort();
return ;// -1;
return -1;
}
// Store first recAttr for each row in m_rows[i]
......@@ -205,7 +216,7 @@ NdbReceiver::do_get_value(NdbReceiver * org,
}
prepareSend();
return;
return 0;
}
NdbRecAttr*
......
......@@ -78,7 +78,11 @@ NdbScanFilter::~NdbScanFilter(){
int
NdbScanFilter::begin(Group group){
m_impl.m_stack2.push_back(m_impl.m_negative);
if (m_impl.m_stack2.push_back(m_impl.m_negative))
{
m_impl.m_operation->setErrorCodeAbort(4000);
return -1;
}
switch(group){
case NdbScanFilter::AND:
INT_DEBUG(("Begin(AND)"));
......@@ -127,7 +131,11 @@ NdbScanFilter::begin(Group group){
}
NdbScanFilterImpl::State tmp = m_impl.m_current;
m_impl.m_stack.push_back(m_impl.m_current);
if (m_impl.m_stack.push_back(m_impl.m_current))
{
m_impl.m_operation->setErrorCodeAbort(4000);
return -1;
}
m_impl.m_current.m_group = group;
m_impl.m_current.m_ownLabel = m_impl.m_label++;
m_impl.m_current.m_popCount = 0;
......
......@@ -797,9 +797,12 @@ int NdbScanOperation::prepareSendScan(Uint32 aTC_ConnectPtr,
req->requestInfo = reqInfo;
for(Uint32 i = 0; i<theParallelism; i++){
m_receivers[i]->do_get_value(&theReceiver, batch_size,
if (m_receivers[i]->do_get_value(&theReceiver, batch_size,
key_size,
m_read_range_no);
m_read_range_no))
{
return -1;
}
}
return 0;
}
......
......@@ -81,6 +81,7 @@ NdbTransaction::NdbTransaction( Ndb* aNdb ) :
{
theListState = NotInList;
theError.code = 0;
//theId = NdbObjectIdMap::InvalidId;
theId = theNdb->theImpl->theNdbObjectIdMap.map(this);
#define CHECK_SZ(mask, sz) assert((sizeof(mask)/sizeof(mask[0])) == sz)
......@@ -106,7 +107,7 @@ void init();
Remark: Initialise connection object for new transaction.
*****************************************************************************/
void
int
NdbTransaction::init()
{
theListState = NotInList;
......@@ -147,6 +148,17 @@ NdbTransaction::init()
//
theBlobFlag = false;
thePendingBlobOps = 0;
if (theId == NdbObjectIdMap::InvalidId)
{
theId = theNdb->theImpl->theNdbObjectIdMap.map(this);
if (theId == NdbObjectIdMap::InvalidId)
{
theError.code = 4000;
return -1;
}
}
return 0;
}//NdbTransaction::init()
/*****************************************************************************
......
......@@ -816,8 +816,9 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3])
InvalidSignal:
#ifdef VM_TRACE
ndbout_c("Ndbif: Error Ndb::handleReceivedSignal "
"(GSN=%d, theImpl->theWaiter.m_state=%d)"
"(tFirstDataPtr=%x, GSN=%d, theImpl->theWaiter.m_state=%d)"
" sender = (Block: %d Node: %d)",
tFirstDataPtr,
tSignalNumber,
tWaitState,
refToBlock(aSignal->theSendersBlockRef),
......
......@@ -74,7 +74,10 @@ Ndb::checkFailedNode()
int
Ndb::createConIdleList(int aNrOfCon)
{
theImpl->theConIdleList.fill(this, aNrOfCon);
if (theImpl->theConIdleList.fill(this, aNrOfCon))
{
return -1;
}
return aNrOfCon;
}
......@@ -90,7 +93,10 @@ Ndb::createConIdleList(int aNrOfCon)
int
Ndb::createOpIdleList(int aNrOfOp)
{
theImpl->theOpIdleList.fill(this, aNrOfOp);
if (theImpl->theOpIdleList.fill(this, aNrOfOp))
{
return -1;
}
return aNrOfOp;
}
......
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "ObjectMap.hpp"
NdbObjectIdMap::NdbObjectIdMap(NdbMutex* mutex, Uint32 sz, Uint32 eSz)
{
m_size = 0;
m_firstFree = InvalidId;
m_map = 0;
m_mutex = mutex;
m_expandSize = eSz;
expand(sz);
#ifdef DEBUG_OBJECTMAP
ndbout_c("NdbObjectIdMap:::NdbObjectIdMap(%u)", sz);
#endif
}
NdbObjectIdMap::~NdbObjectIdMap()
{
free(m_map);
}
int NdbObjectIdMap::expand(Uint32 incSize)
{
NdbMutex_Lock(m_mutex);
Uint32 newSize = m_size + incSize;
MapEntry * tmp = (MapEntry*)realloc(m_map, newSize * sizeof(MapEntry));
if (likely(tmp != 0))
{
m_map = tmp;
for(Uint32 i = m_size; i < newSize; i++){
m_map[i].m_next = i + 1;
}
m_firstFree = m_size;
m_map[newSize-1].m_next = InvalidId;
m_size = newSize;
}
else
{
NdbMutex_Unlock(m_mutex);
g_eventLogger.error("NdbObjectIdMap::expand: realloc(%u*%u) failed",
newSize, sizeof(MapEntry));
return -1;
}
NdbMutex_Unlock(m_mutex);
return 0;
}
......@@ -20,6 +20,9 @@
//#include <NdbMutex.h>
#include <NdbOut.hpp>
#include <EventLogger.hpp>
extern EventLogger g_eventLogger;
//#define DEBUG_OBJECTMAP
/**
......@@ -49,24 +52,6 @@ private:
int expand(Uint32 newSize);
};
inline
NdbObjectIdMap::NdbObjectIdMap(NdbMutex* mutex, Uint32 sz, Uint32 eSz) {
m_size = 0;
m_firstFree = InvalidId;
m_map = 0;
m_mutex = mutex;
m_expandSize = eSz;
expand(sz);
#ifdef DEBUG_OBJECTMAP
ndbout_c("NdbObjectIdMap:::NdbObjectIdMap(%u)", sz);
#endif
}
inline
NdbObjectIdMap::~NdbObjectIdMap(){
free(m_map);
}
inline
Uint32
NdbObjectIdMap::map(void * object){
......@@ -102,7 +87,8 @@ NdbObjectIdMap::unmap(Uint32 id, void *object){
m_map[i].m_next = m_firstFree;
m_firstFree = i;
} else {
ndbout_c("Error: NdbObjectIdMap::::unmap(%u, 0x%x) obj=0x%x", id, object, obj);
g_eventLogger.error("NdbObjectIdMap::unmap(%u, 0x%x) obj=0x%x",
id, object, obj);
return 0;
}
......@@ -128,31 +114,4 @@ NdbObjectIdMap::getObject(Uint32 id){
}
return 0;
}
inline int
NdbObjectIdMap::expand(Uint32 incSize){
NdbMutex_Lock(m_mutex);
Uint32 newSize = m_size + incSize;
MapEntry * tmp = (MapEntry*)realloc(m_map, newSize * sizeof(MapEntry));
if (likely(tmp != 0))
{
m_map = tmp;
for(Uint32 i = m_size; i<newSize; i++){
m_map[i].m_next = i + 1;
}
m_firstFree = m_size;
m_map[newSize-1].m_next = InvalidId;
m_size = newSize;
}
else
{
NdbMutex_Unlock(m_mutex);
return -1;
}
NdbMutex_Unlock(m_mutex);
return 0;
}
#endif
......@@ -147,7 +147,10 @@ SignalSender::waitFor(Uint32 timeOutMillis, T & t)
{
SimpleSignal * s = t.check(m_jobBuffer);
if(s != 0){
m_usedBuffer.push_back(s);
if (m_usedBuffer.push_back(s))
{
return 0;
}
return s;
}
......@@ -162,7 +165,10 @@ SignalSender::waitFor(Uint32 timeOutMillis, T & t)
SimpleSignal * s = t.check(m_jobBuffer);
if(s != 0){
m_usedBuffer.push_back(s);
if (m_usedBuffer.push_back(s))
{
return 0;
}
return s;
}
......
......@@ -353,7 +353,7 @@ Ndb_cluster_connection_impl::set_name(const char *name)
}
}
void
int
Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
const ndb_mgm_configuration
&config)
......@@ -402,7 +402,10 @@ Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
break;
}
}
m_impl.m_all_nodes.push_back(Node(group,remoteNodeId));
if (m_impl.m_all_nodes.push_back(Node(group,remoteNodeId)))
{
DBUG_RETURN(-1);
}
DBUG_PRINT("info",("saved %d %d", group,remoteNodeId));
for (int i= m_impl.m_all_nodes.size()-2;
i >= 0 && m_impl.m_all_nodes[i].group > m_impl.m_all_nodes[i+1].group;
......@@ -449,7 +452,7 @@ Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
do_test();
#endif
DBUG_VOID_RETURN;
DBUG_RETURN(0);
}
void
......@@ -532,7 +535,11 @@ int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds,
break;
m_impl.m_transporter_facade->start_instance(nodeId, props);
m_impl.init_nodes_vector(nodeId, *props);
if (m_impl.init_nodes_vector(nodeId, *props))
{
ndbout_c("Ndb_cluster_connection::connect: malloc failure");
DBUG_RETURN(-1);
}
for(unsigned i=0;
i<m_impl.m_transporter_facade->get_registry()->m_transporter_interface.size();
......
......@@ -68,7 +68,7 @@ private:
};
Vector<Node> m_all_nodes;
void init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config);
int init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config);
void connect_thread();
void set_name(const char *name);
......
......@@ -203,6 +203,7 @@ static const err_code_mapping err_map[]=
{ 284, HA_ERR_TABLE_DEF_CHANGED, 0 },
{4000, HA_ERR_OUT_OF_MEM, 1 },
{4009, HA_ERR_NO_CONNECTION, 1 },
{ 0, 1, 0 },
......@@ -372,7 +373,10 @@ int ha_ndbcluster::records_update()
{
Ndb *ndb= get_ndb();
struct Ndb_statistics stat;
ndb->setDatabaseName(m_dbname);
if (ndb->setDatabaseName(m_dbname))
{
return my_errno= HA_ERR_OUT_OF_MEM;
}
result= ndb_get_table_statistics(this, true, ndb, m_tabname, &stat);
if (result == 0)
{
......@@ -841,7 +845,11 @@ int ha_ndbcluster::get_ndb_blobs_value(NdbBlob *last_ndb_blob,
DBUG_PRINT("value", ("allocate blobs buffer size %u", offset));
m_blobs_buffer= my_malloc(offset, MYF(MY_WME));
if (m_blobs_buffer == NULL)
{
sql_print_error("ha_ndbcluster::get_ndb_blobs_value: "
"my_malloc(%u) failed", offset);
DBUG_RETURN(-1);
}
m_blobs_buffer_size= offset;
}
}
......@@ -1026,6 +1034,12 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
if (data.unique_index_attrid_map)
my_free((char*)data.unique_index_attrid_map, MYF(0));
data.unique_index_attrid_map= (unsigned char*)my_malloc(sz,MYF(MY_WME));
if (data.unique_index_attrid_map == 0)
{
sql_print_error("fix_unique_index_attr_order: my_malloc(%u) failure",
(unsigned int)sz);
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
KEY_PART_INFO* key_part= key_info->key_part;
KEY_PART_INFO* end= key_part+key_info->key_parts;
......@@ -3228,7 +3242,10 @@ int ha_ndbcluster::info(uint flag)
DBUG_RETURN(my_errno);
Ndb *ndb= get_ndb();
struct Ndb_statistics stat;
ndb->setDatabaseName(m_dbname);
if (ndb->setDatabaseName(m_dbname))
{
DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM);
}
if (current_thd->variables.ndb_use_exact_count &&
(result= ndb_get_table_statistics(this, true, ndb, m_tabname, &stat))
== 0)
......@@ -4038,7 +4055,10 @@ static int create_ndb_column(NDBCOL &col,
HA_CREATE_INFO *info)
{
// Set name
col.setName(field->field_name);
if (col.setName(field->field_name))
{
return (my_errno= errno);
}
// Get char set
CHARSET_INFO *cs= field->charset();
// Set type and sizes
......@@ -4410,7 +4430,10 @@ int ha_ndbcluster::create(const char *name,
}
DBUG_PRINT("table", ("name: %s", m_tabname));
tab.setName(m_tabname);
if (tab.setName(m_tabname))
{
DBUG_RETURN(my_errno= errno);
}
tab.setLogging(!(create_info->options & HA_LEX_CREATE_TMP_TABLE));
// Save frm data for this table
......@@ -4435,7 +4458,10 @@ int ha_ndbcluster::create(const char *name,
field->pack_length()));
if ((my_errno= create_ndb_column(col, field, create_info)))
DBUG_RETURN(my_errno);
tab.addColumn(col);
if (tab.addColumn(col))
{
DBUG_RETURN(my_errno= errno);
}
if (col.getPrimaryKey())
pk_length += (field->pack_length() + 3) / 4;
}
......@@ -4444,13 +4470,19 @@ int ha_ndbcluster::create(const char *name,
if (form->s->primary_key == MAX_KEY)
{
DBUG_PRINT("info", ("Generating shadow key"));
col.setName("$PK");
if (col.setName("$PK"))
{
DBUG_RETURN(my_errno= errno);
}
col.setType(NdbDictionary::Column::Bigunsigned);
col.setLength(1);
col.setNullable(FALSE);
col.setPrimaryKey(TRUE);
col.setAutoIncrement(TRUE);
tab.addColumn(col);
if (tab.addColumn(col))
{
DBUG_RETURN(my_errno= errno);
}
pk_length += 2;
}
......@@ -4556,13 +4588,19 @@ int ha_ndbcluster::create_index(const char *name,
// TODO Only temporary ordered indexes supported
ndb_index.setLogging(FALSE);
}
ndb_index.setTable(m_tabname);
if (ndb_index.setTable(m_tabname))
{
DBUG_RETURN(my_errno= errno);
}
for (; key_part != end; key_part++)
{
Field *field= key_part->field;
DBUG_PRINT("info", ("attr: %s", field->field_name));
ndb_index.addColumnName(field->field_name);
if (ndb_index.addColumnName(field->field_name))
{
DBUG_RETURN(my_errno= errno);
}
}
if (dict->createIndex(ndb_index))
......@@ -4617,7 +4655,10 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
m_table= (void *)orig_tab;
// Change current database to that of target table
set_dbname(to);
ndb->setDatabaseName(m_dbname);
if (ndb->setDatabaseName(m_dbname))
{
ERR_RETURN(ndb->getNdbError());
}
if (!(result= alter_table_name(new_tabname)))
{
// Rename .ndb file
......@@ -4636,10 +4677,16 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
for (unsigned i = 0; i < index_list.count; i++) {
NDBDICT::List::Element& index_el = index_list.elements[i];
set_dbname(from);
ndb->setDatabaseName(m_dbname);
if (ndb->setDatabaseName(m_dbname))
{
ERR_RETURN(ndb->getNdbError());
}
const NDBINDEX * index= dict->getIndex(index_el.name, *new_tab);
set_dbname(to);
ndb->setDatabaseName(m_dbname);
if (ndb->setDatabaseName(m_dbname))
{
ERR_RETURN(ndb->getNdbError());
}
DBUG_PRINT("info", ("Creating index %s/%s",
m_dbname, index->getName()));
dict->createIndex(*index);
......@@ -4647,7 +4694,10 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
m_dbname, index->getName()));
set_dbname(from);
ndb->setDatabaseName(m_dbname);
if (ndb->setDatabaseName(m_dbname))
{
ERR_RETURN(ndb->getNdbError());
}
dict->dropIndex(*index);
}
}
......@@ -4668,7 +4718,10 @@ int ha_ndbcluster::alter_table_name(const char *to)
DBUG_ENTER("alter_table_name_table");
NdbDictionary::Table new_tab= *orig_tab;
new_tab.setName(to);
if (new_tab.setName(to))
{
DBUG_RETURN(my_errno= errno);
}
if (dict->alterTable(new_tab) != 0)
ERR_RETURN(dict->getNdbError());
......@@ -4914,7 +4967,10 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked)
if (!res)
{
Ndb *ndb= get_ndb();
ndb->setDatabaseName(m_dbname);
if (ndb->setDatabaseName(m_dbname))
{
ERR_RETURN(ndb->getNdbError());
}
struct Ndb_statistics stat;
res= ndb_get_table_statistics(NULL, false, ndb, m_tabname, &stat);
records= stat.row_count;
......@@ -4946,6 +5002,11 @@ Thd_ndb* ha_ndbcluster::seize_thd_ndb()
DBUG_ENTER("seize_thd_ndb");
thd_ndb= new Thd_ndb();
if (thd_ndb == NULL)
{
my_errno= HA_ERR_OUT_OF_MEM;
return NULL;
}
thd_ndb->ndb->getDictionary()->set_local_table_data_size(
sizeof(Ndb_local_table_statistics)
);
......@@ -5001,7 +5062,10 @@ int ha_ndbcluster::check_ndb_connection(THD* thd)
if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(HA_ERR_NO_CONNECTION);
ndb->setDatabaseName(m_dbname);
if (ndb->setDatabaseName(m_dbname))
{
ERR_RETURN(ndb->getNdbError());
}
DBUG_RETURN(0);
}
......@@ -5035,8 +5099,10 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name,
if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(HA_ERR_NO_CONNECTION);
ndb->setDatabaseName(db);
if (ndb->setDatabaseName(db))
{
ERR_RETURN(ndb->getNdbError());
}
NDBDICT* dict= ndb->getDictionary();
dict->set_local_table_data_size(sizeof(Ndb_local_table_statistics));
dict->invalidateTable(name);
......@@ -5082,8 +5148,10 @@ int ndbcluster_table_exists_in_engine(THD* thd, const char *db, const char *name
if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(HA_ERR_NO_CONNECTION);
ndb->setDatabaseName(db);
if (ndb->setDatabaseName(db))
{
ERR_RETURN(ndb->getNdbError());
}
NDBDICT* dict= ndb->getDictionary();
dict->set_local_table_data_size(sizeof(Ndb_local_table_statistics));
dict->invalidateTable(name);
......@@ -5144,7 +5212,10 @@ int ndbcluster_drop_database(const char *path)
drop_list.push_back(thd->strdup(t.name));
}
// Drop any tables belonging to database
ndb->setDatabaseName(dbname);
if (ndb->setDatabaseName(dbname))
{
ERR_RETURN(ndb->getNdbError());
}
List_iterator_fast<char> it(drop_list);
while ((tabname=it++))
{
......@@ -5373,6 +5444,7 @@ bool ndbcluster_init()
{
DBUG_PRINT("error",("Ndb_cluster_connection(%s)",
opt_ndbcluster_connectstring));
my_errno= HA_ERR_OUT_OF_MEM;
goto ndbcluster_init_error;
}
{
......@@ -5387,6 +5459,7 @@ bool ndbcluster_init()
if ( (g_ndb= new Ndb(g_ndb_cluster_connection, "sys")) == 0 )
{
DBUG_PRINT("error", ("failed to create global ndb object"));
my_errno= HA_ERR_OUT_OF_MEM;
goto ndbcluster_init_error;
}
g_ndb->getDictionary()->set_local_table_data_size(sizeof(Ndb_local_table_statistics));
......@@ -5742,7 +5815,10 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
Ndb *ndb;
if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(1);
ndb->setDatabaseName(dbname);
if (ndb->setDatabaseName(dbname))
{
ERR_RETURN(ndb->getNdbError());
}
uint lock= share->commit_count_lock;
pthread_mutex_unlock(&share->mutex);
......@@ -5955,6 +6031,8 @@ static NDB_SHARE* get_share(const char *table_name)
{
DBUG_PRINT("error", ("Failed to alloc share"));
pthread_mutex_unlock(&ndbcluster_mutex);
sql_print_error("get_share: my_malloc(%u) failed",
(unsigned int)(sizeof(*share)+length+1));
return 0;
}
}
......@@ -6015,7 +6093,11 @@ static int packfrm(const void *data, uint len,
error= 1;
org_len= len;
if (my_compress((byte*)data, &org_len, &comp_len))
{
sql_print_error("packfrm: my_compress(org_len: %u)",
(unsigned int)org_len);
goto err;
}
DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", org_len, comp_len));
DBUG_DUMP("compressed", (char*)data, org_len);
......@@ -6023,8 +6105,10 @@ static int packfrm(const void *data, uint len,
error= 2;
blob_len= sizeof(frm_blob_struct::frm_blob_header)+org_len;
if (!(blob= (frm_blob_struct*) my_malloc(blob_len,MYF(MY_WME))))
{
sql_print_error("packfrm: my_malloc(%u)", blob_len);
goto err;
}
// Store compressed blob in machine independent format
int4store((char*)(&blob->head.ver), 1);
int4store((char*)(&blob->head.orglen), comp_len);
......@@ -6062,14 +6146,23 @@ static int unpackfrm(const void **unpack_data, uint *unpack_len,
DBUG_DUMP("blob->data", (char*) blob->data, complen);
if (ver != 1)
{
sql_print_error("unpackfrm: ver != 1");
DBUG_RETURN(1);
}
if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
DBUG_RETURN(2);
{
sql_print_error("unpackfrm: my_malloc(%u)",
(unsigned int)max(orglen, complen));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
memcpy(data, blob->data, complen);
if (my_uncompress(data, &complen, &orglen))
{
my_free((char*)data, MYF(0));
sql_print_error("unpackfrm: my_uncompress(complen: %u, orglen: %u)",
(unsigned int)complen, (unsigned int)orglen);
DBUG_RETURN(3);
}
......@@ -6663,7 +6756,10 @@ ha_ndbcluster::update_table_comment(
return((char*)comment);
}
ndb->setDatabaseName(m_dbname);
if (ndb->setDatabaseName(m_dbname))
{
return((char*)comment);
}
NDBDICT* dict= ndb->getDictionary();
const NDBTAB* tab;
if (!(tab= dict->getTable(m_tabname)))
......@@ -6676,6 +6772,8 @@ ha_ndbcluster::update_table_comment(
const unsigned fmt_len_plus_extra= length + strlen(fmt);
if ((str= my_malloc(fmt_len_plus_extra, MYF(0))) == NULL)
{
sql_print_error("ha_ndbcluster::update_table_comment: "
"my_malloc(%u) failed", (unsigned int)fmt_len_plus_extra);
return (char*)comment;
}
......@@ -6698,9 +6796,19 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
DBUG_PRINT("enter", ("ndb_cache_check_time: %lu", ndb_cache_check_time));
thd= new THD; /* note that contructor of THD uses DBUG_ */
if (thd == NULL)
{
my_errno= HA_ERR_OUT_OF_MEM;
DBUG_RETURN(NULL);
}
THD_CHECK_SENTRY(thd);
ndb= new Ndb(g_ndb_cluster_connection, "");
if (ndb == NULL)
{
thd->cleanup();
delete thd;
DBUG_RETURN(NULL);
}
pthread_detach_this_thread();
ndb_util_thread= pthread_self();
......@@ -6789,14 +6897,15 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
share->table_name));
/* Contact NDB to get commit count for table */
ndb->setDatabaseName(db);
struct Ndb_statistics stat;
uint lock;
pthread_mutex_lock(&share->mutex);
lock= share->commit_count_lock;
pthread_mutex_unlock(&share->mutex);
if (ndb->setDatabaseName(db))
{
goto loop_next;
}
if (ndb_get_table_statistics(NULL, false, ndb, tabname, &stat) == 0)
{
#ifndef DBUG_OFF
......@@ -6815,7 +6924,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
share->table_name));
stat.commit_count= 0;
}
loop_next:
pthread_mutex_lock(&share->mutex);
if (share->commit_count_lock == lock)
share->commit_count= stat.commit_count;
......@@ -6884,6 +6993,11 @@ ha_ndbcluster::cond_push(const COND *cond)
{
DBUG_ENTER("cond_push");
Ndb_cond_stack *ndb_cond = new Ndb_cond_stack();
if (ndb_cond == NULL)
{
my_errno= HA_ERR_OUT_OF_MEM;
DBUG_RETURN(NULL);
}
DBUG_EXECUTE("where",print_where((COND *)cond, m_tabname););
if (m_cond_stack)
ndb_cond->next= m_cond_stack;
......
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