List:Commits« Previous MessageNext Message »
From:Martin Skold Date:May 17 2007 10:02am
Subject:bk commit into 5.1 tree (mskold:1.2492)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of marty. When marty 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-17 12:02:35+02:00, mskold@stripped +20 -0
  tmp.patch

  include/mysql_com.h@stripped, 2007-04-26 15:20:13+02:00, mskold@stripped +2 -0
    Adding column format and storage

  mysql-test/r/information_schema.result@stripped, 2007-04-26 15:20:14+02:00, mskold@stripped +2 -2
    Adding column format and storage

  mysql-test/r/join.result@stripped, 2007-04-26 15:20:14+02:00, mskold@stripped +3 -3
    Adding column format and storage

  mysql-test/r/sp.result@stripped, 2007-04-26 15:20:15+02:00, mskold@stripped +6 -6
    Adding column format and storage

  sql/field.cc@stripped, 2007-04-26 15:20:15+02:00, mskold@stripped +9 -1
    Adding column format and storage

  sql/field.h@stripped, 2007-04-26 15:20:15+02:00, mskold@stripped +17 -1
    Adding column format and storage

  sql/ha_ndbcluster.cc@stripped, 2007-04-27 16:05:27+02:00, mskold@stripped +153 -92
    Adding column format and storage

  sql/handler.h@stripped, 2007-04-27 15:31:03+02:00, mskold@stripped +6 -1
    Adding column format and storage

  sql/lex.h@stripped, 2007-04-26 15:20:17+02:00, mskold@stripped +1 -0
    Adding column format and storage

  sql/mysql_priv.h@stripped, 2007-04-26 15:20:18+02:00, mskold@stripped +2 -0
    Adding column format and storage

  sql/sp_head.cc@stripped, 2007-04-26 15:20:18+02:00, mskold@stripped +3 -1
    Adding column format and storage

  sql/sql_lex.h@stripped, 2007-04-26 15:20:18+02:00, mskold@stripped +2 -0
    Adding column format and storage

  sql/sql_parse.cc@stripped, 2007-04-26 15:20:18+02:00, mskold@stripped +4 -1
    Adding column format and storage

  sql/sql_show.cc@stripped, 2007-04-26 15:20:19+02:00, mskold@stripped +51 -3
    Adding column format and storage

  sql/sql_table.cc@stripped, 2007-04-27 17:44:22+02:00, mskold@stripped +3 -15
    Adding column format and storage

  sql/sql_yacc.yy@stripped, 2007-04-27 15:36:11+02:00, mskold@stripped +23 -4
    Adding column format and storage

  sql/table.cc@stripped, 2007-04-27 15:29:58+02:00, mskold@stripped +46 -8
    Adding column format and storage

  sql/table.h@stripped, 2007-04-27 17:45:23+02:00, mskold@stripped +2 -0
    Adding column format and storage

  sql/unireg.cc@stripped, 2007-04-27 15:27:47+02:00, mskold@stripped +56 -0
    Adding column format and storage

  sql/unireg.h@stripped, 2007-04-26 15:20:19+02:00, mskold@stripped +4 -0
    Adding column format and storage

# 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:	mskold
# Host:	linux.site
# Root:	/windows/Linux_space/MySQL/mysql-5.1-wl3627-new

--- 1.120/include/mysql_com.h	2007-05-17 12:02:48 +02:00
+++ 1.121/include/mysql_com.h	2007-05-17 12:02:48 +02:00
@@ -103,6 +103,8 @@ enum enum_server_command
 #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
 #define FIELD_IN_ADD_INDEX (1<< 20)	/* Intern: Field used in ADD INDEX */
 #define FIELD_IS_RENAMED (1<< 21)       /* Intern: Field is being renamed */
+#define FIELD_STORAGE_FLAGS 22          /* Storage type: bit 22, 23 and 24 */
+#define COLUMN_FORMAT_FLAGS 25          /* Column format: bit 25, 26 and 27 */
 
 #define REFRESH_GRANT		1	/* Refresh grant tables */
 #define REFRESH_LOG		2	/* Start on new log file */

--- 1.385/sql/field.cc	2007-05-17 12:02:48 +02:00
+++ 1.386/sql/field.cc	2007-05-17 12:02:48 +02:00
@@ -8666,7 +8666,9 @@ bool create_field::init(THD *thd, char *
                         uint fld_type_modifier, Item *fld_default_value,
                         Item *fld_on_update_value, LEX_STRING *fld_comment,
                         char *fld_change, List<String> *fld_interval_list,
-                        CHARSET_INFO *fld_charset, uint fld_geom_type)
+                        CHARSET_INFO *fld_charset, uint fld_geom_type,
+                        enum ha_storage_media storage_type,
+                        enum column_format_type loc_column_format)
 {
   uint sign_len, allowed_type_modifier= 0;
   ulong max_field_charlength= MAX_FIELD_CHARLENGTH;
@@ -8677,6 +8679,10 @@ bool create_field::init(THD *thd, char *
   field_name= fld_name;
   def= fld_default_value;
   flags= fld_type_modifier;
+  field_storage_type= storage_type;
+  column_format= loc_column_format;
+  flags|= (((uint)storage_type << FIELD_STORAGE_FLAGS) & STORAGE_TYPE_MASK);
+  flags|= (((uint)column_format << COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
   unireg_check= (fld_type_modifier & AUTO_INCREMENT_FLAG ?
                  Field::NEXT_NUMBER : Field::NONE);
   decimals= fld_decimals ? (uint)atoi(fld_decimals) : 0;
@@ -9251,6 +9257,8 @@ create_field::create_field(Field *old_fi
   field_name=change=old_field->field_name;
   length=     old_field->field_length;
   flags=      old_field->flags;
+  field_storage_type= old_field->field_storage_type();
+  column_format= old_field->column_format();
   unireg_check=old_field->unireg_check;
   pack_length=old_field->pack_length();
   key_length= old_field->key_length();

--- 1.220/sql/field.h	2007-05-17 12:02:48 +02:00
+++ 1.221/sql/field.h	2007-05-17 12:02:48 +02:00
@@ -390,6 +390,18 @@ public:
     return field_length / charset()->mbmaxlen;
   }
 
+  inline  enum ha_storage_media field_storage_type() const
+  {
+    return (enum ha_storage_media)
+      ((flags >> FIELD_STORAGE_FLAGS) & STORAGE_TYPE_MASK);
+  }
+
+  inline enum column_format_type column_format() const
+  {
+    return (enum column_format_type)
+      ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
+  }
+
   /* Hash value */
   virtual void hash(ulong *nr, ulong *nr2);
   friend bool reopen_table(THD *,struct st_table *,bool);
@@ -1573,6 +1585,8 @@ public:
 
   uint8 row,col,sc_length,interval_id;	// For rea_create_table
   uint	offset,pack_flag;
+  enum ha_storage_media field_storage_type;
+  enum column_format_type column_format;
   create_field() :after(0) {}
   create_field(Field *field, Field *orig_field);
   void create_length_to_internal_length(void);
@@ -1586,7 +1600,9 @@ public:
             char *decimals, uint type_modifier, Item *default_value,
             Item *on_update_value, LEX_STRING *comment, char *change,
             List<String> *interval_list, CHARSET_INFO *cs,
-            uint uint_geom_type);
+            uint uint_geom_type,
+            enum ha_storage_media storage_type,
+            enum column_format_type column_format);
 };
 
 

--- 1.256/sql/handler.h	2007-05-17 12:02:48 +02:00
+++ 1.257/sql/handler.h	2007-05-17 12:02:48 +02:00
@@ -267,6 +267,11 @@ enum row_type { ROW_TYPE_NOT_USED=-1, RO
 		ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
 		ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGES };
 
+enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
+                          COLUMN_FORMAT_TYPE_DEFAULT=   0,
+                          COLUMN_FORMAT_TYPE_FIXED=     1,
+                          COLUMN_FORMAT_TYPE_DYNAMIC=   2 };
+
 enum enum_binlog_func {
   BFN_RESET_LOGS=        1,
   BFN_RESET_SLAVE=       2,
@@ -763,7 +768,7 @@ typedef struct st_ha_create_information
   bool table_existed;			/* 1 in create if table existed */
   bool frm_only;                        /* 1 if no ha_create_table() */
   bool varchar;                         /* 1 if table has a VARCHAR */
-  enum ha_storage_media storage_media;  /* DEFAULT, DISK or MEMORY */
+  enum ha_storage_media default_storage_media;  /* DEFAULT, DISK or MEMORY */
 } HA_CREATE_INFO;
 
 

--- 1.174/sql/lex.h	2007-05-17 12:02:48 +02:00
+++ 1.175/sql/lex.h	2007-05-17 12:02:48 +02:00
@@ -199,6 +199,7 @@ static SYMBOL symbols[] = {
   { "FALSE",		SYM(FALSE_SYM)},
   { "FAST",		SYM(FAST_SYM)},
   { "FETCH",            SYM(FETCH_SYM)},
+  { "COLUMN_FORMAT",	SYM(COLUMN_FORMAT_SYM)},
   { "FIELDS",		SYM(COLUMNS)},
   { "FILE",		SYM(FILE_SYM)},
   { "FIRST",		SYM(FIRST_SYM)},

--- 1.501/sql/mysql_priv.h	2007-05-17 12:02:48 +02:00
+++ 1.502/sql/mysql_priv.h	2007-05-17 12:02:48 +02:00
@@ -1170,6 +1170,8 @@ void set_item_name(Item *item,char *pos,
 bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types type,
 		       char *length, char *decimal,
 		       uint type_modifier,
+                       enum ha_storage_media storage_type,
+                       enum column_format_type column_format,
 		       Item *default_value, Item *on_update_value,
 		       LEX_STRING *comment,
 		       char *change, List<String> *interval_list,

--- 1.272/sql/sql_lex.h	2007-05-17 12:02:48 +02:00
+++ 1.273/sql/sql_lex.h	2007-05-17 12:02:48 +02:00
@@ -1113,6 +1113,8 @@ typedef struct st_lex : public Query_tab
   enum enum_view_create_mode create_view_mode;
   enum enum_drop_mode drop_mode;
   uint uint_geom_type;
+  enum ha_storage_media storage_type;
+  enum column_format_type column_format;
   uint grant, grant_tot_col, which_columns;
   uint fk_delete_opt, fk_update_opt, fk_match_option;
   uint slave_thd_opt, start_transaction_opt;

--- 1.662/sql/sql_parse.cc	2007-05-17 12:02:48 +02:00
+++ 1.663/sql/sql_parse.cc	2007-05-17 12:02:48 +02:00
@@ -5374,6 +5374,8 @@ bool mysql_test_parse_for_slave(THD *thd
 bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
 		       char *length, char *decimals,
 		       uint type_modifier,
+                       enum ha_storage_media storage_type,
+                       enum column_format_type column_format,
 		       Item *default_value, Item *on_update_value,
                        LEX_STRING *comment,
 		       char *change,
@@ -5460,7 +5462,8 @@ bool add_field_to_list(THD *thd, LEX_STR
   if (!(new_field= new create_field()) ||
       new_field->init(thd, field_name->str, type, length, decimals, type_modifier,
                       default_value, on_update_value, comment, change,
-                      interval_list, cs, uint_geom_type))
+                      interval_list, cs, uint_geom_type,
+                      storage_type, column_format))
     DBUG_RETURN(1);
 
   lex->create_list.push_back(new_field);

--- 1.407/sql/sql_show.cc	2007-05-17 12:02:48 +02:00
+++ 1.408/sql/sql_show.cc	2007-05-17 12:02:48 +02:00
@@ -403,6 +403,8 @@ struct show_column_type_st
   const char *case_sensitivity;
   const char *default_value;
   const char *comment;
+  const char *storage_type;
+  const char *column_format;
 };
 
 /* TODO: Add remaning types */
@@ -412,11 +414,11 @@ static struct show_column_type_st sys_co
   {"tinyint",
     1,  "-128",  "127",  0,  0,  "YES",  "YES",
     "NO",   "YES", "YES",  "NO",  "NULL,0",
-    "A very small integer"},
+    "A very small integer", "Default", "Default"},
   {"tinyint unsigned",
     1,  "0"   ,  "255",  0,  0,  "YES",  "YES",
     "YES",  "YES",  "YES",  "NO",  "NULL,0",
-    "A very small integer"},
+    "A very small integer", "Default", "Default"},
 };
 
 bool mysqld_show_column_types(THD *thd)
@@ -440,6 +442,8 @@ bool mysqld_show_column_types(THD *thd)
   field_list.push_back(new Item_empty_string("Case_Sensitive",4));
   field_list.push_back(new Item_empty_string("Default",NAME_CHAR_LEN));
   field_list.push_back(new Item_empty_string("Comment",NAME_CHAR_LEN));
+  field_list.push_back(new Item_empty_string("Storage",8));
+  field_list.push_back(new Item_empty_string("Format",8));
 
   if (protocol->send_fields(&field_list,
                             Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -463,6 +467,8 @@ bool mysqld_show_column_types(THD *thd)
     protocol->store(sys_column_types[i].case_sensitivity, system_charset_info);
     protocol->store(sys_column_types[i].default_value, system_charset_info);
     protocol->store(sys_column_types[i].comment, system_charset_info);
+    protocol->store(sys_column_types[i].storage_type, system_charset_info);
+    protocol->store(sys_column_types[i].column_format, system_charset_info);
     if (protocol->write())
       DBUG_RETURN(TRUE);
   }
@@ -1123,7 +1129,32 @@ int store_create_info(THD *thd, TABLE_LI
       */
       packet->append(STRING_WITH_LEN(" NULL"));
     }
-
+    {
+      /*
+        Add field flags about FIELD FORMAT (FIXED or DYNAMIC)
+        and about STORAGE (DISK or MEMORY).
+      */
+      enum ha_storage_media storage_type= (enum ha_storage_media)
+        ((flags >> FIELD_STORAGE_FLAGS) & STORAGE_TYPE_MASK);
+      enum column_format_type column_format= (enum column_format_type)
+        ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
+      if (storage_type)
+      {
+        packet->append(STRING_WITH_LEN(" STORAGE"));
+        if (storage_type == HA_SM_DISK)
+          packet->append(STRING_WITH_LEN(" DISK"));
+        else
+          packet->append(STRING_WITH_LEN(" MEMORY"));
+      }
+      if (column_format)
+      {
+        packet->append(STRING_WITH_LEN(" COLUMN_FORMAT"));
+        if (column_format == COLUMN_FORMAT_TYPE_FIXED)
+          packet->append(STRING_WITH_LEN(" FIXED"));
+        else
+          packet->append(STRING_WITH_LEN(" DYNAMIC"));
+      }
+    }
     /* 
       Again we are using CURRENT_TIMESTAMP instead of NOW because it is
       more standard 
@@ -3247,6 +3278,21 @@ static int get_schema_column_record(THD 
     table->field[16]->store(tmp, (uint) (end-tmp), cs);
 
     table->field[18]->store(field->comment.str, field->comment.length, cs);
+    {
+      enum ha_storage_media storage_type= (enum ha_storage_media)
+        ((field->flags >> FIELD_STORAGE_FLAGS) & STORAGE_TYPE_MASK);
+      enum column_format_type column_format= (enum column_format_type)
+        ((field->flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
+      pos=(byte*) (storage_type == HA_SM_DEFAULT ? "Default" :
+                   storage_type == HA_SM_DISK ? "Disk" : "Memory");
+      table->field[19]->store((const char*) pos,
+                              strlen((const char*) pos), cs);
+      pos=(byte*) (column_format == COLUMN_FORMAT_TYPE_DEFAULT ? "Default" :
+                   column_format == COLUMN_FORMAT_TYPE_FIXED ? "Fixed" :
+                                                             "Dynamic");
+      table->field[20]->store((const char*) pos,
+                              strlen((const char*) pos), cs);
+    }
     if (schema_table_store_record(thd, table))
       DBUG_RETURN(1);
   }
@@ -5421,6 +5467,8 @@ ST_FIELD_INFO columns_fields_info[]=
   {"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra"},
   {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges"},
   {"COLUMN_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment"},
+  {"COLUMN_STORAGE", 8, MYSQL_TYPE_STRING, 0, 0, "Storage"},
+  {"COLUMN_FORMAT", 8, MYSQL_TYPE_STRING, 0, 0, "Format"},
   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
 };
 

--- 1.409/sql/sql_table.cc	2007-05-17 12:02:48 +02:00
+++ 1.410/sql/sql_table.cc	2007-05-17 12:02:48 +02:00
@@ -4729,18 +4729,6 @@ bool mysql_create_like_table(THD* thd, T
     DBUG_RETURN(TRUE);
 
   /*
-    For bug#25875, Newly created table through CREATE TABLE .. LIKE
-                   has no ndb_dd attributes;
-    Add something to get possible tablespace info from src table,
-    it can get valid tablespace name only for disk-base ndb table
-  */
-  if ((src_tables_list.table->file->get_tablespace_name(thd, ts_name, FN_LEN)))
-  {
-    create_info->tablespace= ts_name;
-    create_info->storage_media= HA_SM_DISK;
-  }
-
-  /*
     Validate the destination table
 
     skip the destination table name checking as this is already
@@ -5703,14 +5691,14 @@ view_err:
   if (!(used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE))
     create_info->key_block_size= table->s->key_block_size;
 
-  if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY)
+  if (!create_info->tablespace && table->s->tablespace)
   {
     /* 
        Regular alter table of disk stored table (no tablespace/storage change)
        Copy tablespace name
     */
-    if ((table->file->get_tablespace_name(thd, tablespace, FN_LEN)))
-      create_info->tablespace= tablespace;
+    strcpy(tablespace, table->s->tablespace);
+    create_info->tablespace= tablespace;
   }
   restore_record(table, s->default_values);     // Empty record for DEFAULT
   List_iterator<Alter_drop> drop_it(alter_info->drop_list);

--- 1.564/sql/sql_yacc.yy	2007-05-17 12:02:48 +02:00
+++ 1.565/sql/sql_yacc.yy	2007-05-17 12:02:48 +02:00
@@ -465,6 +465,7 @@ Item* handle_sql2003_note184_exception(T
   enum ha_key_alg key_alg;
   handlerton *db_type;
   enum row_type row_type;
+  enum column_format_type column_format_type;
   enum ha_rkey_function ha_rkey_mode;
   enum enum_tx_isolation tx_isolation;
   enum Cast_target cast_type;
@@ -669,6 +670,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  FALSE_SYM                     /* SQL-2003-R */
 %token  FAST_SYM
 %token  FETCH_SYM                     /* SQL-2003-R */
+%token  COLUMN_FORMAT_SYM
 %token  FILE_SYM
 %token  FIRST_SYM                     /* SQL-2003-N */
 %token  FIXED_SYM
@@ -1183,6 +1185,8 @@ bool my_yyoverflow(short **a, YYSTYPE **
 
 %type <row_type> row_types
 
+%type <column_format_type> column_format_types
+
 %type <tx_isolation> isolation_types
 
 %type <ha_rkey_mode> handler_rkey_mode
@@ -4341,8 +4345,8 @@ create_table_option:
 	| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.data_file_name= $4.str; Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR; }
 	| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.index_file_name= $4.str;  Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR; }
         | TABLESPACE ident {Lex->create_info.tablespace= $2.str;}
-        | STORAGE_SYM DISK_SYM {Lex->create_info.storage_media= HA_SM_DISK;}
-        | STORAGE_SYM MEMORY_SYM {Lex->create_info.storage_media= HA_SM_MEMORY;}
+        | STORAGE_SYM DISK_SYM {Lex->create_info.default_storage_media= HA_SM_DISK;}
+        | STORAGE_SYM MEMORY_SYM {Lex->create_info.default_storage_media= HA_SM_MEMORY;}
 	| CONNECTION_SYM opt_equal TEXT_STRING_sys { Lex->create_info.connect_string.str= $3.str; Lex->create_info.connect_string.length= $3.length;  Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION; }
 	| KEY_BLOCK_SIZE opt_equal ulong_num
 	  {
@@ -4414,6 +4418,12 @@ storage_engines:
           }
 	};
 
+column_format_types:
+	DEFAULT		{ $$= COLUMN_FORMAT_TYPE_DEFAULT; }
+	| FIXED_SYM	{ $$= COLUMN_FORMAT_TYPE_FIXED; }
+	| DYNAMIC_SYM	{ $$= COLUMN_FORMAT_TYPE_DYNAMIC; }
+        ;
+
 row_types:
 	DEFAULT		{ $$= ROW_TYPE_DEFAULT; }
 	| FIXED_SYM	{ $$= ROW_TYPE_FIXED; }
@@ -4534,12 +4544,15 @@ field_spec:
 	   lex->default_value= lex->on_update_value= 0;
            lex->comment=null_lex_str;
 	   lex->charset=NULL;
+           lex->storage_type= HA_SM_DEFAULT;
+           lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
 	 }
 	type opt_attribute
 	{
 	  LEX *lex=Lex;
 	  if (add_field_to_list(lex->thd, &$1, (enum enum_field_types) $3,
 				lex->length,lex->dec,lex->type,
+                                lex->storage_type, lex->column_format,
 				lex->default_value, lex->on_update_value, 
                                 &lex->comment,
 				lex->change,&lex->interval_list,lex->charset,
@@ -4738,6 +4751,9 @@ opt_attribute_list:
 
 attribute:
 	NULL_SYM	  { Lex->type&= ~ NOT_NULL_FLAG; }
+        | STORAGE_SYM DISK_SYM {Lex->storage_type= HA_SM_DISK;}
+        | STORAGE_SYM MEMORY_SYM {Lex->storage_type= HA_SM_MEMORY;}
+        | COLUMN_FORMAT_SYM column_format_types { Lex->column_format= $2; }
 	| not NULL_SYM	  { Lex->type|= NOT_NULL_FLAG; }
 	| DEFAULT now_or_signed_literal { Lex->default_value=$2; }
 	| ON UPDATE_SYM NOW_SYM optional_braces 
@@ -5099,7 +5115,7 @@ alter:
 	  lex->alter_info.reset();
 	  lex->alter_info.flags= 0;
           lex->no_write_to_binlog= 0;
-          lex->create_info.storage_media= HA_SM_DEFAULT;	
+          lex->create_info.default_storage_media= HA_SM_DEFAULT;	
 	}
 	alter_commands
 	{}
@@ -5490,6 +5506,8 @@ alter_list_item:
             lex->comment=null_lex_str;
 	    lex->charset= NULL;
 	    lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
+            lex->storage_type= HA_SM_DEFAULT;
+            lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
           }
           type opt_attribute
           {
@@ -5497,6 +5515,7 @@ alter_list_item:
             if (add_field_to_list(lex->thd,&$3,
                                   (enum enum_field_types) $5,
                                   lex->length,lex->dec,lex->type,
+                                  lex->storage_type, lex->column_format,
                                   lex->default_value, lex->on_update_value,
                                   &lex->comment,
 				  $3.str, &lex->interval_list, lex->charset,
@@ -8798,7 +8817,7 @@ show_param:
 	    if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL,0))
 	      MYSQL_YYABORT;
             lex->only_view= 0;
-	    lex->create_info.storage_media= HA_SM_DEFAULT;
+	    lex->create_info.default_storage_media= HA_SM_DEFAULT;
 	  }
         | CREATE VIEW_SYM table_ident
           {

--- 1.286/sql/table.cc	2007-05-17 12:02:48 +02:00
+++ 1.287/sql/table.cc	2007-05-17 12:02:48 +02:00
@@ -471,6 +471,8 @@ static int open_binary_frm(THD *thd, TAB
   const char **interval_array;
   enum legacy_db_type legacy_db_type;
   my_bitmap_map *bitmaps;
+  char *buff= 0;
+  char *field_extra_info= 0;
   DBUG_ENTER("open_binary_frm");
 
   new_field_pack_flag= head[27];
@@ -636,21 +638,19 @@ static int open_binary_frm(THD *thd, TAB
   if ((n_length= uint4korr(head+55)))
   {
     /* Read extra data segment */
-    char *buff, *next_chunk, *buff_end;
+    char *next_chunk, *buff_end;
     DBUG_PRINT("info", ("extra segment size is %u bytes", n_length));
     if (!(next_chunk= buff= my_malloc(n_length, MYF(MY_WME))))
       goto err;
     if (my_pread(file, (byte*)buff, n_length, record_offset + share->reclength,
                  MYF(MY_NABP)))
     {
-      my_free(buff, MYF(0));
       goto err;
     }
     share->connect_string.length= uint2korr(buff);
     if (! (share->connect_string.str= strmake_root(&share->mem_root,
             next_chunk + 2, share->connect_string.length)))
     {
-      my_free(buff, MYF(0));
       goto err;
     }
     next_chunk+= share->connect_string.length + 2;
@@ -692,7 +692,6 @@ static int open_binary_frm(THD *thd, TAB
               memdup_root(&share->mem_root, next_chunk + 4,
                           partition_info_len + 1)))
         {
-          my_free(buff, MYF(0));
           goto err;
         }
       }
@@ -700,7 +699,6 @@ static int open_binary_frm(THD *thd, TAB
       if (partition_info_len)
       {
         DBUG_PRINT("info", ("WITH_PARTITION_STORAGE_ENGINE is not defined"));
-        my_free(buff, MYF(0));
         goto err;
       }
 #endif
@@ -737,21 +735,43 @@ static int open_binary_frm(THD *thd, TAB
         {
           DBUG_PRINT("error",
                      ("fulltext key uses parser that is not defined in .frm"));
-          my_free(buff, MYF(0));
           goto err;
         }
         parser_name.str= next_chunk;
         parser_name.length= strlen(next_chunk);
+        next_chunk+= (parser_name.length + 1);
         keyinfo->parser= plugin_lock(&parser_name, MYSQL_FTPARSER_PLUGIN);
         if (! keyinfo->parser)
         {
           my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), parser_name.str);
-          my_free(buff, MYF(0));
           goto err;
         }
       }
     }
-    my_free(buff, MYF(0));
+    DBUG_ASSERT (next_chunk <= buff_end);
+    {
+      if ((char*)next_chunk >= buff_end)
+      {
+        DBUG_PRINT("info", ("Found no field extra info"));
+        abort();
+      }
+      else
+      {
+        DBUG_PRINT("info", ("Found field extra info"));
+        const uint format_section_header_size= 8;
+        uint format_section_len= uint2korr(next_chunk+0);
+        uint flags=              uint4korr(next_chunk+2);
+
+        share->default_storage_media= (enum ha_storage_media) (flags & 0x7);
+
+        char *tablespace= next_chunk + format_section_header_size;
+        uint tablespace_len= strlen(tablespace);
+
+        field_extra_info= next_chunk + format_section_header_size + tablespace_len + 1;
+        next_chunk+= format_section_len;
+      }
+    }
+    DBUG_ASSERT (next_chunk <= buff_end);
   }
   share->key_block_size= uint2korr(head+62);
 
@@ -894,10 +914,21 @@ static int open_binary_frm(THD *thd, TAB
   {
     uint pack_flag, interval_nr, unireg_type, recpos, field_length;
     enum_field_types field_type;
+    enum ha_storage_media storage_type= HA_SM_DEFAULT;
+    enum column_format_type column_format= COLUMN_FORMAT_TYPE_DEFAULT;
     CHARSET_INFO *charset=NULL;
     Field::geometry_type geom_type= Field::GEOM_GEOMETRY;
     LEX_STRING comment;
 
+    if (field_extra_info)
+    {
+      char tmp= field_extra_info[i];
+      storage_type= (enum ha_storage_media)(tmp & STORAGE_TYPE_MASK);
+      column_format= (enum column_format_type)
+                    ((tmp >> COLUMN_FORMAT_SHIFT) & COLUMN_FORMAT_MASK);
+      DBUG_PRINT("info", ("Field extra: storage %u format %u",
+                          storage_type, column_format));
+    }
     if (new_frm_ver >= 3)
     {
       /* new frm file in 4.1 */
@@ -1030,6 +1061,8 @@ static int open_binary_frm(THD *thd, TAB
       goto err;			/* purecov: inspected */
     }
 
+    reg_field->flags|= ((uint)storage_type << FIELD_STORAGE_FLAGS);
+    reg_field->flags|= ((uint)column_format << COLUMN_FORMAT_FLAGS);
     reg_field->field_index= i;
     reg_field->comment=comment;
     if (field_type == MYSQL_TYPE_BIT && !f_bit_as_char(pack_flag))
@@ -1321,9 +1354,13 @@ static int open_binary_frm(THD *thd, TAB
   if (use_hash)
     (void) hash_check(&share->name_hash);
 #endif
+  if (buff)
+    my_free(buff, MYF(0));
   DBUG_RETURN (0);
 
  err:
+  if (buff)
+    my_free(buff, MYF(0));
   share->error= error;
   share->open_errno= my_errno;
   share->errarg= errarg;
@@ -2216,6 +2253,7 @@ void update_create_info_from_table(HA_CR
   create_info->table_options= share->db_create_options;
   create_info->avg_row_length= share->avg_row_length;
   create_info->row_type= share->row_type;
+  create_info->default_storage_media= share->default_storage_media;
   create_info->default_table_charset= share->table_charset;
   create_info->table_charset= 0;
 

--- 1.166/sql/table.h	2007-05-17 12:02:48 +02:00
+++ 1.167/sql/table.h	2007-05-17 12:02:48 +02:00
@@ -174,6 +174,8 @@ typedef struct st_table_share
 
   handlerton *db_type;			/* table_type for handler */
   enum row_type row_type;		/* How rows are stored */
+  enum ha_storage_media default_storage_media;
+  const char *tablespace;
   enum tmp_table_type tmp_table;
 
   uint ref_count;                       /* How many TABLE objects uses this */

--- 1.100/sql/unireg.cc	2007-05-17 12:02:48 +02:00
+++ 1.101/sql/unireg.cc	2007-05-17 12:02:48 +02:00
@@ -86,6 +86,9 @@ bool mysql_create_frm(THD *thd, const ch
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   partition_info *part_info= thd->work_part_info;
 #endif
+  const uint format_section_header_size= 8;
+  uint format_section_len;
+  uint tablespace_len= 0;
   DBUG_ENTER("mysql_create_frm");
 
   DBUG_ASSERT(*fn_rext((char*)file_name)); // Check .frm extension
@@ -148,6 +151,16 @@ bool mysql_create_frm(THD *thd, const ch
     if (key_info[i].parser_name)
       create_info->extra_size+= key_info[i].parser_name->length + 1;
   }
+  /* Add space for storage type and field format array of fields */
+  {
+    if (create_info->tablespace)
+      tablespace_len= strlen(create_info->tablespace);
+    format_section_len=
+      format_section_header_size +
+      tablespace_len + 1 +
+      create_fields.elements;
+    create_info->extra_size+= format_section_len;
+  }
 
   if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo,
 		       create_info, keys)) < 0)
@@ -252,6 +265,49 @@ bool mysql_create_frm(THD *thd, const ch
     }
   }
 
+  /* Store storage type and field format array of fields */
+  {
+    /* prepare header */
+    {
+      uint flags= 0;
+      flags|= create_info->default_storage_media; //3 bits
+
+      bzero(buff, format_section_header_size);
+      /* length of section 2 bytes*/
+      int2store(buff+0, format_section_len);
+      /* flags of section 4 bytes*/
+      int4store(buff+2, flags);
+      /* 2 bytes left for future use */
+    }
+    /* write header */
+    {
+      if (my_write(file, buff, format_section_header_size, MYF_RW))
+        goto err;
+    }
+    /* write tablespace name */
+    {
+      if (tablespace_len > 0)
+        if (my_write(file, create_info->tablespace, tablespace_len, MYF_RW))
+          goto err;
+      buff[0]= 0;
+      if (my_write(file, buff, 1, MYF_RW))
+        goto err;
+    }
+    /* write column info, 1 byte per column */
+    {
+      List_iterator<create_field> it(create_fields);
+      create_field *field;
+      uchar storage_type, column_format, write_byte;
+      while ((field=it++))
+      {
+        storage_type= (uchar)field->field_storage_type & STORAGE_TYPE_MASK;
+        column_format= (uchar)field->column_format & COLUMN_FORMAT_MASK;
+        write_byte= storage_type + (column_format << COLUMN_FORMAT_SHIFT);
+        if (my_write(file, (const byte*)&write_byte, 1, MYF_RW))
+          goto err;
+      }
+    }
+  }
   VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
   if (my_write(file,(byte*) forminfo,288,MYF_RW) ||
       my_write(file,(byte*) screen_buff,info_length,MYF_RW) ||

--- 1.51/sql/unireg.h	2007-05-17 12:02:48 +02:00
+++ 1.52/sql/unireg.h	2007-05-17 12:02:48 +02:00
@@ -175,6 +175,10 @@
 
 #define DEFAULT_KEY_CACHE_NAME "default"
 
+#define STORAGE_TYPE_MASK 7
+#define COLUMN_FORMAT_MASK 7
+#define COLUMN_FORMAT_SHIFT 3
+
 /* Include prototypes for unireg */
 
 #include "mysqld_error.h"

--- 1.151/mysql-test/r/information_schema.result	2007-05-17 12:02:49 +02:00
+++ 1.152/mysql-test/r/information_schema.result	2007-05-17 12:02:49 +02:00
@@ -181,8 +181,8 @@ Field	Type	Collation	Null	Key	Default	Ex
 c	varchar(64)	utf8_general_ci	NO				select,insert,update,references	
 select * from information_schema.COLUMNS where table_name="t1"
 and column_name= "a";
-TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	COLUMN_NAME	ORDINAL_POSITION	COLUMN_DEFAULT	IS_NULLABLE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	CHARACTER_SET_NAME	COLLATION_NAME	COLUMN_TYPE	COLUMN_KEY	EXTRA	PRIVILEGES	COLUMN_COMMENT
-NULL	mysqltest	t1	a	1	NULL	YES	int	NULL	NULL	10	0	NULL	NULL	int(11)			select,insert,update,references	
+TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	COLUMN_NAME	ORDINAL_POSITION	COLUMN_DEFAULT	IS_NULLABLE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	CHARACTER_SET_NAME	COLLATION_NAME	COLUMN_TYPE	COLUMN_KEY	EXTRA	PRIVILEGES	COLUMN_COMMENT	COLUMN_STORAGE	COLUMN_FORMAT
+NULL	mysqltest	t1	a	1	NULL	YES	int	NULL	NULL	10	0	NULL	NULL	int(11)			select,insert,update,references		Default	Default
 show columns from mysqltest.t1 where field like "%a%";
 Field	Type	Null	Key	Default	Extra
 a	int(11)	YES		NULL	

--- 1.444/sql/ha_ndbcluster.cc	2007-05-17 12:02:49 +02:00
+++ 1.445/sql/ha_ndbcluster.cc	2007-05-17 12:02:49 +02:00
@@ -4641,14 +4641,16 @@ static int ndbcluster_rollback(handlerto
   NDB binary types without a character set.  This may change.
  */
 
-static int create_ndb_column(NDBCOL &col,
+static int create_ndb_column(THD *thd,
+                             NDBCOL &col,
                              Field *field,
-                             HA_CREATE_INFO *info)
+                             HA_CREATE_INFO *create_info)
 {
+  DBUG_ENTER("create_ndb_column");
   // Set name
   if (col.setName(field->field_name))
   {
-    return (my_errno= errno);
+    DBUG_RETURN(my_errno= errno);
   }
   // Get char set
   CHARSET_INFO *cs= field->charset();
@@ -4805,7 +4807,7 @@ static int create_ndb_column(NDBCOL &col
       }
       else
       {
-        return HA_ERR_UNSUPPORTED;
+        DBUG_RETURN(HA_ERR_UNSUPPORTED);
       }
       col.setLength(field->field_length);
     }
@@ -4904,7 +4906,7 @@ static int create_ndb_column(NDBCOL &col
     goto mysql_type_unsupported;
   mysql_type_unsupported:
   default:
-    return HA_ERR_UNSUPPORTED;
+    DBUG_RETURN(HA_ERR_UNSUPPORTED);
   }
   // Set nullable and pk
   col.setNullable(field->maybe_null());
@@ -4916,14 +4918,99 @@ static int create_ndb_column(NDBCOL &col
     char buff[22];
 #endif
     col.setAutoIncrement(TRUE);
-    ulonglong value= info->auto_increment_value ?
-      info->auto_increment_value : (ulonglong) 1;
+    ulonglong value= create_info->auto_increment_value ?
+      create_info->auto_increment_value : (ulonglong) 1;
     DBUG_PRINT("info", ("Autoincrement key, initial: %s", llstr(value, buff)));
     col.setAutoIncrementInitialValue(value);
   }
   else
     col.setAutoIncrement(FALSE);
-  return 0;
+ 
+  NDBCOL::StorageType type;
+  bool dynamic;
+
+  switch (field->field_storage_type()) {
+  case(HA_SM_DEFAULT):
+    if (create_info->default_storage_media == HA_SM_DISK)
+      type= NDBCOL::StorageTypeDisk;
+    else
+      type= NDBCOL::StorageTypeMemory;
+    break;
+  case(HA_SM_DISK):
+    type= NDBCOL::StorageTypeDisk;
+    break;
+  case(HA_SM_MEMORY):
+    type= NDBCOL::StorageTypeMemory;
+    break;
+  }
+
+  switch (field->column_format()) {
+  case(COLUMN_FORMAT_TYPE_FIXED):
+    dynamic= FALSE;
+    break;
+  case(COLUMN_FORMAT_TYPE_DYNAMIC):
+    dynamic= TRUE;
+    break;
+  case(COLUMN_FORMAT_TYPE_DEFAULT):
+  default:
+    if (create_info->row_type == ROW_TYPE_DEFAULT)
+    {
+      bool is_dynamic= field_type_forces_var_part(field->type());
+      dynamic= is_dynamic;
+    }
+    else
+      dynamic= create_info->row_type == ROW_TYPE_DYNAMIC;
+    break;
+  }
+  DBUG_PRINT("info", ("Column %s is declared %s", field->field_name,
+                      (dynamic) ? "dynamic" : "static"));
+  if (type == NDBCOL::StorageTypeDisk)
+  {
+    if (dynamic)
+    {
+      DBUG_PRINT("info", ("Dynamic disk stored column %s changed to static",
+                          field->field_name));
+      dynamic= false;
+    }
+    if (thd && field->column_format() == COLUMN_FORMAT_TYPE_DYNAMIC)
+    {
+      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                          ER_ILLEGAL_HA_CREATE_OPTION,
+                          "DYNAMIC column %s with "
+                          "STORAGE DISK is not supported, "
+                          "column will become FIXED",
+                          field->field_name);
+    }
+  }
+
+  switch (create_info->row_type) {
+  case ROW_TYPE_FIXED:
+    if (thd && 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;
+  }
+
+  col.setStorageType(type);
+#ifdef NOT_YET
+  col.setDynamic(dynamic);
+#endif
+
+  DBUG_RETURN(0);
 }
 
 /*
@@ -4942,6 +5029,7 @@ int ha_ndbcluster::create(const char *na
   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];
+  bool use_disk= FALSE;
   NdbDictionary::Table::SingleUserMode single_user_mode= NdbDictionary::Table::SingleUserModeLocked;
 
   DBUG_ENTER("ha_ndbcluster::create");
@@ -5028,32 +5116,6 @@ int ha_ndbcluster::create(const char *na
   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 
@@ -5081,38 +5143,19 @@ int ha_ndbcluster::create(const char *na
   for (i= 0; i < form->s->fields; i++) 
   {
     Field *field= form->field[i];
-    DBUG_PRINT("info", ("name: %s  type: %u  pack_length: %d", 
+    DBUG_PRINT("info", ("name: %s  type: %u  storage: %u  format: %u  "
+                        "pack_length: %d", 
                         field->field_name, field->real_type(),
+                        field->field_storage_type(),
+                        field->column_format(),
                         field->pack_length()));
-    if ((my_errno= create_ndb_column(col, field, create_info)))
+    if ((my_errno= create_ndb_column(thd, col, field, create_info)))
       DBUG_RETURN(my_errno);
- 
-    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;
-    }
+    if (!use_disk &&
+        col.getStorageType() == NDBCOL::StorageTypeDisk)
+      use_disk= TRUE;
+
     if (tab.addColumn(col))
     {
       DBUG_RETURN(my_errno= errno);
@@ -5121,14 +5164,40 @@ int ha_ndbcluster::create(const char *na
       pk_length += (field->pack_length() + 3) / 4;
   }
 
+  if (use_disk)
+  { 
+    if (create_info->tablespace)
+      tab.setTablespaceName(create_info->tablespace);
+    else
+      tab.setTablespaceName("DEFAULT-TS");
+  }
+
+  DBUG_PRINT("info", ("Table %s is %s stored with tables space %s",
+                      m_tabname,
+                      (use_disk) ? "disk" : "memory",
+                      (use_disk) ? tab.getTablespaceName() : "N/A"));
+ 
   KEY* key_info;
   for (i= 0, key_info= form->key_info; i < form->s->keys; i++, key_info++)
   {
     KEY_PART_INFO *key_part= key_info->key_part;
     KEY_PART_INFO *end= key_part + key_info->key_parts;
     for (; key_part != end; key_part++)
+    {
+      if (key_part->field->field_storage_type() == HA_SM_DISK)
+      {
+        push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+                            ER_ILLEGAL_HA_CREATE_OPTION,
+                            ER(ER_ILLEGAL_HA_CREATE_OPTION),
+                            ndbcluster_hton_name,
+                            "Index on field "
+                            "declared with "
+                            "STORAGE DISK is not supported");
+        DBUG_RETURN(HA_ERR_UNSUPPORTED);
+      }
       tab.getColumn(key_part->fieldnr-1)->setStorageType(
                              NdbDictionary::Column::StorageTypeMemory);
+    }
   }
 
   // No primary key, create shadow key as 64 bit, auto increment  
@@ -5503,6 +5572,17 @@ int ha_ndbcluster::create_ndb_index(cons
   for (; key_part != end; key_part++) 
   {
     Field *field= key_part->field;
+    if (field->field_storage_type() == HA_SM_DISK)
+    {
+      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+                          ER_ILLEGAL_HA_CREATE_OPTION,
+                          ER(ER_ILLEGAL_HA_CREATE_OPTION),
+                          ndbcluster_hton_name,
+                          "Index on field "
+                          "declared with "
+                          "STORAGE DISK is not supported");
+      DBUG_RETURN(HA_ERR_UNSUPPORTED);
+    }
     DBUG_PRINT("info", ("attr: %s", field->field_name));
     if (ndb_index.addColumnName(field->field_name))
     {
@@ -9589,6 +9669,7 @@ bool ha_ndbcluster::check_if_incompatibl
   DBUG_ENTER("ha_ndbcluster::check_if_incompatible_data");
   uint i;
   const NDBTAB *tab= (const NDBTAB *) m_table;
+  NDBCOL new_col;
 
   if (current_thd->variables.ndb_use_copying_alter_table)
   {
@@ -9599,17 +9680,13 @@ bool ha_ndbcluster::check_if_incompatibl
   int pk= 0;
   int ai= 0;
 
-  if (create_info->tablespace)
-    create_info->storage_media = HA_SM_DISK;
-  else
-    create_info->storage_media = HA_SM_MEMORY;
-
   for (i= 0; i < table->s->fields; i++) 
   {
     Field *field= table->field[i];
     const NDBCOL *col= tab->getColumn(i);
-    if (col->getStorageType() == NDB_STORAGETYPE_MEMORY && create_info->storage_media != HA_SM_MEMORY ||
-        col->getStorageType() == NDB_STORAGETYPE_DISK && create_info->storage_media != HA_SM_DISK)
+
+    create_ndb_column(0, new_col, field, create_info);
+    if (col->getStorageType() != new_col.getStorageType())
     {
       DBUG_PRINT("info", ("Column storage media is changed"));
       DBUG_RETURN(COMPATIBLE_DATA_NO);
@@ -9633,31 +9710,15 @@ bool ha_ndbcluster::check_if_incompatibl
       ai=1;
   }
 
-  char tablespace_name[FN_LEN]; 
-  if (get_tablespace_name(current_thd, tablespace_name, FN_LEN))
-  {
-    if (create_info->tablespace) 
-    {
-      if (strcmp(create_info->tablespace, tablespace_name))
-      {
-        DBUG_PRINT("info", ("storage media is changed, old tablespace=%s, new tablespace=%s",
-          tablespace_name, create_info->tablespace));
-        DBUG_RETURN(COMPATIBLE_DATA_NO);
-      }
-    }
-    else
-    {
-      DBUG_PRINT("info", ("storage media is changed, old is DISK and tablespace=%s, new is MEM",
-        tablespace_name));
-      DBUG_RETURN(COMPATIBLE_DATA_NO);
-    }
-  }
-  else
+  char tablespace_name[FN_LEN];
+  if (get_tablespace_name(current_thd, tablespace_name, FN_LEN) != create_info->tablespace)
   {
-    if (create_info->storage_media != HA_SM_MEMORY)
+    if (get_tablespace_name(current_thd, tablespace_name, FN_LEN) == 0 ||
+        create_info->tablespace == 0 ||
+        strcmp(create_info->tablespace, tablespace_name))
     {
-      DBUG_PRINT("info", ("storage media is changed, old is MEM, new is DISK and tablespace=%s",
-        create_info->tablespace));
+      DBUG_PRINT("info", ("storage media is changed, old tablespace=%s, new tablespace=%s",
+                          tablespace_name, create_info->tablespace));
       DBUG_RETURN(COMPATIBLE_DATA_NO);
     }
   }

--- 1.44/mysql-test/r/join.result	2007-05-17 12:02:49 +02:00
+++ 1.45/mysql-test/r/join.result	2007-05-17 12:02:49 +02:00
@@ -699,9 +699,9 @@ select * from v1a join v1b on t1.b = t2.
 ERROR 42S22: Unknown column 't1.b' in 'on clause'
 select * from information_schema.statistics join information_schema.columns
 using(table_name,column_name) where table_name='user';
-TABLE_NAME	COLUMN_NAME	TABLE_CATALOG	TABLE_SCHEMA	NON_UNIQUE	INDEX_SCHEMA	INDEX_NAME	SEQ_IN_INDEX	COLLATION	CARDINALITY	SUB_PART	PACKED	NULLABLE	INDEX_TYPE	COMMENT	TABLE_CATALOG	TABLE_SCHEMA	ORDINAL_POSITION	COLUMN_DEFAULT	IS_NULLABLE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	CHARACTER_SET_NAME	COLLATION_NAME	COLUMN_TYPE	COLUMN_KEY	EXTRA	PRIVILEGES	COLUMN_COMMENT
-user	Host	NULL	mysql	0	mysql	PRIMARY	1	A	NULL	NULL	NULL		BTREE		NULL	mysql	1		NO	char	60	180	NULL	NULL	utf8	utf8_bin	char(60)	PRI		#	
-user	User	NULL	mysql	0	mysql	PRIMARY	2	A	3	NULL	NULL		BTREE		NULL	mysql	2		NO	char	16	48	NULL	NULL	utf8	utf8_bin	char(16)	PRI		#	
+TABLE_NAME	COLUMN_NAME	TABLE_CATALOG	TABLE_SCHEMA	NON_UNIQUE	INDEX_SCHEMA	INDEX_NAME	SEQ_IN_INDEX	COLLATION	CARDINALITY	SUB_PART	PACKED	NULLABLE	INDEX_TYPE	COMMENT	TABLE_CATALOG	TABLE_SCHEMA	ORDINAL_POSITION	COLUMN_DEFAULT	IS_NULLABLE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	CHARACTER_SET_NAME	COLLATION_NAME	COLUMN_TYPE	COLUMN_KEY	EXTRA	PRIVILEGES	COLUMN_COMMENT	COLUMN_STORAGE	COLUMN_FORMAT
+user	Host	NULL	mysql	0	mysql	PRIMARY	1	A	NULL	NULL	NULL		BTREE		NULL	mysql	1		NO	char	60	180	NULL	NULL	utf8	utf8_bin	char(60)	PRI		#		Default	Default
+user	User	NULL	mysql	0	mysql	PRIMARY	2	A	3	NULL	NULL		BTREE		NULL	mysql	2		NO	char	16	48	NULL	NULL	utf8	utf8_bin	char(16)	PRI		#		Default	Default
 drop table t1;
 drop table t2;
 drop table t3;

--- 1.268/mysql-test/r/sp.result	2007-05-17 12:02:49 +02:00
+++ 1.269/mysql-test/r/sp.result	2007-05-17 12:02:49 +02:00
@@ -2450,9 +2450,9 @@ end|
 call bug4902()|
 Charset	Description	Default collation	Maxlen
 Collation	Charset	Id	Default	Compiled	Sortlen
-Type	Size	Min_Value	Max_Value	Prec	Scale	Nullable	Auto_Increment	Unsigned	Zerofill	Searchable	Case_Sensitive	Default	Comment
-tinyint	1	-128	127	0	0	YES	YES	NO	YES	YES	NO	NULL,0	A very small integer
-tinyint unsigned	1	0	255	0	0	YES	YES	YES	YES	YES	NO	NULL,0	A very small integer
+Type	Size	Min_Value	Max_Value	Prec	Scale	Nullable	Auto_Increment	Unsigned	Zerofill	Searchable	Case_Sensitive	Default	Comment	Storage	Format
+tinyint	1	-128	127	0	0	YES	YES	NO	YES	YES	NO	NULL,0	A very small integer	Default	Default
+tinyint unsigned	1	0	255	0	0	YES	YES	YES	YES	YES	NO	NULL,0	A very small integer	Default	Default
 Table	Create Table
 t1	CREATE TABLE `t1` (
   `id` char(16) NOT NULL DEFAULT '',
@@ -2504,9 +2504,9 @@ Level	Code	Message
 call bug4902()|
 Charset	Description	Default collation	Maxlen
 Collation	Charset	Id	Default	Compiled	Sortlen
-Type	Size	Min_Value	Max_Value	Prec	Scale	Nullable	Auto_Increment	Unsigned	Zerofill	Searchable	Case_Sensitive	Default	Comment
-tinyint	1	-128	127	0	0	YES	YES	NO	YES	YES	NO	NULL,0	A very small integer
-tinyint unsigned	1	0	255	0	0	YES	YES	YES	YES	YES	NO	NULL,0	A very small integer
+Type	Size	Min_Value	Max_Value	Prec	Scale	Nullable	Auto_Increment	Unsigned	Zerofill	Searchable	Case_Sensitive	Default	Comment	Storage	Format
+tinyint	1	-128	127	0	0	YES	YES	NO	YES	YES	NO	NULL,0	A very small integer	Default	Default
+tinyint unsigned	1	0	255	0	0	YES	YES	YES	YES	YES	NO	NULL,0	A very small integer	Default	Default
 Table	Create Table
 t1	CREATE TABLE `t1` (
   `id` char(16) NOT NULL DEFAULT '',

--- 1.266/sql/sp_head.cc	2007-05-17 12:02:49 +02:00
+++ 1.267/sql/sp_head.cc	2007-05-17 12:02:49 +02:00
@@ -1959,7 +1959,9 @@ sp_head::fill_field_definition(THD *thd,
                       &lex->interval_list,
                       (lex->charset ? lex->charset :
                                       sp_db_info.default_table_charset),
-                      lex->uint_geom_type))
+                      lex->uint_geom_type,
+                      (enum ha_storage_media)0,
+                      (enum column_format_type)0))
     return TRUE;
 
   if (field_def->interval_list.elements)
Thread
bk commit into 5.1 tree (mskold:1.2492)Martin Skold17 May