Commit 2776a71b authored by unknown's avatar unknown

Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.0-ndb

into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-single-user


storage/ndb/src/ndbapi/NdbImpl.hpp:
  Auto merged
storage/ndb/src/ndbapi/NdbOperation.cpp:
  Auto merged
storage/ndb/src/ndbapi/NdbRecAttr.cpp:
  Auto merged
storage/ndb/src/ndbapi/NdbReceiver.cpp:
  Auto merged
storage/ndb/src/ndbapi/NdbScanFilter.cpp:
  Auto merged
storage/ndb/include/ndbapi/NdbReceiver.hpp:
  Auto merged
storage/ndb/include/ndbapi/NdbTransaction.hpp:
  Auto merged
storage/ndb/include/util/BaseString.hpp:
  Auto merged
storage/ndb/src/common/util/BaseString.cpp:
  Auto merged
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
  Auto merged
storage/ndb/src/ndbapi/NdbTransaction.cpp:
  Auto merged
storage/ndb/src/ndbapi/Ndbif.cpp:
  Auto merged
storage/ndb/src/ndbapi/Ndblist.cpp:
  Auto merged
storage/ndb/src/ndbapi/SignalSender.cpp:
  Auto merged
storage/ndb/src/ndbapi/ndb_cluster_connection.cpp:
  Auto merged
storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp:
  Auto merged
sql/ha_ndbcluster.cc:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/include/ndbapi/Ndb.hpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/include/ndbapi/NdbDictionary.hpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/include/util/Vector.hpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/src/ndbapi/DictCache.cpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/src/ndbapi/DictCache.hpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/src/ndbapi/Makefile.am:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/src/ndbapi/Ndb.cpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/src/ndbapi/NdbDictionary.cpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
storage/ndb/src/ndbapi/ObjectMap.hpp:
  Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11
  - manual merge to 5.1
parents 2d0939c0 8187aaa8
/* 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;
}
...@@ -480,7 +480,10 @@ int ha_ndbcluster::records_update() ...@@ -480,7 +480,10 @@ int ha_ndbcluster::records_update()
{ {
Ndb *ndb= get_ndb(); Ndb *ndb= get_ndb();
struct Ndb_statistics stat; 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_table, &stat); result= ndb_get_table_statistics(this, TRUE, ndb, m_table, &stat);
if (result == 0) if (result == 0)
{ {
...@@ -874,6 +877,9 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array, ...@@ -874,6 +877,9 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array,
DBUG_PRINT("info", ("allocate blobs buffer size %u", offset)); DBUG_PRINT("info", ("allocate blobs buffer size %u", offset));
buffer= my_malloc(offset, MYF(MY_WME)); buffer= my_malloc(offset, MYF(MY_WME));
if (buffer == NULL) if (buffer == NULL)
{
sql_print_error("ha_ndbcluster::get_ndb_blobs_value: "
"my_malloc(%u) failed", offset);
DBUG_RETURN(-1); DBUG_RETURN(-1);
buffer_size= offset; buffer_size= offset;
} }
...@@ -1066,6 +1072,12 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data, ...@@ -1066,6 +1072,12 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
if (data.unique_index_attrid_map) if (data.unique_index_attrid_map)
my_free((char*)data.unique_index_attrid_map, MYF(0)); my_free((char*)data.unique_index_attrid_map, MYF(0));
data.unique_index_attrid_map= (uchar*)my_malloc(sz,MYF(MY_WME)); data.unique_index_attrid_map= (uchar*)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* key_part= key_info->key_part;
KEY_PART_INFO* end= key_part+key_info->key_parts; KEY_PART_INFO* end= key_part+key_info->key_parts;
...@@ -3809,7 +3821,10 @@ int ha_ndbcluster::info(uint flag) ...@@ -3809,7 +3821,10 @@ int ha_ndbcluster::info(uint flag)
Ndb *ndb= get_ndb(); Ndb *ndb= get_ndb();
ndb->setDatabaseName(m_dbname); ndb->setDatabaseName(m_dbname);
struct Ndb_statistics stat; 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 && if (current_thd->variables.ndb_use_exact_count &&
(result= ndb_get_table_statistics(this, TRUE, ndb, m_table, &stat)) (result= ndb_get_table_statistics(this, TRUE, ndb, m_table, &stat))
== 0) == 0)
...@@ -4565,7 +4580,10 @@ static int create_ndb_column(NDBCOL &col, ...@@ -4565,7 +4580,10 @@ static int create_ndb_column(NDBCOL &col,
HA_CREATE_INFO *info) HA_CREATE_INFO *info)
{ {
// Set name // Set name
col.setName(field->field_name); if (col.setName(field->field_name))
{
return (my_errno= errno);
}
// Get char set // Get char set
CHARSET_INFO *cs= field->charset(); CHARSET_INFO *cs= field->charset();
// Set type and sizes // Set type and sizes
...@@ -4923,7 +4941,10 @@ int ha_ndbcluster::create(const char *name, ...@@ -4923,7 +4941,10 @@ int ha_ndbcluster::create(const char *name,
#endif /* HAVE_NDB_BINLOG */ #endif /* HAVE_NDB_BINLOG */
DBUG_PRINT("table", ("name: %s", m_tabname)); 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)); tab.setLogging(!(create_info->options & HA_LEX_CREATE_TMP_TABLE));
tab.setSingleUserMode(single_user_mode); tab.setSingleUserMode(single_user_mode);
...@@ -4955,7 +4976,10 @@ int ha_ndbcluster::create(const char *name, ...@@ -4955,7 +4976,10 @@ int ha_ndbcluster::create(const char *name,
else else
col.setStorageType(NdbDictionary::Column::StorageTypeMemory); col.setStorageType(NdbDictionary::Column::StorageTypeMemory);
tab.addColumn(col); if (tab.addColumn(col))
{
DBUG_RETURN(my_errno= errno);
}
if (col.getPrimaryKey()) if (col.getPrimaryKey())
pk_length += (field->pack_length() + 3) / 4; pk_length += (field->pack_length() + 3) / 4;
} }
...@@ -4997,13 +5021,19 @@ int ha_ndbcluster::create(const char *name, ...@@ -4997,13 +5021,19 @@ int ha_ndbcluster::create(const char *name,
if (form->s->primary_key == MAX_KEY) if (form->s->primary_key == MAX_KEY)
{ {
DBUG_PRINT("info", ("Generating shadow 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.setType(NdbDictionary::Column::Bigunsigned);
col.setLength(1); col.setLength(1);
col.setNullable(FALSE); col.setNullable(FALSE);
col.setPrimaryKey(TRUE); col.setPrimaryKey(TRUE);
col.setAutoIncrement(TRUE); col.setAutoIncrement(TRUE);
tab.addColumn(col); if (tab.addColumn(col))
{
DBUG_RETURN(my_errno= errno);
}
pk_length += 2; pk_length += 2;
} }
...@@ -5351,13 +5381,19 @@ int ha_ndbcluster::create_ndb_index(const char *name, ...@@ -5351,13 +5381,19 @@ int ha_ndbcluster::create_ndb_index(const char *name,
// TODO Only temporary ordered indexes supported // TODO Only temporary ordered indexes supported
ndb_index.setLogging(FALSE); 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++) for (; key_part != end; key_part++)
{ {
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); if (ndb_index.addColumnName(field->field_name))
{
DBUG_RETURN(my_errno= errno);
}
} }
if (dict->createIndex(ndb_index, *m_table)) if (dict->createIndex(ndb_index, *m_table))
...@@ -5518,7 +5554,10 @@ int ha_ndbcluster::rename_table(const char *from, const char *to) ...@@ -5518,7 +5554,10 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
} }
// Change current database to that of target table // Change current database to that of target table
set_dbname(to); set_dbname(to);
ndb->setDatabaseName(m_dbname); if (ndb->setDatabaseName(m_dbname))
{
ERR_RETURN(ndb->getNdbError());
}
NdbDictionary::Table new_tab= *orig_tab; NdbDictionary::Table new_tab= *orig_tab;
new_tab.setName(new_tabname); new_tab.setName(new_tabname);
...@@ -6092,7 +6131,10 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked) ...@@ -6092,7 +6131,10 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked)
if (!res) if (!res)
{ {
Ndb *ndb= get_ndb(); Ndb *ndb= get_ndb();
ndb->setDatabaseName(m_dbname); if (ndb->setDatabaseName(m_dbname))
{
ERR_RETURN(ndb->getNdbError());
}
struct Ndb_statistics stat; struct Ndb_statistics stat;
res= ndb_get_table_statistics(NULL, FALSE, ndb, m_table, &stat); res= ndb_get_table_statistics(NULL, FALSE, ndb, m_table, &stat);
stats.mean_rec_length= stat.row_size; stats.mean_rec_length= stat.row_size;
...@@ -6159,6 +6201,11 @@ Thd_ndb* ha_ndbcluster::seize_thd_ndb() ...@@ -6159,6 +6201,11 @@ Thd_ndb* ha_ndbcluster::seize_thd_ndb()
DBUG_ENTER("seize_thd_ndb"); DBUG_ENTER("seize_thd_ndb");
thd_ndb= new Thd_ndb(); thd_ndb= new Thd_ndb();
if (thd_ndb == NULL)
{
my_errno= HA_ERR_OUT_OF_MEM;
return NULL;
}
if (thd_ndb->ndb->init(max_transactions) != 0) if (thd_ndb->ndb->init(max_transactions) != 0)
{ {
ERR_PRINT(thd_ndb->ndb->getNdbError()); ERR_PRINT(thd_ndb->ndb->getNdbError());
...@@ -6211,7 +6258,10 @@ int ha_ndbcluster::check_ndb_connection(THD* thd) ...@@ -6211,7 +6258,10 @@ int ha_ndbcluster::check_ndb_connection(THD* thd)
if (!(ndb= check_ndb_in_thd(thd))) if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(HA_ERR_NO_CONNECTION); DBUG_RETURN(HA_ERR_NO_CONNECTION);
ndb->setDatabaseName(m_dbname); if (ndb->setDatabaseName(m_dbname))
{
ERR_RETURN(ndb->getNdbError());
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -6249,7 +6299,10 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db, ...@@ -6249,7 +6299,10 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db,
if (!(ndb= check_ndb_in_thd(thd))) if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(HA_ERR_NO_CONNECTION); DBUG_RETURN(HA_ERR_NO_CONNECTION);
ndb->setDatabaseName(db); if (ndb->setDatabaseName(db))
{
ERR_RETURN(ndb->getNdbError());
}
NDBDICT* dict= ndb->getDictionary(); NDBDICT* dict= ndb->getDictionary();
build_table_filename(key, sizeof(key), db, name, "", 0); build_table_filename(key, sizeof(key), db, name, "", 0);
/* ndb_share reference temporary */ /* ndb_share reference temporary */
...@@ -6350,7 +6403,6 @@ int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd, ...@@ -6350,7 +6403,6 @@ int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd,
if (!(ndb= check_ndb_in_thd(thd))) if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(HA_ERR_NO_CONNECTION); DBUG_RETURN(HA_ERR_NO_CONNECTION);
NDBDICT* dict= ndb->getDictionary(); NDBDICT* dict= ndb->getDictionary();
NdbDictionary::Dictionary::List list; NdbDictionary::Dictionary::List list;
if (dict->listObjects(list, NdbDictionary::Object::UserTable) != 0) if (dict->listObjects(list, NdbDictionary::Object::UserTable) != 0)
...@@ -6420,8 +6472,10 @@ int ndbcluster_drop_database_impl(const char *path) ...@@ -6420,8 +6472,10 @@ int ndbcluster_drop_database_impl(const char *path)
char full_path[FN_REFLEN]; char full_path[FN_REFLEN];
char *tmp= full_path + char *tmp= full_path +
build_table_filename(full_path, sizeof(full_path), dbname, "", "", 0); build_table_filename(full_path, sizeof(full_path), dbname, "", "", 0);
if (ndb->setDatabaseName(dbname))
ndb->setDatabaseName(dbname); {
ERR_RETURN(ndb->getNdbError());
}
List_iterator_fast<char> it(drop_list); List_iterator_fast<char> it(drop_list);
while ((tabname=it++)) while ((tabname=it++))
{ {
...@@ -6912,6 +6966,7 @@ static int ndbcluster_init(void *p) ...@@ -6912,6 +6966,7 @@ static int ndbcluster_init(void *p)
{ {
DBUG_PRINT("error",("Ndb_cluster_connection(%s)", DBUG_PRINT("error",("Ndb_cluster_connection(%s)",
opt_ndbcluster_connectstring)); opt_ndbcluster_connectstring));
my_errno= HA_ERR_OUT_OF_MEM;
goto ndbcluster_init_error; goto ndbcluster_init_error;
} }
{ {
...@@ -6926,6 +6981,7 @@ static int ndbcluster_init(void *p) ...@@ -6926,6 +6981,7 @@ static int ndbcluster_init(void *p)
if ( (g_ndb= new Ndb(g_ndb_cluster_connection, "sys")) == 0 ) if ( (g_ndb= new Ndb(g_ndb_cluster_connection, "sys")) == 0 )
{ {
DBUG_PRINT("error", ("failed to create global ndb object")); DBUG_PRINT("error", ("failed to create global ndb object"));
my_errno= HA_ERR_OUT_OF_MEM;
goto ndbcluster_init_error; goto ndbcluster_init_error;
} }
if (g_ndb->init() != 0) if (g_ndb->init() != 0)
...@@ -7418,7 +7474,10 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname, ...@@ -7418,7 +7474,10 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
Ndb *ndb; Ndb *ndb;
if (!(ndb= check_ndb_in_thd(thd))) if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(1); DBUG_RETURN(1);
ndb->setDatabaseName(dbname); if (ndb->setDatabaseName(dbname))
{
ERR_RETURN(ndb->getNdbError());
}
uint lock= share->commit_count_lock; uint lock= share->commit_count_lock;
pthread_mutex_unlock(&share->mutex); pthread_mutex_unlock(&share->mutex);
...@@ -8634,7 +8693,10 @@ ha_ndbcluster::update_table_comment( ...@@ -8634,7 +8693,10 @@ ha_ndbcluster::update_table_comment(
return((char*)comment); return((char*)comment);
} }
ndb->setDatabaseName(m_dbname); if (ndb->setDatabaseName(m_dbname))
{
return((char*)comment);
}
const NDBTAB* tab= m_table; const NDBTAB* tab= m_table;
DBUG_ASSERT(tab != NULL); DBUG_ASSERT(tab != NULL);
...@@ -8643,6 +8705,8 @@ ha_ndbcluster::update_table_comment( ...@@ -8643,6 +8705,8 @@ ha_ndbcluster::update_table_comment(
const unsigned fmt_len_plus_extra= length + strlen(fmt); const unsigned fmt_len_plus_extra= length + strlen(fmt);
if ((str= my_malloc(fmt_len_plus_extra, MYF(0))) == NULL) 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; return (char*)comment;
} }
...@@ -8669,8 +8733,18 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) ...@@ -8669,8 +8733,18 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
pthread_mutex_lock(&LOCK_ndb_util_thread); pthread_mutex_lock(&LOCK_ndb_util_thread);
thd= new THD; /* note that contructor of THD uses DBUG_ */ 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); THD_CHECK_SENTRY(thd);
if (ndb == NULL)
{
thd->cleanup();
delete thd;
DBUG_RETURN(NULL);
}
pthread_detach_this_thread(); pthread_detach_this_thread();
ndb_util_thread= pthread_self(); ndb_util_thread= pthread_self();
...@@ -8843,7 +8917,10 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) ...@@ -8843,7 +8917,10 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
pthread_mutex_lock(&share->mutex); pthread_mutex_lock(&share->mutex);
lock= share->commit_count_lock; lock= share->commit_count_lock;
pthread_mutex_unlock(&share->mutex); pthread_mutex_unlock(&share->mutex);
if (ndb->setDatabaseName(db))
{
goto loop_next;
}
{ {
/* Contact NDB to get commit count for table */ /* Contact NDB to get commit count for table */
Ndb* ndb= thd_ndb->ndb; Ndb* ndb= thd_ndb->ndb;
...@@ -8870,7 +8947,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) ...@@ -8870,7 +8947,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
stat.commit_count= 0; stat.commit_count= 0;
} }
} }
loop_next:
pthread_mutex_lock(&share->mutex); pthread_mutex_lock(&share->mutex);
if (share->commit_count_lock == lock) if (share->commit_count_lock == lock)
share->commit_count= stat.commit_count; share->commit_count= stat.commit_count;
...@@ -8950,6 +9027,11 @@ ha_ndbcluster::cond_push(const COND *cond) ...@@ -8950,6 +9027,11 @@ ha_ndbcluster::cond_push(const COND *cond)
{ {
DBUG_ENTER("cond_push"); DBUG_ENTER("cond_push");
Ndb_cond_stack *ndb_cond = new Ndb_cond_stack(); 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);); DBUG_EXECUTE("where",print_where((COND *)cond, m_tabname););
if (m_cond_stack) if (m_cond_stack)
ndb_cond->next= m_cond_stack; ndb_cond->next= m_cond_stack;
......
...@@ -1055,6 +1055,18 @@ class Ndb ...@@ -1055,6 +1055,18 @@ class Ndb
friend class NdbDictInterface; friend class NdbDictInterface;
friend class NdbBlob; friend class NdbBlob;
friend class NdbImpl; friend class NdbImpl;
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 #endif
public: public:
...@@ -1104,7 +1116,7 @@ public: ...@@ -1104,7 +1116,7 @@ public:
* *
* @param aCatalogName is the new name of the current catalog * @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. * The current schema name can be fetched by getSchemaName.
...@@ -1118,7 +1130,7 @@ public: ...@@ -1118,7 +1130,7 @@ public:
* *
* @param aSchemaName is the new name of the current schema * @param aSchemaName is the new name of the current schema
*/ */
void setSchemaName(const char * aSchemaName); int setSchemaName(const char * aSchemaName);
#endif #endif
/** /**
...@@ -1133,7 +1145,7 @@ public: ...@@ -1133,7 +1145,7 @@ public:
* *
* @param aDatabaseName is the new name of the current database * @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. * The current database schema name can be fetched by getDatabaseSchemaName.
...@@ -1147,7 +1159,7 @@ public: ...@@ -1147,7 +1159,7 @@ public:
* *
* @param aDatabaseSchemaName is the new name of the current database schema * @param aDatabaseSchemaName is the new name of the current database schema
*/ */
void setDatabaseSchemaName(const char * aDatabaseSchemaName); int setDatabaseSchemaName(const char * aDatabaseSchemaName);
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/** Set database and schema name to match previously retrieved table /** Set database and schema name to match previously retrieved table
......
...@@ -429,7 +429,7 @@ public: ...@@ -429,7 +429,7 @@ public:
* Set name of column * Set name of column
* @param name Name of the column * @param name Name of the column
*/ */
void setName(const char * name); int setName(const char * name);
/** /**
* Set whether column is nullable or not * Set whether column is nullable or not
...@@ -520,7 +520,7 @@ public: ...@@ -520,7 +520,7 @@ public:
void setAutoIncrement(bool); void setAutoIncrement(bool);
bool getAutoIncrement() const; bool getAutoIncrement() const;
void setAutoIncrementInitialValue(Uint64 val); void setAutoIncrementInitialValue(Uint64 val);
void setDefaultValue(const char*); int setDefaultValue(const char*);
const char* getDefaultValue() const; const char* getDefaultValue() const;
static const Column * FRAGMENT; static const Column * FRAGMENT;
...@@ -759,13 +759,13 @@ public: ...@@ -759,13 +759,13 @@ public:
* Name of table * Name of table
* @param name 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 * Add a column definition to a table
* @note creates a copy * @note creates a copy
*/ */
void addColumn(const Column &); int addColumn(const Column &);
/** /**
* @see NdbDictionary::Table::getLogging. * @see NdbDictionary::Table::getLogging.
...@@ -854,7 +854,7 @@ public: ...@@ -854,7 +854,7 @@ public:
/** /**
* Set frm file to store with this table * Set frm file to store with this table
*/ */
void setFrm(const void* data, Uint32 len); int setFrm(const void* data, Uint32 len);
/** /**
* Set array of fragment information containing * Set array of fragment information containing
...@@ -1099,26 +1099,26 @@ public: ...@@ -1099,26 +1099,26 @@ public:
/** /**
* Set the name of an index * 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 * 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 * Add a column to the index definition
* Note that the order of columns will be in * Note that the order of columns will be in
* the order they are added (only matters for ordered indexes). * 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 * Add a column name to the index definition
* Note that the order of indexes will be in * Note that the order of indexes will be in
* the order they are added (only matters for ordered indexes). * 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 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/** /**
...@@ -1127,7 +1127,7 @@ public: ...@@ -1127,7 +1127,7 @@ public:
* the order they are added (only matters for ordered indexes). * the order they are added (only matters for ordered indexes).
* Depricated, use addColumnName instead. * Depricated, use addColumnName instead.
*/ */
void addIndexColumn(const char * name); int addIndexColumn(const char * name);
#endif #endif
/** /**
...@@ -1135,7 +1135,7 @@ public: ...@@ -1135,7 +1135,7 @@ public:
* Note that the order of indexes will be in * Note that the order of indexes will be in
* the order they are added (only matters for ordered indexes). * 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 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/** /**
...@@ -1144,7 +1144,7 @@ public: ...@@ -1144,7 +1144,7 @@ public:
* the order they are added (only matters for ordered indexes). * the order they are added (only matters for ordered indexes).
* Depricated, use addColumnNames instead. * Depricated, use addColumnNames instead.
*/ */
void addIndexColumns(int noOfNames, const char ** names); int addIndexColumns(int noOfNames, const char ** names);
#endif #endif
/** /**
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
}; };
NdbReceiver(Ndb *aNdb); NdbReceiver(Ndb *aNdb);
void init(ReceiverType type, void* owner); int init(ReceiverType type, void* owner);
void release(); void release();
~NdbReceiver(); ~NdbReceiver();
...@@ -75,7 +75,7 @@ private: ...@@ -75,7 +75,7 @@ private:
* At setup * At setup
*/ */
class NdbRecAttr * getValue(const class NdbColumnImpl*, char * user_dst_ptr); 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 prepareSend();
void calculate_batch_size(Uint32, Uint32, Uint32&, Uint32&, Uint32&); void calculate_batch_size(Uint32, Uint32, Uint32&, Uint32&, Uint32&);
......
...@@ -575,7 +575,7 @@ private: ...@@ -575,7 +575,7 @@ private:
NdbTransaction(Ndb* aNdb); NdbTransaction(Ndb* aNdb);
~NdbTransaction(); ~NdbTransaction();
void init(); // Initialize connection object for new transaction int init(); // Initialize connection object for new transaction
int executeNoBlobs(ExecType execType, int executeNoBlobs(ExecType execType,
NdbOperation::AbortOption = NdbOperation::DefaultAbortOption, NdbOperation::AbortOption = NdbOperation::DefaultAbortOption,
......
...@@ -188,6 +188,7 @@ public: ...@@ -188,6 +188,7 @@ public:
private: private:
char* m_chr; char* m_chr;
unsigned m_len; unsigned m_len;
friend bool operator!(const BaseString& str);
}; };
inline const char* inline const char*
...@@ -261,6 +262,12 @@ BaseString::operator!=(const char *str) const ...@@ -261,6 +262,12 @@ BaseString::operator!=(const char *str) const
return strcmp(m_chr, str) != 0; return strcmp(m_chr, str) != 0;
} }
inline bool
operator!(const BaseString& str)
{
return str.m_chr == NULL;
}
inline BaseString& inline BaseString&
BaseString::assign(const BaseString& str) BaseString::assign(const BaseString& str)
{ {
......
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
const T& operator[](unsigned i) const; const T& operator[](unsigned i) const;
unsigned size() const { return m_size; }; unsigned size() const { return m_size; };
void push_back(const T &); int push_back(const T &);
void push(const T&, unsigned pos); void push(const T&, unsigned pos);
T& set(T&, unsigned pos, T& fill_obj); T& set(T&, unsigned pos, T& fill_obj);
T& back(); T& back();
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
void clear(); void clear();
void fill(unsigned new_size, T & obj); int fill(unsigned new_size, T & obj);
Vector<T>& operator=(const Vector<T>&); Vector<T>& operator=(const Vector<T>&);
...@@ -54,6 +54,14 @@ private: ...@@ -54,6 +54,14 @@ private:
template<class T> template<class T>
Vector<T>::Vector(int i){ Vector<T>::Vector(int i){
m_items = new T[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_size = 0;
m_arraySize = i; m_arraySize = i;
m_incSize = 50; m_incSize = 50;
...@@ -91,12 +99,15 @@ Vector<T>::back(){ ...@@ -91,12 +99,15 @@ Vector<T>::back(){
} }
template<class T> template<class T>
void int
Vector<T>::push_back(const T & t){ Vector<T>::push_back(const T & t){
if(m_size == m_arraySize){ if(m_size == m_arraySize){
T * tmp = new T [m_arraySize + m_incSize]; T * tmp = new T [m_arraySize + m_incSize];
if(!tmp) if(tmp == NULL)
abort(); {
errno = ENOMEM;
return -1;
}
for (unsigned k = 0; k < m_size; k++) for (unsigned k = 0; k < m_size; k++)
tmp[k] = m_items[k]; tmp[k] = m_items[k];
delete[] m_items; delete[] m_items;
...@@ -150,10 +161,12 @@ Vector<T>::clear(){ ...@@ -150,10 +161,12 @@ Vector<T>::clear(){
} }
template<class T> template<class T>
void int
Vector<T>::fill(unsigned new_size, T & obj){ Vector<T>::fill(unsigned new_size, T & obj){
while(m_size <= new_size) while(m_size <= new_size)
push_back(obj); if (push_back(obj))
return -1;
return 0;
} }
template<class T> template<class T>
...@@ -177,8 +190,8 @@ struct MutexVector : public NdbLockable { ...@@ -177,8 +190,8 @@ struct MutexVector : public NdbLockable {
const T& operator[](unsigned i) const; const T& operator[](unsigned i) const;
unsigned size() const { return m_size; }; unsigned size() const { return m_size; };
void push_back(const T &); int push_back(const T &);
void push_back(const T &, bool lockMutex); int push_back(const T &, bool lockMutex);
T& back(); T& back();
void erase(unsigned index); void erase(unsigned index);
...@@ -187,7 +200,7 @@ struct MutexVector : public NdbLockable { ...@@ -187,7 +200,7 @@ struct MutexVector : public NdbLockable {
void clear(); void clear();
void clear(bool lockMutex); void clear(bool lockMutex);
void fill(unsigned new_size, T & obj); int fill(unsigned new_size, T & obj);
private: private:
T * m_items; T * m_items;
unsigned m_size; unsigned m_size;
...@@ -198,6 +211,14 @@ private: ...@@ -198,6 +211,14 @@ private:
template<class T> template<class T>
MutexVector<T>::MutexVector(int i){ MutexVector<T>::MutexVector(int i){
m_items = new T[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_size = 0;
m_arraySize = i; m_arraySize = i;
m_incSize = 50; m_incSize = 50;
...@@ -235,11 +256,17 @@ MutexVector<T>::back(){ ...@@ -235,11 +256,17 @@ MutexVector<T>::back(){
} }
template<class T> template<class T>
void int
MutexVector<T>::push_back(const T & t){ MutexVector<T>::push_back(const T & t){
lock(); lock();
if(m_size == m_arraySize){ if(m_size == m_arraySize){
T * tmp = new T [m_arraySize + m_incSize]; T * tmp = new T [m_arraySize + m_incSize];
if (tmp == NULL)
{
errno = ENOMEM;
unlock();
return -1;
}
for (unsigned k = 0; k < m_size; k++) for (unsigned k = 0; k < m_size; k++)
tmp[k] = m_items[k]; tmp[k] = m_items[k];
delete[] m_items; delete[] m_items;
...@@ -249,15 +276,23 @@ MutexVector<T>::push_back(const T & t){ ...@@ -249,15 +276,23 @@ MutexVector<T>::push_back(const T & t){
m_items[m_size] = t; m_items[m_size] = t;
m_size++; m_size++;
unlock(); unlock();
return 0;
} }
template<class T> template<class T>
void int
MutexVector<T>::push_back(const T & t, bool lockMutex){ MutexVector<T>::push_back(const T & t, bool lockMutex){
if(lockMutex) if(lockMutex)
lock(); lock();
if(m_size == m_arraySize){ if(m_size == m_arraySize){
T * tmp = new T [m_arraySize + m_incSize]; 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++) for (unsigned k = 0; k < m_size; k++)
tmp[k] = m_items[k]; tmp[k] = m_items[k];
delete[] m_items; delete[] m_items;
...@@ -268,6 +303,7 @@ MutexVector<T>::push_back(const T & t, bool lockMutex){ ...@@ -268,6 +303,7 @@ MutexVector<T>::push_back(const T & t, bool lockMutex){
m_size++; m_size++;
if(lockMutex) if(lockMutex)
unlock(); unlock();
return 0;
} }
template<class T> template<class T>
...@@ -315,10 +351,12 @@ MutexVector<T>::clear(bool l){ ...@@ -315,10 +351,12 @@ MutexVector<T>::clear(bool l){
} }
template<class T> template<class T>
void int
MutexVector<T>::fill(unsigned new_size, T & obj){ MutexVector<T>::fill(unsigned new_size, T & obj){
while(m_size <= new_size) while(m_size <= new_size)
push_back(obj); if (push_back(obj))
return -1;
return 0;
} }
#endif #endif
...@@ -16,19 +16,36 @@ ...@@ -16,19 +16,36 @@
/* -*- c-basic-offset: 4; -*- */ /* -*- c-basic-offset: 4; -*- */
#include <ndb_global.h> #include <ndb_global.h>
#include <BaseString.hpp> #include <BaseString.hpp>
#include <basestring_vsnprintf.h> #include "basestring_vsnprintf.h"
BaseString::BaseString() BaseString::BaseString()
{ {
m_chr = new char[1]; m_chr = new char[1];
if (m_chr == NULL)
{
errno = ENOMEM;
m_len = 0;
return;
}
m_chr[0] = 0; m_chr[0] = 0;
m_len = 0; m_len = 0;
} }
BaseString::BaseString(const char* s) BaseString::BaseString(const char* s)
{ {
if (s == NULL)
{
m_chr = NULL;
m_len = 0;
}
const size_t n = strlen(s); const size_t n = strlen(s);
m_chr = new char[n + 1]; m_chr = new char[n + 1];
if (m_chr == NULL)
{
errno = ENOMEM;
m_len = 0;
return;
}
memcpy(m_chr, s, n + 1); memcpy(m_chr, s, n + 1);
m_len = n; m_len = n;
} }
...@@ -37,7 +54,20 @@ BaseString::BaseString(const BaseString& str) ...@@ -37,7 +54,20 @@ BaseString::BaseString(const BaseString& str)
{ {
const char* const s = str.m_chr; const char* const s = str.m_chr;
const size_t n = str.m_len; const size_t n = str.m_len;
if (s == NULL)
{
m_chr = NULL;
m_len = 0;
return;
}
char* t = new char[n + 1]; char* t = new char[n + 1];
if (t == NULL)
{
errno = ENOMEM;
m_chr = NULL;
m_len = 0;
return;
}
memcpy(t, s, n + 1); memcpy(t, s, n + 1);
m_chr = t; m_chr = t;
m_len = n; m_len = n;
...@@ -51,9 +81,23 @@ BaseString::~BaseString() ...@@ -51,9 +81,23 @@ BaseString::~BaseString()
BaseString& BaseString&
BaseString::assign(const char* s) 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]; char* t = new char[n + 1];
memcpy(t, s, n + 1); if (t)
{
memcpy(t, s, n + 1);
}
else
{
errno = ENOMEM;
n = 0;
}
delete[] m_chr; delete[] m_chr;
m_chr = t; m_chr = t;
m_len = n; m_len = n;
...@@ -64,8 +108,16 @@ BaseString& ...@@ -64,8 +108,16 @@ BaseString&
BaseString::assign(const char* s, size_t n) BaseString::assign(const char* s, size_t n)
{ {
char* t = new char[n + 1]; char* t = new char[n + 1];
memcpy(t, s, n); if (t)
t[n] = 0; {
memcpy(t, s, n);
t[n] = 0;
}
else
{
errno = ENOMEM;
n = 0;
}
delete[] m_chr; delete[] m_chr;
m_chr = t; m_chr = t;
m_len = n; m_len = n;
...@@ -83,10 +135,19 @@ BaseString::assign(const BaseString& str, size_t n) ...@@ -83,10 +135,19 @@ BaseString::assign(const BaseString& str, size_t n)
BaseString& BaseString&
BaseString::append(const char* s) BaseString::append(const char* s)
{ {
const size_t n = strlen(s); size_t n = strlen(s);
char* t = new char[m_len + n + 1]; char* t = new char[m_len + n + 1];
memcpy(t, m_chr, m_len); if (t)
memcpy(t + m_len, s, n + 1); {
memcpy(t, m_chr, m_len);
memcpy(t + m_len, s, n + 1);
}
else
{
errno = ENOMEM;
m_len = 0;
n = 0;
}
delete[] m_chr; delete[] m_chr;
m_chr = t; m_chr = t;
m_len += n; m_len += n;
...@@ -130,8 +191,14 @@ BaseString::assfmt(const char *fmt, ...) ...@@ -130,8 +191,14 @@ BaseString::assfmt(const char *fmt, ...)
l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1; l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
va_end(ap); va_end(ap);
if(l > (int)m_len) { if(l > (int)m_len) {
char *t = new char[l];
if (t == NULL)
{
errno = ENOMEM;
return *this;
}
delete[] m_chr; delete[] m_chr;
m_chr = new char[l]; m_chr = t;
} }
va_start(ap, fmt); va_start(ap, fmt);
basestring_vsnprintf(m_chr, l, fmt, ap); basestring_vsnprintf(m_chr, l, fmt, ap);
...@@ -155,6 +222,11 @@ BaseString::appfmt(const char *fmt, ...) ...@@ -155,6 +222,11 @@ BaseString::appfmt(const char *fmt, ...)
l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1; l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
va_end(ap); va_end(ap);
char *tmp = new char[l]; char *tmp = new char[l];
if (tmp == NULL)
{
errno = ENOMEM;
return *this;
}
va_start(ap, fmt); va_start(ap, fmt);
basestring_vsnprintf(tmp, l, fmt, ap); basestring_vsnprintf(tmp, l, fmt, ap);
va_end(ap); va_end(ap);
...@@ -242,9 +314,28 @@ BaseString::argify(const char *argv0, const char *src) { ...@@ -242,9 +314,28 @@ BaseString::argify(const char *argv0, const char *src) {
Vector<char *> vargv; Vector<char *> vargv;
if(argv0 != NULL) 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]; 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; char *dst = tmp;
const char *end = src + strlen(src); const char *end = src + strlen(src);
/* Copy characters from src to destination, while compacting them /* Copy characters from src to destination, while compacting them
...@@ -287,20 +378,48 @@ BaseString::argify(const char *argv0, const char *src) { ...@@ -287,20 +378,48 @@ BaseString::argify(const char *argv0, const char *src) {
/* Make sure the string is properly terminated */ /* Make sure the string is properly terminated */
*dst++ = '\0'; *dst++ = '\0';
src++; 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: end:
delete[] tmp; 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 /* Convert the C++ Vector into a C-vector of strings, suitable for
* calling execv(). * calling execv().
*/ */
char **argv = (char **)malloc(sizeof(*argv) * (vargv.size())); char **argv = (char **)malloc(sizeof(*argv) * (vargv.size()));
if(argv == NULL) if(argv == NULL)
{
for(size_t i = 0; i < vargv.size(); i++)
free(vargv[i]);
errno = ENOMEM;
return NULL; return NULL;
}
for(size_t i = 0; i < vargv.size(); i++){ for(size_t i = 0; i < vargv.size(); i++){
argv[i] = vargv[i]; argv[i] = vargv[i];
......
...@@ -154,7 +154,7 @@ void GlobalDictCache::printCache() ...@@ -154,7 +154,7 @@ void GlobalDictCache::printCache()
} }
NdbTableImpl * NdbTableImpl *
GlobalDictCache::get(const char * name) GlobalDictCache::get(const char * name, int *error)
{ {
DBUG_ENTER("GlobalDictCache::get"); DBUG_ENTER("GlobalDictCache::get");
DBUG_PRINT("enter", ("name: %s", name)); DBUG_PRINT("enter", ("name: %s", name));
...@@ -165,6 +165,11 @@ GlobalDictCache::get(const char * name) ...@@ -165,6 +165,11 @@ GlobalDictCache::get(const char * name)
versions = m_tableHash.getData(name, len); versions = m_tableHash.getData(name, len);
if(versions == 0){ if(versions == 0){
versions = new Vector<TableVersion>(2); versions = new Vector<TableVersion>(2);
if (versions == NULL)
{
*error = -1;
DBUG_RETURN(0);
}
m_tableHash.insertKey(name, len, 0, versions); m_tableHash.insertKey(name, len, 0, versions);
} }
...@@ -211,7 +216,11 @@ GlobalDictCache::get(const char * name) ...@@ -211,7 +216,11 @@ GlobalDictCache::get(const char * name)
tmp.m_impl = 0; tmp.m_impl = 0;
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); if (versions->push_back(tmp))
{
*error = -1;
DBUG_RETURN(0);
}
DBUG_PRINT("info", ("No table found")); DBUG_PRINT("info", ("No table found"));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
~GlobalDictCache(); ~GlobalDictCache();
NdbTableImpl * get(NdbTableImpl *tab); NdbTableImpl * get(NdbTableImpl *tab);
NdbTableImpl * get(const char * name); NdbTableImpl * get(const char * name, int *error);
NdbTableImpl* put(const char * name, NdbTableImpl *); NdbTableImpl* put(const char * name, NdbTableImpl *);
void release(NdbTableImpl *, int invalidate = 0); void release(NdbTableImpl *, int invalidate = 0);
......
...@@ -55,7 +55,8 @@ libndbapi_la_SOURCES = \ ...@@ -55,7 +55,8 @@ libndbapi_la_SOURCES = \
ndb_cluster_connection.cpp \ ndb_cluster_connection.cpp \
NdbBlob.cpp \ NdbBlob.cpp \
NdbIndexStat.cpp \ NdbIndexStat.cpp \
SignalSender.cpp SignalSender.cpp \
ObjectMap.cpp
INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/mgmapi INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/mgmapi
......
...@@ -436,7 +436,11 @@ Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId) ...@@ -436,7 +436,11 @@ Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId)
theRemainingStartTransactions--; theRemainingStartTransactions--;
NdbTransaction* tConNext = theTransactionList; NdbTransaction* tConNext = theTransactionList;
tConnection->init(); if (tConnection->init())
{
theError.code = tConnection->theError.code;
DBUG_RETURN(NULL);
}
theTransactionList = tConnection; // into a transaction list. theTransactionList = tConnection; // into a transaction list.
tConnection->next(tConNext); // Add the active connection object tConnection->next(tConNext); // Add the active connection object
tConnection->setTransactionId(tFirstTransId); tConnection->setTransactionId(tFirstTransId);
...@@ -1200,13 +1204,18 @@ const char * Ndb::getCatalogName() const ...@@ -1200,13 +1204,18 @@ const char * Ndb::getCatalogName() const
return theImpl->m_dbname.c_str(); return theImpl->m_dbname.c_str();
} }
void Ndb::setCatalogName(const char * a_catalog_name) int Ndb::setCatalogName(const char * a_catalog_name)
{ {
// TODO can table_name_separator be escaped? // TODO can table_name_separator be escaped?
if (a_catalog_name && ! strchr(a_catalog_name, table_name_separator)) { if (a_catalog_name && ! strchr(a_catalog_name, table_name_separator)) {
theImpl->m_dbname.assign(a_catalog_name); if (!theImpl->m_dbname.assign(a_catalog_name) ||
theImpl->update_prefix(); theImpl->update_prefix())
{
theError.code = 4000;
return -1;
}
} }
return 0;
} }
const char * Ndb::getSchemaName() const const char * Ndb::getSchemaName() const
...@@ -1214,12 +1223,16 @@ const char * Ndb::getSchemaName() const ...@@ -1214,12 +1223,16 @@ const char * Ndb::getSchemaName() const
return theImpl->m_schemaname.c_str(); return theImpl->m_schemaname.c_str();
} }
void Ndb::setSchemaName(const char * a_schema_name) int Ndb::setSchemaName(const char * a_schema_name)
{ {
// TODO can table_name_separator be escaped? // TODO can table_name_separator be escaped?
if (a_schema_name && ! strchr(a_schema_name, table_name_separator)) { if (a_schema_name && ! strchr(a_schema_name, table_name_separator)) {
theImpl->m_schemaname.assign(a_schema_name); if (!theImpl->m_schemaname.assign(a_schema_name) ||
theImpl->update_prefix(); theImpl->update_prefix())
{
theError.code = 4000;
return -1;
}
} }
} }
// </internal> // </internal>
...@@ -1229,9 +1242,9 @@ const char * Ndb::getDatabaseName() const ...@@ -1229,9 +1242,9 @@ const char * Ndb::getDatabaseName() const
return getCatalogName(); 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 const char * Ndb::getDatabaseSchemaName() const
...@@ -1239,9 +1252,9 @@ const char * Ndb::getDatabaseSchemaName() const ...@@ -1239,9 +1252,9 @@ const char * Ndb::getDatabaseSchemaName() const
return getSchemaName(); 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);
} }
int Ndb::setDatabaseAndSchemaName(const NdbDictionary::Table* t) int Ndb::setDatabaseAndSchemaName(const NdbDictionary::Table* t)
...@@ -1411,6 +1424,11 @@ const BaseString ...@@ -1411,6 +1424,11 @@ const BaseString
Ndb::getDatabaseFromInternalName(const char * internalName) Ndb::getDatabaseFromInternalName(const char * internalName)
{ {
char * databaseName = new char[strlen(internalName) + 1]; char * databaseName = new char[strlen(internalName) + 1];
if (databaseName == NULL)
{
errno = ENOMEM;
return BaseString(NULL);
}
strcpy(databaseName, internalName); strcpy(databaseName, internalName);
register char *ptr = databaseName; register char *ptr = databaseName;
...@@ -1427,6 +1445,11 @@ const BaseString ...@@ -1427,6 +1445,11 @@ const BaseString
Ndb::getSchemaFromInternalName(const char * internalName) Ndb::getSchemaFromInternalName(const char * internalName)
{ {
char * schemaName = new char[strlen(internalName)]; char * schemaName = new char[strlen(internalName)];
if (schemaName == NULL)
{
errno = ENOMEM;
return BaseString(NULL);
}
register const char *ptr1 = internalName; register const char *ptr1 = internalName;
/* Scan name for the second table_name_separator */ /* Scan name for the second table_name_separator */
......
...@@ -78,9 +78,9 @@ NdbDictionary::Column::operator=(const NdbDictionary::Column& column) ...@@ -78,9 +78,9 @@ NdbDictionary::Column::operator=(const NdbDictionary::Column& column)
return *this; return *this;
} }
void int
NdbDictionary::Column::setName(const char * name){ NdbDictionary::Column::setName(const char * name){
m_impl.m_name.assign(name); return !m_impl.m_name.assign(name);
} }
const char* const char*
...@@ -234,10 +234,10 @@ NdbDictionary::Column::setAutoIncrementInitialValue(Uint64 val){ ...@@ -234,10 +234,10 @@ NdbDictionary::Column::setAutoIncrementInitialValue(Uint64 val){
m_impl.m_autoIncrementInitialValue = val; m_impl.m_autoIncrementInitialValue = val;
} }
void int
NdbDictionary::Column::setDefaultValue(const char* defaultValue) NdbDictionary::Column::setDefaultValue(const char* defaultValue)
{ {
m_impl.m_defaultValue.assign(defaultValue); return !m_impl.m_defaultValue.assign(defaultValue);
} }
const char* const char*
...@@ -327,9 +327,9 @@ NdbDictionary::Table::operator=(const NdbDictionary::Table& table) ...@@ -327,9 +327,9 @@ NdbDictionary::Table::operator=(const NdbDictionary::Table& table)
return *this; return *this;
} }
void int
NdbDictionary::Table::setName(const char * name){ NdbDictionary::Table::setName(const char * name){
m_impl.setName(name); return m_impl.setName(name);
} }
const char * const char *
...@@ -347,12 +347,24 @@ NdbDictionary::Table::getTableId() const { ...@@ -347,12 +347,24 @@ NdbDictionary::Table::getTableId() const {
return m_impl.m_id; return m_impl.m_id;
} }
void int
NdbDictionary::Table::addColumn(const Column & c){ NdbDictionary::Table::addColumn(const Column & c){
NdbColumnImpl* col = new NdbColumnImpl; NdbColumnImpl* col = new NdbColumnImpl;
if (col == NULL)
{
errno = ENOMEM;
return -1;
}
(* col) = NdbColumnImpl::getImpl(c); (* col) = NdbColumnImpl::getImpl(c);
m_impl.m_columns.push_back(col); if (m_impl.m_columns.push_back(col))
m_impl.buildColumnHash(); {
return -1;
}
if (m_impl.buildColumnHash())
{
return -1;
}
return 0;
} }
const NdbDictionary::Column* const NdbDictionary::Column*
...@@ -549,9 +561,9 @@ NdbDictionary::Table::getFragmentCount() const ...@@ -549,9 +561,9 @@ NdbDictionary::Table::getFragmentCount() const
return m_impl.getFragmentCount(); return m_impl.getFragmentCount();
} }
void int
NdbDictionary::Table::setFrm(const void* data, Uint32 len){ NdbDictionary::Table::setFrm(const void* data, Uint32 len){
m_impl.setFrm(data, len); return m_impl.setFrm(data, len);
} }
const void* const void*
...@@ -731,6 +743,7 @@ NdbDictionary::Table::validate(NdbError& error) ...@@ -731,6 +743,7 @@ NdbDictionary::Table::validate(NdbError& error)
/***************************************************************** /*****************************************************************
* Index facade * Index facade
*/ */
NdbDictionary::Index::Index(const char * name) NdbDictionary::Index::Index(const char * name)
: m_impl(* new NdbIndexImpl(* this)) : m_impl(* new NdbIndexImpl(* this))
{ {
...@@ -749,9 +762,9 @@ NdbDictionary::Index::~Index(){ ...@@ -749,9 +762,9 @@ NdbDictionary::Index::~Index(){
} }
} }
void int
NdbDictionary::Index::setName(const char * name){ NdbDictionary::Index::setName(const char * name){
m_impl.setName(name); return m_impl.setName(name);
} }
const char * const char *
...@@ -759,9 +772,9 @@ NdbDictionary::Index::getName() const { ...@@ -759,9 +772,9 @@ NdbDictionary::Index::getName() const {
return m_impl.getName(); return m_impl.getName();
} }
void int
NdbDictionary::Index::setTable(const char * table){ NdbDictionary::Index::setTable(const char * table){
m_impl.setTable(table); return m_impl.setTable(table);
} }
const char * const char *
...@@ -796,39 +809,56 @@ NdbDictionary::Index::getIndexColumn(int no) const { ...@@ -796,39 +809,56 @@ NdbDictionary::Index::getIndexColumn(int no) const {
return NULL; return NULL;
} }
void int
NdbDictionary::Index::addColumn(const Column & c){ NdbDictionary::Index::addColumn(const Column & c){
NdbColumnImpl* col = new NdbColumnImpl; NdbColumnImpl* col = new NdbColumnImpl;
if (col == NULL)
{
errno = ENOMEM;
return -1;
}
(* col) = NdbColumnImpl::getImpl(c); (* 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){ NdbDictionary::Index::addColumnName(const char * name){
const Column c(name); const Column c(name);
addColumn(c); return addColumn(c);
} }
void int
NdbDictionary::Index::addIndexColumn(const char * name){ NdbDictionary::Index::addIndexColumn(const char * name){
const Column c(name); const Column c(name);
addColumn(c); return addColumn(c);
} }
void int
NdbDictionary::Index::addColumnNames(unsigned noOfNames, const char ** names){ NdbDictionary::Index::addColumnNames(unsigned noOfNames, const char ** names){
for(unsigned i = 0; i < noOfNames; i++) { for(unsigned i = 0; i < noOfNames; i++) {
const Column c(names[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){ NdbDictionary::Index::addIndexColumns(int noOfNames, const char ** names){
for(int i = 0; i < noOfNames; i++) { for(int i = 0; i < noOfNames; i++) {
const Column c(names[i]); const Column c(names[i]);
addColumn(c); if (addColumn(c))
{
return -1;
}
} }
return 0;
} }
void void
......
...@@ -131,7 +131,7 @@ public: ...@@ -131,7 +131,7 @@ public:
~NdbTableImpl(); ~NdbTableImpl();
void init(); void init();
void setName(const char * name); int setName(const char * name);
const char * getName() const; const char * getName() const;
void setFragmentCount(Uint32 count); void setFragmentCount(Uint32 count);
Uint32 getFragmentCount() const; Uint32 getFragmentCount() const;
...@@ -182,7 +182,7 @@ public: ...@@ -182,7 +182,7 @@ public:
Vector<Uint32> m_columnHash; Vector<Uint32> m_columnHash;
Vector<NdbColumnImpl *> m_columns; Vector<NdbColumnImpl *> m_columns;
void computeAggregates(); void computeAggregates();
void buildColumnHash(); int buildColumnHash();
/** /**
* Fragment info * Fragment info
...@@ -232,7 +232,7 @@ public: ...@@ -232,7 +232,7 @@ public:
* Equality/assign * Equality/assign
*/ */
bool equal(const NdbTableImpl&) const; bool equal(const NdbTableImpl&) const;
void assign(const NdbTableImpl&); int assign(const NdbTableImpl&);
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);
...@@ -258,9 +258,9 @@ public: ...@@ -258,9 +258,9 @@ public:
~NdbIndexImpl(); ~NdbIndexImpl();
void init(); void init();
void setName(const char * name); int setName(const char * name);
const char * getName() const; const char * getName() const;
void setTable(const char * table); int setTable(const char * table);
const char * getTable() const; const char * getTable() const;
const NdbTableImpl * getIndexTable() const; const NdbTableImpl * getIndexTable() const;
......
...@@ -37,7 +37,7 @@ struct Ndb_free_list_t ...@@ -37,7 +37,7 @@ struct Ndb_free_list_t
Ndb_free_list_t(); 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*); T* seize(Ndb*);
void release(T*); void release(T*);
void clear(); void clear();
...@@ -86,10 +86,14 @@ public: ...@@ -86,10 +86,14 @@ public:
BaseString m_prefix; // Buffer for preformatted internal name <db>/<schema>/ 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, if (!m_prefix.assfmt("%s%c%s%c", m_dbname.c_str(), table_name_separator,
m_schemaname.c_str(), table_name_separator); m_schemaname.c_str(), table_name_separator))
{
return -1;
}
return 0;
} }
BaseString m_systemPrefix; // Buffer for preformatted for <sys>/<def>/ BaseString m_systemPrefix; // Buffer for preformatted for <sys>/<def>/
...@@ -203,7 +207,7 @@ Ndb_free_list_t<T>::~Ndb_free_list_t() ...@@ -203,7 +207,7 @@ Ndb_free_list_t<T>::~Ndb_free_list_t()
template<class T> template<class T>
inline inline
void int
Ndb_free_list_t<T>::fill(Ndb* ndb, Uint32 cnt) Ndb_free_list_t<T>::fill(Ndb* ndb, Uint32 cnt)
{ {
if (m_free_list == 0) if (m_free_list == 0)
...@@ -211,18 +215,28 @@ Ndb_free_list_t<T>::fill(Ndb* ndb, Uint32 cnt) ...@@ -211,18 +215,28 @@ Ndb_free_list_t<T>::fill(Ndb* ndb, Uint32 cnt)
m_free_cnt++; m_free_cnt++;
m_alloc_cnt++; m_alloc_cnt++;
m_free_list = new T(ndb); m_free_list = new T(ndb);
if (m_free_list == 0)
{
ndb->theError.code = 4000;
assert(false);
return -1;
}
} }
while(m_alloc_cnt < cnt) while(m_alloc_cnt < cnt)
{ {
T* obj= new T(ndb); T* obj= new T(ndb);
if(obj == 0) if(obj == 0)
return; {
ndb->theError.code = 4000;
assert(false);
return -1;
}
obj->next(m_free_list); obj->next(m_free_list);
m_free_cnt++; m_free_cnt++;
m_alloc_cnt++; m_alloc_cnt++;
m_free_list = obj; m_free_list = obj;
} }
return 0;
} }
template<class T> template<class T>
...@@ -243,7 +257,11 @@ Ndb_free_list_t<T>::seize(Ndb* ndb) ...@@ -243,7 +257,11 @@ Ndb_free_list_t<T>::seize(Ndb* ndb)
{ {
m_alloc_cnt++; m_alloc_cnt++;
} }
else
{
ndb->theError.code = 4000;
assert(false);
}
return tmp; return tmp;
} }
......
...@@ -177,7 +177,11 @@ NdbOperation::init(const NdbTableImpl* tab, NdbTransaction* myConnection){ ...@@ -177,7 +177,11 @@ NdbOperation::init(const NdbTableImpl* tab, NdbTransaction* myConnection){
tcKeyReq->scanInfo = 0; tcKeyReq->scanInfo = 0;
theKEYINFOptr = &tcKeyReq->keyInfo[0]; theKEYINFOptr = &tcKeyReq->keyInfo[0];
theATTRINFOptr = &tcKeyReq->attrInfo[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; return 0;
} }
......
...@@ -81,6 +81,7 @@ NdbRecAttr::setup(const NdbColumnImpl* anAttrInfo, char* aValue) ...@@ -81,6 +81,7 @@ NdbRecAttr::setup(const NdbColumnImpl* anAttrInfo, char* aValue)
theRef = tRef; theRef = tRef;
return 0; return 0;
} }
errno = ENOMEM;
return -1; return -1;
} }
...@@ -100,7 +101,11 @@ NdbRecAttr::copyout() ...@@ -100,7 +101,11 @@ NdbRecAttr::copyout()
NdbRecAttr * NdbRecAttr *
NdbRecAttr::clone() const { NdbRecAttr::clone() const {
NdbRecAttr * ret = new NdbRecAttr(0); NdbRecAttr * ret = new NdbRecAttr(0);
if (ret == NULL)
{
errno = ENOMEM;
return NULL;
}
ret->theAttrId = theAttrId; ret->theAttrId = theAttrId;
ret->m_size_in_bytes = m_size_in_bytes; ret->m_size_in_bytes = m_size_in_bytes;
ret->m_column = m_column; ret->m_column = m_column;
...@@ -112,6 +117,12 @@ NdbRecAttr::clone() const { ...@@ -112,6 +117,12 @@ NdbRecAttr::clone() const {
ret->theValue = 0; ret->theValue = 0;
} else { } else {
ret->theStorageX = new Uint64[((n + 7) >> 3)]; ret->theStorageX = new Uint64[((n + 7) >> 3)];
if (ret->theStorageX == NULL)
{
delete ret;
errno = ENOMEM;
return NULL;
}
ret->theRef = (char*)ret->theStorageX; ret->theRef = (char*)ret->theStorageX;
ret->theValue = 0; ret->theValue = 0;
} }
......
...@@ -32,7 +32,7 @@ NdbReceiver::NdbReceiver(Ndb *aNdb) : ...@@ -32,7 +32,7 @@ NdbReceiver::NdbReceiver(Ndb *aNdb) :
{ {
theCurrentRecAttr = theFirstRecAttr = 0; theCurrentRecAttr = theFirstRecAttr = 0;
m_defined_rows = 0; m_defined_rows = 0;
m_rows = new NdbRecAttr*[0]; m_rows = NULL;
} }
NdbReceiver::~NdbReceiver() NdbReceiver::~NdbReceiver()
...@@ -45,19 +45,26 @@ NdbReceiver::~NdbReceiver() ...@@ -45,19 +45,26 @@ NdbReceiver::~NdbReceiver()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void int
NdbReceiver::init(ReceiverType type, void* owner) NdbReceiver::init(ReceiverType type, void* owner)
{ {
theMagicNumber = 0x11223344; theMagicNumber = 0x11223344;
m_type = type; m_type = type;
m_owner = owner; m_owner = owner;
theFirstRecAttr = NULL;
theCurrentRecAttr = NULL;
if (m_id == NdbObjectIdMap::InvalidId) { if (m_id == NdbObjectIdMap::InvalidId) {
if (m_ndb) if (m_ndb)
{
m_id = m_ndb->theImpl->theNdbObjectIdMap.map(this); m_id = m_ndb->theImpl->theNdbObjectIdMap.map(this);
if (m_id == NdbObjectIdMap::InvalidId)
{
setErrorCode(4000);
return -1;
}
}
} }
return 0;
theFirstRecAttr = NULL;
theCurrentRecAttr = NULL;
} }
void void
...@@ -146,7 +153,7 @@ NdbReceiver::calculate_batch_size(Uint32 key_size, ...@@ -146,7 +153,7 @@ NdbReceiver::calculate_batch_size(Uint32 key_size,
return; return;
} }
void int
NdbReceiver::do_get_value(NdbReceiver * org, NdbReceiver::do_get_value(NdbReceiver * org,
Uint32 rows, Uint32 rows,
Uint32 key_size, Uint32 key_size,
...@@ -154,7 +161,11 @@ NdbReceiver::do_get_value(NdbReceiver * org, ...@@ -154,7 +161,11 @@ NdbReceiver::do_get_value(NdbReceiver * org,
if(rows > m_defined_rows){ if(rows > m_defined_rows){
delete[] m_rows; delete[] m_rows;
m_defined_rows = 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; m_rows[rows] = 0;
...@@ -174,7 +185,7 @@ NdbReceiver::do_get_value(NdbReceiver * org, ...@@ -174,7 +185,7 @@ NdbReceiver::do_get_value(NdbReceiver * org,
// Put key-recAttr fir on each row // Put key-recAttr fir on each row
if(key_size && !getValue(&key, (char*)0)){ if(key_size && !getValue(&key, (char*)0)){
abort(); abort();
return ; // -1 return -1;
} }
if(range_no && if(range_no &&
...@@ -193,7 +204,7 @@ NdbReceiver::do_get_value(NdbReceiver * org, ...@@ -193,7 +204,7 @@ NdbReceiver::do_get_value(NdbReceiver * org,
if(tRecAttr){ if(tRecAttr){
abort(); abort();
return ;// -1; return -1;
} }
// Store first recAttr for each row in m_rows[i] // Store first recAttr for each row in m_rows[i]
...@@ -205,7 +216,7 @@ NdbReceiver::do_get_value(NdbReceiver * org, ...@@ -205,7 +216,7 @@ NdbReceiver::do_get_value(NdbReceiver * org,
} }
prepareSend(); prepareSend();
return; return 0;
} }
NdbRecAttr* NdbRecAttr*
......
...@@ -78,7 +78,11 @@ NdbScanFilter::~NdbScanFilter(){ ...@@ -78,7 +78,11 @@ NdbScanFilter::~NdbScanFilter(){
int int
NdbScanFilter::begin(Group group){ 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){ switch(group){
case NdbScanFilter::AND: case NdbScanFilter::AND:
INT_DEBUG(("Begin(AND)")); INT_DEBUG(("Begin(AND)"));
...@@ -127,7 +131,11 @@ NdbScanFilter::begin(Group group){ ...@@ -127,7 +131,11 @@ NdbScanFilter::begin(Group group){
} }
NdbScanFilterImpl::State tmp = m_impl.m_current; 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_group = group;
m_impl.m_current.m_ownLabel = m_impl.m_label++; m_impl.m_current.m_ownLabel = m_impl.m_label++;
m_impl.m_current.m_popCount = 0; m_impl.m_current.m_popCount = 0;
......
...@@ -820,9 +820,12 @@ int NdbScanOperation::prepareSendScan(Uint32 aTC_ConnectPtr, ...@@ -820,9 +820,12 @@ int NdbScanOperation::prepareSendScan(Uint32 aTC_ConnectPtr,
req->requestInfo = reqInfo; req->requestInfo = reqInfo;
for(Uint32 i = 0; i<theParallelism; i++){ 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, key_size,
m_read_range_no); m_read_range_no))
{
return -1;
}
} }
return 0; return 0;
} }
......
...@@ -81,6 +81,7 @@ NdbTransaction::NdbTransaction( Ndb* aNdb ) : ...@@ -81,6 +81,7 @@ NdbTransaction::NdbTransaction( Ndb* aNdb ) :
{ {
theListState = NotInList; theListState = NotInList;
theError.code = 0; theError.code = 0;
//theId = NdbObjectIdMap::InvalidId;
theId = theNdb->theImpl->theNdbObjectIdMap.map(this); theId = theNdb->theImpl->theNdbObjectIdMap.map(this);
#define CHECK_SZ(mask, sz) assert((sizeof(mask)/sizeof(mask[0])) == sz) #define CHECK_SZ(mask, sz) assert((sizeof(mask)/sizeof(mask[0])) == sz)
...@@ -106,7 +107,7 @@ void init(); ...@@ -106,7 +107,7 @@ void init();
Remark: Initialise connection object for new transaction. Remark: Initialise connection object for new transaction.
*****************************************************************************/ *****************************************************************************/
void int
NdbTransaction::init() NdbTransaction::init()
{ {
theListState = NotInList; theListState = NotInList;
...@@ -148,6 +149,17 @@ NdbTransaction::init() ...@@ -148,6 +149,17 @@ NdbTransaction::init()
// //
theBlobFlag = false; theBlobFlag = false;
thePendingBlobOps = 0; 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() }//NdbTransaction::init()
/***************************************************************************** /*****************************************************************************
......
...@@ -940,8 +940,9 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) ...@@ -940,8 +940,9 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3])
InvalidSignal: InvalidSignal:
#ifdef VM_TRACE #ifdef VM_TRACE
ndbout_c("Ndbif: Error Ndb::handleReceivedSignal " 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)", " sender = (Block: %d Node: %d)",
tFirstDataPtr,
tSignalNumber, tSignalNumber,
tWaitState, tWaitState,
refToBlock(aSignal->theSendersBlockRef), refToBlock(aSignal->theSendersBlockRef),
......
...@@ -74,7 +74,10 @@ Ndb::checkFailedNode() ...@@ -74,7 +74,10 @@ Ndb::checkFailedNode()
int int
Ndb::createConIdleList(int aNrOfCon) Ndb::createConIdleList(int aNrOfCon)
{ {
theImpl->theConIdleList.fill(this, aNrOfCon); if (theImpl->theConIdleList.fill(this, aNrOfCon))
{
return -1;
}
return aNrOfCon; return aNrOfCon;
} }
...@@ -90,7 +93,10 @@ Ndb::createConIdleList(int aNrOfCon) ...@@ -90,7 +93,10 @@ Ndb::createConIdleList(int aNrOfCon)
int int
Ndb::createOpIdleList(int aNrOfOp) Ndb::createOpIdleList(int aNrOfOp)
{ {
theImpl->theOpIdleList.fill(this, aNrOfOp); if (theImpl->theOpIdleList.fill(this, aNrOfOp))
{
return -1;
}
return aNrOfOp; return aNrOfOp;
} }
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
//#include <NdbMutex.h> //#include <NdbMutex.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <EventLogger.hpp>
extern EventLogger g_eventLogger;
//#define DEBUG_OBJECTMAP //#define DEBUG_OBJECTMAP
/** /**
...@@ -49,24 +52,6 @@ private: ...@@ -49,24 +52,6 @@ private:
int expand(Uint32 newSize); 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 inline
Uint32 Uint32
NdbObjectIdMap::map(void * object){ NdbObjectIdMap::map(void * object){
...@@ -100,8 +85,8 @@ NdbObjectIdMap::unmap(Uint32 id, void *object){ ...@@ -100,8 +85,8 @@ NdbObjectIdMap::unmap(Uint32 id, void *object){
m_map[i].m_next = m_firstFree; m_map[i].m_next = m_firstFree;
m_firstFree = i; m_firstFree = i;
} else { } else {
ndbout_c("Error: NdbObjectIdMap::::unmap(%u, 0x%lx) obj=0x%lx", g_eventLogger.error("NdbObjectIdMap::unmap(%u, 0x%x) obj=0x%x",
id, (long) object, (long) obj); id, (long) object, (long) obj);
DBUG_PRINT("error",("NdbObjectIdMap::unmap(%u, 0x%lx) obj=0x%lx", DBUG_PRINT("error",("NdbObjectIdMap::unmap(%u, 0x%lx) obj=0x%lx",
id, (long) object, (long) obj)); id, (long) object, (long) obj));
return 0; return 0;
...@@ -125,31 +110,4 @@ NdbObjectIdMap::getObject(Uint32 id){ ...@@ -125,31 +110,4 @@ NdbObjectIdMap::getObject(Uint32 id){
} }
return 0; 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 #endif
...@@ -137,7 +137,10 @@ SignalSender::waitFor(Uint32 timeOutMillis, T & t) ...@@ -137,7 +137,10 @@ SignalSender::waitFor(Uint32 timeOutMillis, T & t)
{ {
SimpleSignal * s = t.check(m_jobBuffer); SimpleSignal * s = t.check(m_jobBuffer);
if(s != 0){ if(s != 0){
m_usedBuffer.push_back(s); if (m_usedBuffer.push_back(s))
{
return 0;
}
return s; return s;
} }
...@@ -152,7 +155,10 @@ SignalSender::waitFor(Uint32 timeOutMillis, T & t) ...@@ -152,7 +155,10 @@ SignalSender::waitFor(Uint32 timeOutMillis, T & t)
SimpleSignal * s = t.check(m_jobBuffer); SimpleSignal * s = t.check(m_jobBuffer);
if(s != 0){ if(s != 0){
m_usedBuffer.push_back(s); if (m_usedBuffer.push_back(s))
{
return 0;
}
return s; return s;
} }
......
...@@ -419,7 +419,7 @@ Ndb_cluster_connection_impl::set_name(const char *name) ...@@ -419,7 +419,7 @@ Ndb_cluster_connection_impl::set_name(const char *name)
} }
} }
void int
Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid, Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
const ndb_mgm_configuration const ndb_mgm_configuration
&config) &config)
...@@ -465,7 +465,10 @@ Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid, ...@@ -465,7 +465,10 @@ Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
break; 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)); DBUG_PRINT("info",("saved %d %d", group,remoteNodeId));
for (int i= m_impl.m_all_nodes.size()-2; 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; i >= 0 && m_impl.m_all_nodes[i].group > m_impl.m_all_nodes[i+1].group;
...@@ -512,7 +515,7 @@ Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid, ...@@ -512,7 +515,7 @@ Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
do_test(); do_test();
#endif #endif
DBUG_VOID_RETURN; DBUG_RETURN(0);
} }
void void
...@@ -595,7 +598,11 @@ int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, ...@@ -595,7 +598,11 @@ int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds,
break; break;
m_impl.m_transporter_facade->start_instance(nodeId, props); 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; for(unsigned i=0;
i<m_impl.m_transporter_facade->get_registry()->m_transporter_interface.size(); i<m_impl.m_transporter_facade->get_registry()->m_transporter_interface.size();
......
...@@ -66,7 +66,7 @@ private: ...@@ -66,7 +66,7 @@ private:
}; };
Vector<Node> m_all_nodes; 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 connect_thread();
void set_name(const char *name); void set_name(const char *name);
......
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