Commit 341d8aae authored by unknown's avatar unknown

Merge msvensson@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb

into neptunus.(none):/home/magnus/mysql/mysql-4.1-ndb


BitKeeper/etc/logging_ok:
  auto-union
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_ndbcluster.h:
  Auto merged
parents f6f7af7a 4caff3fe
...@@ -698,11 +698,11 @@ int ha_ndbcluster::get_metadata(const char *path) ...@@ -698,11 +698,11 @@ int ha_ndbcluster::get_metadata(const char *path)
int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
{ {
uint i;
int error= 0; int error= 0;
char *name; const char *name, *index_name;
const char *index_name; char unique_index_name[FN_LEN];
static const char* unique_suffix= "$unique"; static const char* unique_suffix= "$unique";
uint i, name_len;
KEY* key_info= tab->key_info; KEY* key_info= tab->key_info;
const char **key_name= tab->keynames.type_names; const char **key_name= tab->keynames.type_names;
NdbDictionary::Dictionary *dict= m_ndb->getDictionary(); NdbDictionary::Dictionary *dict= m_ndb->getDictionary();
...@@ -716,21 +716,15 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) ...@@ -716,21 +716,15 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
m_index[i].type= idx_type; m_index[i].type= idx_type;
if (idx_type == UNIQUE_ORDERED_INDEX || idx_type == UNIQUE_INDEX) if (idx_type == UNIQUE_ORDERED_INDEX || idx_type == UNIQUE_INDEX)
{ {
name_len= strlen(index_name)+strlen(unique_suffix)+1; strxnmov(unique_index_name, FN_LEN, index_name, unique_suffix, NullS);
// Create name for unique index by appending "$unique"; DBUG_PRINT("info", ("Created unique index name \'%s\' for index %d",
if (!(name= my_malloc(name_len, MYF(MY_WME)))) unique_index_name, i));
DBUG_RETURN(2);
strxnmov(name, name_len, index_name, unique_suffix, NullS);
m_index[i].unique_name= name;
DBUG_PRINT("info", ("Created unique index name: %s for index %d",
name, i));
} }
// Create secondary indexes if in create phase // Create secondary indexes if in create phase
if (phase == ILBP_CREATE) if (phase == ILBP_CREATE)
{ {
DBUG_PRINT("info", ("Creating index %u: %s", i, index_name)); DBUG_PRINT("info", ("Creating index %u: %s", i, index_name));
switch (idx_type){
switch (m_index[i].type){
case PRIMARY_KEY_INDEX: case PRIMARY_KEY_INDEX:
// Do nothing, already created // Do nothing, already created
...@@ -740,10 +734,10 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) ...@@ -740,10 +734,10 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
break; break;
case UNIQUE_ORDERED_INDEX: case UNIQUE_ORDERED_INDEX:
if (!(error= create_ordered_index(index_name, key_info))) if (!(error= create_ordered_index(index_name, key_info)))
error= create_unique_index(get_unique_index_name(i), key_info); error= create_unique_index(unique_index_name, key_info);
break; break;
case UNIQUE_INDEX: case UNIQUE_INDEX:
error= create_unique_index(get_unique_index_name(i), key_info); error= create_unique_index(unique_index_name, key_info);
break; break;
case ORDERED_INDEX: case ORDERED_INDEX:
error= create_ordered_index(index_name, key_info); error= create_ordered_index(index_name, key_info);
...@@ -760,21 +754,20 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) ...@@ -760,21 +754,20 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
} }
} }
// Add handles to index objects // Add handles to index objects
DBUG_PRINT("info", ("Trying to add handle to index %s", index_name)); if (idx_type != PRIMARY_KEY_INDEX && idx_type != UNIQUE_INDEX)
if ((m_index[i].type != PRIMARY_KEY_INDEX) &&
(m_index[i].type != UNIQUE_INDEX))
{ {
DBUG_PRINT("info", ("Get handle to index %s", index_name));
const NDBINDEX *index= dict->getIndex(index_name, m_tabname); const NDBINDEX *index= dict->getIndex(index_name, m_tabname);
if (!index) DBUG_RETURN(1); if (!index) DBUG_RETURN(1);
m_index[i].index= (void *) index; m_index[i].index= (void *) index;
} }
if (m_index[i].unique_name) if (idx_type == UNIQUE_ORDERED_INDEX || idx_type == UNIQUE_INDEX)
{ {
const NDBINDEX *index= dict->getIndex(m_index[i].unique_name, m_tabname); DBUG_PRINT("info", ("Get handle to unique_index %s", unique_index_name));
const NDBINDEX *index= dict->getIndex(unique_index_name, m_tabname);
if (!index) DBUG_RETURN(1); if (!index) DBUG_RETURN(1);
m_index[i].unique_index= (void *) index; m_index[i].unique_index= (void *) index;
} }
DBUG_PRINT("info", ("Added handle to index %s", index_name));
} }
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -810,9 +803,6 @@ void ha_ndbcluster::release_metadata() ...@@ -810,9 +803,6 @@ void ha_ndbcluster::release_metadata()
// Release index list // Release index list
for (i= 0; i < MAX_KEY; i++) for (i= 0; i < MAX_KEY; i++)
{ {
if (m_index[i].unique_name)
my_free((char*)m_index[i].unique_name, MYF(0));
m_index[i].unique_name= NULL;
m_index[i].unique_index= NULL; m_index[i].unique_index= NULL;
m_index[i].index= NULL; m_index[i].index= NULL;
} }
...@@ -868,16 +858,6 @@ static const ulong index_type_flags[]= ...@@ -868,16 +858,6 @@ static const ulong index_type_flags[]=
static const int index_flags_size= sizeof(index_type_flags)/sizeof(ulong); static const int index_flags_size= sizeof(index_type_flags)/sizeof(ulong);
inline const char* ha_ndbcluster::get_index_name(uint idx_no) const
{
return table->keynames.type_names[idx_no];
}
inline const char* ha_ndbcluster::get_unique_index_name(uint idx_no) const
{
return m_index[idx_no].unique_name;
}
inline NDB_INDEX_TYPE ha_ndbcluster::get_index_type(uint idx_no) const inline NDB_INDEX_TYPE ha_ndbcluster::get_index_type(uint idx_no) const
{ {
DBUG_ASSERT(idx_no < MAX_KEY); DBUG_ASSERT(idx_no < MAX_KEY);
...@@ -1094,7 +1074,6 @@ int ha_ndbcluster::unique_index_read(const byte *key, ...@@ -1094,7 +1074,6 @@ int ha_ndbcluster::unique_index_read(const byte *key,
DBUG_ENTER("unique_index_read"); DBUG_ENTER("unique_index_read");
DBUG_PRINT("enter", ("key_len: %u, index: %u", key_len, active_index)); DBUG_PRINT("enter", ("key_len: %u, index: %u", key_len, active_index));
DBUG_DUMP("key", (char*)key, key_len); DBUG_DUMP("key", (char*)key, key_len);
DBUG_PRINT("enter", ("name: %s", get_unique_index_name(active_index)));
NdbOperation::LockMode lm= NdbOperation::LockMode lm=
(NdbOperation::LockMode)get_ndb_lock_type(m_lock.type); (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type);
...@@ -1350,7 +1329,6 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key, ...@@ -1350,7 +1329,6 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key,
NdbConnection *trans= m_active_trans; NdbConnection *trans= m_active_trans;
NdbResultSet *cursor; NdbResultSet *cursor;
NdbIndexScanOperation *op; NdbIndexScanOperation *op;
const char *index_name;
DBUG_ENTER("ordered_index_scan"); DBUG_ENTER("ordered_index_scan");
DBUG_PRINT("enter", ("index: %u, sorted: %d", active_index, sorted)); DBUG_PRINT("enter", ("index: %u, sorted: %d", active_index, sorted));
...@@ -1359,7 +1337,6 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key, ...@@ -1359,7 +1337,6 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key,
DBUG_EXECUTE("enter", print_key(start_key, "start_key");); DBUG_EXECUTE("enter", print_key(start_key, "start_key"););
DBUG_EXECUTE("enter", print_key(end_key, "end_key");); DBUG_EXECUTE("enter", print_key(end_key, "end_key"););
index_name= get_index_name(active_index);
NdbOperation::LockMode lm= NdbOperation::LockMode lm=
(NdbOperation::LockMode)get_ndb_lock_type(m_lock.type); (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type);
...@@ -3304,7 +3281,6 @@ int ha_ndbcluster::create_index(const char *name, ...@@ -3304,7 +3281,6 @@ int ha_ndbcluster::create_index(const char *name,
DBUG_ENTER("create_index"); DBUG_ENTER("create_index");
DBUG_PRINT("enter", ("name: %s ", name)); DBUG_PRINT("enter", ("name: %s ", name));
// NdbDictionary::Index ndb_index(name);
NdbDictionary::Index ndb_index(name); NdbDictionary::Index ndb_index(name);
if (unique) if (unique)
ndb_index.setType(NdbDictionary::Index::UniqueHashIndex); ndb_index.setType(NdbDictionary::Index::UniqueHashIndex);
...@@ -3502,7 +3478,6 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): ...@@ -3502,7 +3478,6 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
for (i= 0; i < MAX_KEY; i++) for (i= 0; i < MAX_KEY; i++)
{ {
m_index[i].type= UNDEFINED_INDEX; m_index[i].type= UNDEFINED_INDEX;
m_index[i].unique_name= NULL;
m_index[i].unique_index= NULL; m_index[i].unique_index= NULL;
m_index[i].index= NULL; m_index[i].index= NULL;
} }
......
...@@ -52,7 +52,6 @@ typedef enum ndb_index_type { ...@@ -52,7 +52,6 @@ typedef enum ndb_index_type {
typedef struct ndb_index_data { typedef struct ndb_index_data {
NDB_INDEX_TYPE type; NDB_INDEX_TYPE type;
void *index; void *index;
const char * unique_name;
void *unique_index; void *unique_index;
} NDB_INDEX_DATA; } NDB_INDEX_DATA;
...@@ -180,8 +179,6 @@ class ha_ndbcluster: public handler ...@@ -180,8 +179,6 @@ class ha_ndbcluster: public handler
int build_index_list(TABLE *tab, enum ILBP phase); int build_index_list(TABLE *tab, enum ILBP phase);
int get_metadata(const char* path); int get_metadata(const char* path);
void release_metadata(); void release_metadata();
const char* get_index_name(uint idx_no) const;
const char* get_unique_index_name(uint idx_no) const;
NDB_INDEX_TYPE get_index_type(uint idx_no) const; NDB_INDEX_TYPE get_index_type(uint idx_no) const;
NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const; NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const;
......
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