Commit 2776a71b authored by unknown's avatar unknown
Browse files

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
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
/* 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;
}
+103 −21
Original line number Diff line number Diff line
@@ -480,7 +480,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_table, &stat);
    if (result == 0)
    {
@@ -874,6 +877,9 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array,
      DBUG_PRINT("info", ("allocate blobs buffer size %u", offset));
      buffer= my_malloc(offset, MYF(MY_WME));
      if (buffer == NULL)
      {
        sql_print_error("ha_ndbcluster::get_ndb_blobs_value: "
                        "my_malloc(%u) failed", offset);
        DBUG_RETURN(-1);
      buffer_size= offset;
    }
@@ -1066,6 +1072,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= (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* end= key_part+key_info->key_parts;
@@ -3809,7 +3821,10 @@ int ha_ndbcluster::info(uint flag)
      Ndb *ndb= get_ndb();
      ndb->setDatabaseName(m_dbname);
      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_table, &stat))
          == 0)
@@ -4565,7 +4580,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
@@ -4923,7 +4941,10 @@ int ha_ndbcluster::create(const char *name,
#endif /* HAVE_NDB_BINLOG */

  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.setSingleUserMode(single_user_mode);

@@ -4955,7 +4976,10 @@ int ha_ndbcluster::create(const char *name,
    else
      col.setStorageType(NdbDictionary::Column::StorageTypeMemory);

    tab.addColumn(col);
    if (tab.addColumn(col))
    {
      DBUG_RETURN(my_errno= errno);
    }
    if (col.getPrimaryKey())
      pk_length += (field->pack_length() + 3) / 4;
  }
@@ -4997,13 +5021,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;
  }
 
@@ -5351,13 +5381,19 @@ int ha_ndbcluster::create_ndb_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, *m_table))
@@ -5518,7 +5554,10 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
  }
  // Change current database to that of target table
  set_dbname(to);
  ndb->setDatabaseName(m_dbname);
  if (ndb->setDatabaseName(m_dbname))
  {
    ERR_RETURN(ndb->getNdbError());
  }

  NdbDictionary::Table new_tab= *orig_tab;
  new_tab.setName(new_tabname);
@@ -6092,7 +6131,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_table, &stat);
    stats.mean_rec_length= stat.row_size;
@@ -6159,6 +6201,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;
  }
  if (thd_ndb->ndb->init(max_transactions) != 0)
  {
    ERR_PRINT(thd_ndb->ndb->getNdbError());
@@ -6211,7 +6258,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);
}

@@ -6249,7 +6299,10 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db,

  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();
  build_table_filename(key, sizeof(key), db, name, "", 0);
  /* ndb_share reference temporary */
@@ -6350,7 +6403,6 @@ int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd,

  if (!(ndb= check_ndb_in_thd(thd)))
    DBUG_RETURN(HA_ERR_NO_CONNECTION);

  NDBDICT* dict= ndb->getDictionary();
  NdbDictionary::Dictionary::List list;
  if (dict->listObjects(list, NdbDictionary::Object::UserTable) != 0)
@@ -6420,8 +6472,10 @@ int ndbcluster_drop_database_impl(const char *path)
  char full_path[FN_REFLEN];
  char *tmp= full_path +
    build_table_filename(full_path, sizeof(full_path), dbname, "", "", 0);

  ndb->setDatabaseName(dbname);
  if (ndb->setDatabaseName(dbname))
  {
    ERR_RETURN(ndb->getNdbError());
  }
  List_iterator_fast<char> it(drop_list);
  while ((tabname=it++))
  {
@@ -6912,6 +6966,7 @@ static int ndbcluster_init(void *p)
  {
    DBUG_PRINT("error",("Ndb_cluster_connection(%s)",
                        opt_ndbcluster_connectstring));
    my_errno= HA_ERR_OUT_OF_MEM;
    goto ndbcluster_init_error;
  }
  {
@@ -6926,6 +6981,7 @@ static int ndbcluster_init(void *p)
  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;
  }
  if (g_ndb->init() != 0)
@@ -7418,7 +7474,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);

@@ -8634,7 +8693,10 @@ ha_ndbcluster::update_table_comment(
    return((char*)comment);
  }

  ndb->setDatabaseName(m_dbname);
  if (ndb->setDatabaseName(m_dbname))
  {
    return((char*)comment);
  }
  const NDBTAB* tab= m_table;
  DBUG_ASSERT(tab != NULL);

@@ -8643,6 +8705,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;
  }

@@ -8669,8 +8733,18 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
   pthread_mutex_lock(&LOCK_ndb_util_thread);

  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);

  if (ndb == NULL)
  {
    thd->cleanup();
    delete thd;
    DBUG_RETURN(NULL);
  }
  pthread_detach_this_thread();
  ndb_util_thread= pthread_self();

@@ -8843,7 +8917,10 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
      pthread_mutex_lock(&share->mutex);
      lock= share->commit_count_lock;
      pthread_mutex_unlock(&share->mutex);

      if (ndb->setDatabaseName(db))
      {
        goto loop_next;
      }
      {
        /* Contact NDB to get commit count for table */
        Ndb* ndb= thd_ndb->ndb;
@@ -8870,7 +8947,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
          stat.commit_count= 0;
        }
      }

  loop_next:
      pthread_mutex_lock(&share->mutex);
      if (share->commit_count_lock == lock)
        share->commit_count= stat.commit_count;
@@ -8950,6 +9027,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;
+16 −4
Original line number Diff line number Diff line
@@ -1055,6 +1055,18 @@ class Ndb
  friend class NdbDictInterface;
  friend class NdbBlob;
  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

public:
@@ -1104,7 +1116,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.
@@ -1118,7 +1130,7 @@ public:
   *
   * @param aSchemaName is the new name of the current schema
   */
  void setSchemaName(const char * aSchemaName);
  int setSchemaName(const char * aSchemaName);
#endif

  /**
@@ -1133,7 +1145,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.
@@ -1147,7 +1159,7 @@ public:
   *
   * @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
  /** Set database and schema name to match previously retrieved table
+12 −12
Original line number Diff line number Diff line
@@ -429,7 +429,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
@@ -520,7 +520,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;
@@ -759,13 +759,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.
@@ -854,7 +854,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 array of fragment information containing
@@ -1099,26 +1099,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
    /**
@@ -1127,7 +1127,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

    /**
@@ -1135,7 +1135,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
    /**
@@ -1144,7 +1144,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

    /**
+2 −2
Original line number Diff line number Diff line
@@ -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&);

Loading