List:Internals« Previous MessageNext Message »
From:mikael Date:September 22 2005 8:49pm
Subject:bk commit into 5.1 tree (mronstrom:1.2028)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mikron. When mikron does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2028 05/09/22 22:49:13 mronstrom@stripped +6 -0
  Another step in Partition Management WL 2604

  storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
    1.106 05/09/22 22:49:01 mronstrom@stripped +29 -6
    Another step in Partition Management WL 2604

  storage/ndb/src/ndbapi/NdbDictionary.cpp
    1.53 05/09/22 22:49:01 mronstrom@stripped +16 -0
    Another step in Partition Management WL 2604

  storage/ndb/include/ndbapi/NdbDictionary.hpp
    1.52 05/09/22 22:49:01 mronstrom@stripped +6 -1
    Another step in Partition Management WL 2604

  sql/sql_partition.cc
    1.19 05/09/22 22:49:00 mronstrom@stripped +0 -0
    Another step in Partition Management WL 2604

  sql/handler.h
    1.155 05/09/22 22:49:00 mronstrom@stripped +1 -1
    Another step in Partition Management WL 2604

  sql/ha_ndbcluster.cc
    1.159 05/09/22 22:49:00 mronstrom@stripped +89 -76
    Another step in Partition Management WL 2604

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mronstrom
# Host:	c-ac08e253.1238-1-64736c10.cust.bredbandsbolaget.se
# Root:	/Users/mikron/wl2498

--- 1.154/sql/handler.h	2005-09-22 16:43:35 +02:00
+++ 1.155/sql/handler.h	2005-09-22 22:49:00 +02:00
@@ -456,7 +456,7 @@
 
 typedef struct {
   longlong list_value;
-  uint partition_id;
+  uint32 partition_id;
 } LIST_PART_ENTRY;
 enum Item_result;
 

--- 1.51/storage/ndb/include/ndbapi/NdbDictionary.hpp	2005-09-22 16:56:43 +02:00
+++ 1.52/storage/ndb/include/ndbapi/NdbDictionary.hpp	2005-09-22 22:49:01 +02:00
@@ -777,9 +777,14 @@
      * Fragment Identity
      * Node group identity
      * Fragment State
-     * Tablespace identity
      */
     void setFragmentData(const void* data, Uint32 len);
+
+    /**
+     * Set tablespace information per fragment
+     * Contains a tablespace id and a tablespace version
+     */
+    void setTablespaceData(const void* data, Uint32 len);
 
     /**
      * Set array of information mapping range values and list values

--- 1.52/storage/ndb/src/ndbapi/NdbDictionary.cpp	2005-09-22 16:56:44 +02:00
+++ 1.53/storage/ndb/src/ndbapi/NdbDictionary.cpp	2005-09-22 22:49:01 +02:00
@@ -457,6 +457,22 @@
 }
 
 const void* 
+NdbDictionary::Table::getTablespaceData() const {
+  return m_impl.getTablespaceData();
+}
+
+Uint32
+NdbDictionary::Table::getTablespaceDataLen() const {
+  return m_impl.getTablespaceDataLen();
+}
+
+void
+NdbDictionary::Table::setTablespaceData(const void* data, Uint32 noWords)
+{
+  m_impl.setTablespaceData(data, noWords);
+}
+
+const void* 
 NdbDictionary::Table::getRangeListData() const {
   return m_impl.getRangeListData();
 }

--- 1.105/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2005-09-22 16:56:44 +02:00
+++ 1.106/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2005-09-22 22:49:01 +02:00
@@ -581,18 +581,41 @@
     return m_newFrm.length();
 }
 
-void NdbTableImpl::setFragmentData(const void* data, Uint32 len)
+void NdbTableImpl::setFrm(const void* data, Uint32 len)
 {
-  m_new_fd.assign(data, len);
+  m_newFrm.assign(data, len);
 }
 
 const void * 
-NdbTableImpl::getFragmentData() const
+NdbTableImpl::getFrmData() const
 {
-  if (m_new_fd.empty())
-    return m_fd.get_data();
+  if (m_newFrm.empty())
+    return m_frm.get_data();
   else
-    return m_new_fd.get_data();
+    return m_newFrm.get_data();
+}
+
+Uint32
+NdbTableImpl::getTablespaceDataLen() const 
+{
+  if (m_new_ts.empty())
+    return m_ts.length();
+  else
+    return m_new_ts.length();
+}
+
+void NdbTableImpl::setTablespaceData(const void* data, Uint32 len)
+{
+  m_new_ts.assign(data, len);
+}
+
+const void * 
+NdbTableImpl::getTablespaceData() const
+{
+  if (m_new_ts.empty())
+    return m_ts.get_data();
+  else
+    return m_new_ts.get_data();
 }
 
 Uint32

--- 1.158/sql/ha_ndbcluster.cc	2005-09-22 16:56:43 +02:00
+++ 1.159/sql/ha_ndbcluster.cc	2005-09-22 22:49:00 +02:00
@@ -47,6 +47,7 @@
 static const int max_transactions= 3; // should really be 2 but there is a transaction to much allocated when loch table is used
 
 static const char *ha_ndb_ext=".ndb";
+static const char *default_ts= "DEFAULT-TS";
 
 static int ndbcluster_close_connection(THD *thd);
 static int ndbcluster_commit(THD *thd, bool all);
@@ -3863,7 +3864,7 @@
     if (info->tablespace)
       tab.setTablespace(info->tablespace);
     else
-      tab.setTablespace("DEFAULT-TS");
+      tab.setTablespace(default_ts);
   // No primary key, create shadow key as 64 bit, auto increment  
   if (form->s->primary_key == MAX_KEY) 
   {
@@ -3912,21 +3913,11 @@
 
   // Check partition info
   partition_info *part_info= form->s->part_info;
-  if (part_info)
+  if ((my_errno= set_up_partition_info(part_info, form, (void*)&tab)))
   {
-    int error;
-    if ((error= set_up_partition_info(part_info, form, (void*)&tab)))
-    {
-      DBUG_RETURN(error);
-    }
-  }
-  else
-  {
-    ndb_set_fragmentation(tab, form, pk_length);
+    DBUG_RETURN(my_errno);
   }
 
-
-
   if ((my_errno= check_ndb_connection()))
     DBUG_RETURN(my_errno);
   
@@ -7666,6 +7657,22 @@
   DBUG_VOID_RETURN;
 }
 
+bool ha_partition::get_tablespace_id(uint32 *ts_id, uint32 *ts_version,
+                                     char *tablespace_name)
+{
+  NdbTablespaceImpl tmp;
+
+  if (tablespace_name == NULL)
+    tablespace_name= default_ts;
+  if (get_filegroup(tmp, NdbDictionary::Object::Tablespace, tablespace_name))
+  {
+    /* TODO RONM: Fix proper error handling */
+    return TRUE;
+  }
+  *ts_id= tmp.m_id;
+  *ts_version= tmp.m_version;
+  return FALSE;
+}
 
 /*
   User defined partitioning set-up. We need to check how many fragments the
@@ -7684,12 +7691,15 @@
                                           TABLE *table,
                                           void *tab_par)
 {
-  ushort node_group[MAX_PARTITIONS];
-  ulong ng_index= 0, i, j;
+  ushort frag_data[3*MAX_PARTITIONS];
+  uint32 ts_data[2*MAX_PARTITIONS];
+  ulong ts_index= 0, fd_index= 0, i, j;
   NDBTAB *tab= (NDBTAB*)tab_par;
   NDBTAB::FragmentType ftype= NDBTAB::UserDefined;
   partition_element *part_elem;
   bool first= TRUE;
+  uint ts_id, ts_version, part_count= 0;
+  List_iterator<partition_element> part_it(part_info->partitions);
   DBUG_ENTER("ha_ndbcluster::set_up_partition_info");
 
   if (part_info->part_type == HASH_PARTITION &&
@@ -7709,18 +7719,63 @@
       col->setPartitionKey(TRUE);
     }
   }
-  List_iterator<partition_element> part_it(part_info->partitions);
+  else if (part_info->part_type == RANGE_PARTITION)
+  {
+    int32 *range_data= frag_data;
+    for (i= 0; i < part_info->no_parts; i++)
+    {
+      longlong range_val= part_info->range_int_array[i];
+      if (range_val < INT_MIN32 || range_val > INT_MAX32)
+      {
+        DBUG_RETURN(1234);
+      }
+      range_data[i]= (int32)range_val;
+    }
+    tab->setRangeListData(range_data, 4*no_parts);
+  }
+  else if (part_info->part_type == LIST_PARTITION)
+  {
+    int32 *list_data= my_malloc(part_info->no_list_values*2*sizeof(int32));
+    uint32 *part_id;
+    if (!list_data)
+    {
+      mem_alloc_error();
+      DBUG_RETURN(TRUE);
+    }
+    for (i= 0; i < part_info->no_list_values; i++)
+    {
+       LIST_PART_ENTRY *list_entry= part_info->list_array[i];
+       longlong list_val= list_entry->list_value;
+       if (list_val < INT_MIN32 || list_val > INT_MAX32)
+       {
+         DBUG_RETURN(1234);
+       }
+       list_data[2*i]= (int32)list_val;
+       part_id= (uint32*)&list_data[2*i+1];
+       *part_id= list_entry->partition_id;
+    }
+    tab->setRangeListData(list_data, 8*part_info->no_list_values);
+    my_free(list_data);
+  }
+  tab->setFragmentType(ftype);
   for (i= 0; i < part_info->no_parts; i++)
   {
     uint ng;
     part_elem= part_it++;
     if (!is_sub_partitioned(part_info))
     {
+      frag_data[fd_index++]= part_count++;
       ng= part_elem->nodegroup_id;
       if (first && ng == UNDEF_NODEGROUP)
         ng= 0;
-      node_group[ng_index++]= ng;
-      //Here we should insert tablespace id based on tablespace name
+      frag_data[fd_index++]= ng;
+      frag_data[fd_index++]= 0; //State normal
+      if (get_tablespace_id(&ts_id, &ts_version, part_elem->tablespace_name))
+      {
+        DBUG_RETURN(1234);
+      }
+      ts_data[ts_index++]= ts_id;
+      ts_data[ts_index++]= ts_version;
     }
     else
     {
@@ -7728,15 +7783,26 @@
       for (j= 0; j < part_info->no_subparts; j++)
       {
         part_elem= sub_it++;
+        frag_data[fd_index++]= part_count++;
         ng= part_elem->nodegroup_id;
         if (first && ng == UNDEF_NODEGROUP)
           ng= 0;
-        node_group[ng_index++]= ng;
-        //Here we should insert tablespace id based on tablespace name
+        frag_data[fd_index++]= ng;
+        frag_data[fd_index++]= 0; //State normal
+        if (get_tablespace_id(&ts_id, &ts_version,
+                              part_elem->tablespace_name))
+        {
+          DBUG_RETURN(1234);
+        }
+        ts_data[ts_index++]= ts_id;
+        ts_data[ts_index++]= ts_version;
       }
     }
     first= FALSE;
   }
+  tab->setFragmentData(&frag_data, fd_index*4);
+  tab->setTablespaceData(&ts_data, ts_index*4);
+
   {
     uint no_nodes= g_ndb_cluster_connection->no_db_nodes();
     if (ng_index > 4 * no_nodes)
@@ -7744,66 +7810,10 @@
       DBUG_RETURN(1300);
     }
   }
-  tab->setNodeGroupIds(&node_group, ng_index);
-  tab->setFragmentType(ftype);
   DBUG_RETURN(0);
 }
 
 
-/*
-  This routine is used to set-up fragmentation when the user has only specified
-  ENGINE = NDB and no user defined partitioning what so ever. Thus all values
-  will be based on default values. We will choose Linear Hash or Hash with
-  perfect spread dependent on a session variable defined in MySQL.
-*/
-
-static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length)
-{
-  NDBTAB::FragmentType ftype= NDBTAB::DistrKeyHash;
-  ushort node_group[MAX_PARTITIONS];
-  uint no_nodes= g_ndb_cluster_connection->no_db_nodes(), no_fragments, i;
-  DBUG_ENTER("ndb_set_fragmentation");
-
-  if (form->s->max_rows == (ha_rows) 0)
-  {
-    no_fragments= no_nodes;
-  }
-  else
-  {
-    /*
-      Ensure that we get enough fragments to handle all rows and ensure that
-      the table is fully distributed by keeping the number of fragments a
-      multiple of the number of nodes.
-    */
-    uint fragments= get_no_fragments(form->s->max_rows);
-    if (adjusted_frag_count(fragments, no_nodes, no_fragments))
-    {
-      push_warning(current_thd,
-                   MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
-      "Ndb might have problems storing the max amount of rows specified");
-    }
-  }
-  /*
-    Always start with node group 0 and continue with next node group from
-    there
-  */
-  node_group[0]= 0;
-  for (i= 1; i < no_fragments; i++)
-    node_group[i]= UNDEF_NODEGROUP;
-  switch (opt_ndb_distribution_id)
-  {
-  case ND_KEYHASH:
-    ftype= NDBTAB::DistrKeyHash;
-    break;
-  case ND_LINHASH:
-    ftype= NDBTAB::DistrKeyLin;
-    break;
-  }
-  tab.setFragmentType(ftype);
-  tab.setNodeGroupIds(&node_group, no_fragments);
-  DBUG_VOID_RETURN;
-}
-
 bool ha_ndbcluster::check_if_incompatible_data(HA_CREATE_INFO *info,
 					       uint table_changes)
 {
@@ -7894,6 +7904,9 @@
     the array of ranges.
     This information is either retrieved from the part_info object and for
     non-partitioned tables it is calculated based on whe
+
+    Use function get_filegroup to map from table space name to tablespace
+    id.
   */
   new_tab.setFragmentData(NULL, frag_data_len);
   new_tab.setFrm(pack_frm_data, pack_frm_len);
Thread
bk commit into 5.1 tree (mronstrom:1.2028)mikael23 Sep