List:Commits« Previous MessageNext Message »
From:tomas Date:May 2 2007 8:24pm
Subject:bk commit into 5.1 tree (tomas:1.2502)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas 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@stripped, 2007-05-02 22:23:55+02:00, tomas@stripped +1 -0
  Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-telco-6.1
  into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-telco-6.1-batch-slave
  MERGE: 1.2500.1.17

  sql/ha_ndbcluster.cc@stripped, 2007-05-02 22:23:51+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.408.1.1

# 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:	tomas
# Host:	whalegate.ndb.mysql.com
# Root:	/home/tomas/mysql-5.1-telco-6.1-batch-slave/RESYNC

--- 1.409/sql/ha_ndbcluster.cc	2007-04-25 17:09:40 +02:00
+++ 1.410/sql/ha_ndbcluster.cc	2007-05-02 22:23:51 +02:00
@@ -657,6 +657,26 @@
 
 
 /*
+  Check if MySQL field type forces var part in ndb storage
+*/
+static bool field_type_forces_var_part(enum_field_types type)
+{
+  switch (type) {
+  case MYSQL_TYPE_VAR_STRING:
+  case MYSQL_TYPE_VARCHAR:
+    return TRUE;
+  case MYSQL_TYPE_TINY_BLOB:
+  case MYSQL_TYPE_BLOB:
+  case MYSQL_TYPE_MEDIUM_BLOB:
+  case MYSQL_TYPE_LONG_BLOB:
+  case MYSQL_TYPE_GEOMETRY:
+    return FALSE;
+  default:
+    return FALSE;
+  }
+}
+
+/*
   Instruct NDB to set the value of the hidden primary key
 */
 
@@ -4791,14 +4811,14 @@
 
 int ha_ndbcluster::create(const char *name, 
                           TABLE *form, 
-                          HA_CREATE_INFO *info)
+                          HA_CREATE_INFO *create_info)
 {
   THD *thd= current_thd;
   NDBTAB tab;
   NDBCOL col;
   uint pack_length, length, i, pk_length= 0;
   const void *data= NULL, *pack_data= NULL;
-  bool create_from_engine= (info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
+  bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
   bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE);
   char tablespace[FN_LEN];
 
@@ -4822,7 +4842,7 @@
       if (!(m_table= ndbtab_g.get_table()))
 	ERR_RETURN(dict->getNdbError());
       if ((get_tablespace_name(thd, tablespace, FN_LEN)))
-	info->tablespace= tablespace;    
+	create_info->tablespace= tablespace;    
       m_table= NULL;
     }
     DBUG_PRINT("info", ("Dropping and re-creating table for TRUNCATE"));
@@ -4863,7 +4883,7 @@
 
   DBUG_PRINT("table", ("name: %s", m_tabname));  
   tab.setName(m_tabname);
-  tab.setLogging(!(info->options & HA_LEX_CREATE_TMP_TABLE));    
+  tab.setLogging(!(create_info->options & HA_LEX_CREATE_TMP_TABLE));    
    
   // Save frm data for this table
   if (readfrm(name, &data, &length))
@@ -4878,20 +4898,93 @@
   my_free((char*)data, MYF(0));
   my_free((char*)pack_data, MYF(0));
   
+  /*
+    Check for disk options
+  */
+  if (create_info->storage_media == HA_SM_DISK)
+  { 
+    if (create_info->tablespace)
+      tab.setTablespaceName(create_info->tablespace);
+    else
+      tab.setTablespaceName("DEFAULT-TS");
+  }
+  else if (create_info->tablespace)
+  {
+    if (create_info->storage_media == HA_SM_MEMORY)
+    {
+      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+			  ER_ILLEGAL_HA_CREATE_OPTION,
+			  ER(ER_ILLEGAL_HA_CREATE_OPTION),
+			  ndbcluster_hton_name,
+			  "TABLESPACE currently only supported for "
+			  "STORAGE DISK");
+      DBUG_RETURN(HA_ERR_UNSUPPORTED);
+    }
+    tab.setTablespaceName(create_info->tablespace);
+    create_info->storage_media = HA_SM_DISK;  //if use tablespace, that also means store on disk
+  }
+
+  /*
+    Handle table row type
+
+    Default is to let table rows have var part reference so that online 
+    add column can be performed in the future.  Explicitly setting row 
+    type to fixed will omit var part reference, which will save data 
+    memory in ndb, but at the cost of not being able to online add 
+    column to this table
+  */
+  switch (create_info->row_type) {
+  case ROW_TYPE_FIXED:
+    tab.setForceVarPart(FALSE);
+    break;
+  case ROW_TYPE_DYNAMIC:
+    /* fall through, treat as default */
+  default:
+    /* fall through, treat as default */
+  case ROW_TYPE_DEFAULT:
+    tab.setForceVarPart(TRUE);
+    break;
+  }
+
+  /*
+    Setup columns
+  */
   for (i= 0; i < form->s->fields; i++) 
   {
     Field *field= form->field[i];
     DBUG_PRINT("info", ("name: %s, type: %u, pack_length: %d", 
                         field->field_name, field->real_type(),
                         field->pack_length()));
-    if ((my_errno= create_ndb_column(col, field, info)))
+    if ((my_errno= create_ndb_column(col, field, create_info)))
       DBUG_RETURN(my_errno);
  
-    if (info->storage_media == HA_SM_DISK)
+    if (create_info->storage_media == HA_SM_DISK)
       col.setStorageType(NdbDictionary::Column::StorageTypeDisk);
     else
       col.setStorageType(NdbDictionary::Column::StorageTypeMemory);
 
+    switch (create_info->row_type) {
+    case ROW_TYPE_FIXED:
+      if (field_type_forces_var_part(field->type()))
+      {
+        push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+                            ER_ILLEGAL_HA_CREATE_OPTION,
+                            ER(ER_ILLEGAL_HA_CREATE_OPTION),
+                            ndbcluster_hton_name,
+                            "Row format FIXED incompatible with "
+                            "variable sized attribute");
+        DBUG_RETURN(HA_ERR_UNSUPPORTED);
+      }
+      break;
+    case ROW_TYPE_DYNAMIC:
+      /*
+        Future: make columns dynamic in this case
+      */
+      break;
+    default:
+      break;
+    }
+
     tab.addColumn(col);
     if (col.getPrimaryKey())
       pk_length += (field->pack_length() + 3) / 4;
@@ -4905,29 +4998,6 @@
     for (; key_part != end; key_part++)
       tab.getColumn(key_part->fieldnr-1)->setStorageType(
                              NdbDictionary::Column::StorageTypeMemory);
-  }
-
-  if (info->storage_media == HA_SM_DISK)
-  { 
-    if (info->tablespace)
-      tab.setTablespaceName(info->tablespace);
-    else
-      tab.setTablespaceName("DEFAULT-TS");
-  }
-  else if (info->tablespace)
-  {
-    if (info->storage_media == HA_SM_MEMORY)
-    {
-      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
-			  ER_ILLEGAL_HA_CREATE_OPTION,
-			  ER(ER_ILLEGAL_HA_CREATE_OPTION),
-			  ndbcluster_hton_name,
-			  "TABLESPACE currently only supported for "
-			  "STORAGE DISK"); 
-      DBUG_RETURN(HA_ERR_UNSUPPORTED);
-    }
-    tab.setTablespaceName(info->tablespace);
-    info->storage_media = HA_SM_DISK;  //if use tablespace, that also means store on disk
   }
 
   // No primary key, create shadow key as 64 bit, auto increment  
Thread
bk commit into 5.1 tree (tomas:1.2502)tomas2 May