List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:March 4 2011 9:55am
Subject:bzr commit into mysql-5.5-telco-7.0 branch (magnus.blaudd:3220) WL#3627
View as plain text  
#At file:///data0/magnus/mysql/format_section/5.5-telco-7.0/ based on revid:magnus.blaudd@stripped7-ubkb844t7285ynhx

 3220 Magnus Blåudd	2011-03-04
      WL#3627 Add COLUMN_FORMAT and STORAGE on field level
        
       - Extend parser to allow to specify COLUMN_FORMAT [DEFAULT|FIXED|DYNAMIC]
         and STORAGE [DEFAULT|DISK|MEMORY] for each column in a table.
       - Reserve and use 2 bits for each of these attributes(total 4 bits) among the
         flag bits used in both Create_field::flags and Field::flags, this
         way the two new attributes are automatically copied around with
         the other flags for a field.
       - Add printouts of which COLUMN_FORMAT and STORAGE each
         field have in SHOW CREATE TABLE. Using 5.1.20 as version
         guard since that is when MySQL Cluster added it.
       - Add testcase for COLUMN_FORMAT and STORAGE
       - Update .result file for test of reading the 7.0.22 MySQL Cluster
         table since all the info therein is now shown.

    modified:
      mysql-test/r/tablespace.result
      mysql-test/t/tablespace.test
      sql/field.h
      sql/ha_ndbcluster_glue.h
      sql/handler.h
      sql/lex.h
      sql/sql_show.cc
      sql/sql_yacc.yy
      sql/table.cc
      sql/unireg.cc
=== modified file 'mysql-test/r/tablespace.result'
--- a/mysql-test/r/tablespace.result	2011-03-04 08:52:27 +0000
+++ b/mysql-test/r/tablespace.result	2011-03-04 09:53:26 +0000
@@ -98,15 +98,72 @@ Table	Create Table
 t1	CREATE TABLE `t1` (
   `a` int(11) NOT NULL,
   `b` int(11) DEFAULT NULL,
-  `c` int(11) DEFAULT NULL,
-  `d` int(11) NOT NULL,
-  `e` int(11) DEFAULT NULL,
-  `f` int(11) DEFAULT NULL,
+  `c` int(11) /*!50602 STORAGE DISK */ DEFAULT NULL,
+  `d` int(11) NOT NULL /*!50602 STORAGE MEMORY */,
+  `e` int(11) /*!50602 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `f` int(11) /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
   `g` int(11) DEFAULT NULL,
-  `h` int(11) NOT NULL,
-  `i` int(11) DEFAULT NULL,
-  `j` int(11) DEFAULT NULL,
-  `k` int(11) DEFAULT NULL,
+  `h` int(11) NOT NULL /*!50602 STORAGE DISK */ /*!50602 COLUMN_FORMAT DYNAMIC */,
+  `i` int(11) /*!50602 STORAGE MEMORY */ /*!50602 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `j` int(11) /*!50602 STORAGE DISK */ /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `k` int(11) /*!50602 STORAGE MEMORY */ /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
   PRIMARY KEY (`a`)
 ) /*!50100 TABLESPACE the_tablespacename STORAGE DISK */ ENGINE=MyISAM DEFAULT CHARSET=latin1
 DROP TABLE t1;
+CREATE TABLE t1 (
+a int STORAGE DISK,
+b int STORAGE MEMORY NOT NULL,
+c int COLUMN_FORMAT DYNAMIC,
+d int COLUMN_FORMAT FIXED,
+e int COLUMN_FORMAT DEFAULT,
+f int STORAGE DISK COLUMN_FORMAT DYNAMIC NOT NULL,
+g int STORAGE MEMORY COLUMN_FORMAT DYNAMIC,
+h int STORAGE DISK COLUMN_FORMAT FIXED,
+i int STORAGE MEMORY COLUMN_FORMAT FIXED
+);
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) /*!50602 STORAGE DISK */ DEFAULT NULL,
+  `b` int(11) NOT NULL /*!50602 STORAGE MEMORY */,
+  `c` int(11) /*!50602 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `d` int(11) /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `e` int(11) DEFAULT NULL,
+  `f` int(11) NOT NULL /*!50602 STORAGE DISK */ /*!50602 COLUMN_FORMAT DYNAMIC */,
+  `g` int(11) /*!50602 STORAGE MEMORY */ /*!50602 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `h` int(11) /*!50602 STORAGE DISK */ /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `i` int(11) /*!50602 STORAGE MEMORY */ /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+ALTER TABLE t1
+ADD COLUMN j int STORAGE DISK,
+ADD COLUMN k int STORAGE MEMORY NOT NULL,
+ADD COLUMN l int COLUMN_FORMAT DYNAMIC,
+ADD COLUMN m int COLUMN_FORMAT FIXED,
+ADD COLUMN n int COLUMN_FORMAT DEFAULT,
+ADD COLUMN o int STORAGE DISK COLUMN_FORMAT DYNAMIC NOT NULL,
+ADD COLUMN p int STORAGE MEMORY COLUMN_FORMAT DYNAMIC,
+ADD COLUMN q int STORAGE DISK COLUMN_FORMAT FIXED,
+ADD COLUMN r int STORAGE MEMORY COLUMN_FORMAT FIXED;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) /*!50602 STORAGE DISK */ DEFAULT NULL,
+  `b` int(11) NOT NULL /*!50602 STORAGE MEMORY */,
+  `c` int(11) /*!50602 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `d` int(11) /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `e` int(11) DEFAULT NULL,
+  `f` int(11) NOT NULL /*!50602 STORAGE DISK */ /*!50602 COLUMN_FORMAT DYNAMIC */,
+  `g` int(11) /*!50602 STORAGE MEMORY */ /*!50602 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `h` int(11) /*!50602 STORAGE DISK */ /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `i` int(11) /*!50602 STORAGE MEMORY */ /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `j` int(11) /*!50602 STORAGE DISK */ DEFAULT NULL,
+  `k` int(11) NOT NULL /*!50602 STORAGE MEMORY */,
+  `l` int(11) /*!50602 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `m` int(11) /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `n` int(11) DEFAULT NULL,
+  `o` int(11) NOT NULL /*!50602 STORAGE DISK */ /*!50602 COLUMN_FORMAT DYNAMIC */,
+  `p` int(11) /*!50602 STORAGE MEMORY */ /*!50602 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `q` int(11) /*!50602 STORAGE DISK */ /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `r` int(11) /*!50602 STORAGE MEMORY */ /*!50602 COLUMN_FORMAT FIXED */ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;

=== modified file 'mysql-test/t/tablespace.test'
--- a/mysql-test/t/tablespace.test	2011-03-04 08:52:27 +0000
+++ b/mysql-test/t/tablespace.test	2011-03-04 09:53:26 +0000
@@ -120,3 +120,34 @@ copy_file std_data/cluster_7022_table.MY
 SHOW CREATE TABLE t1;
 
 DROP TABLE t1;
+
+#
+# WL#3627 Add COLUMN_FORMAT and STORAGE for fields
+#
+
+CREATE TABLE t1 (
+ a int STORAGE DISK,
+ b int STORAGE MEMORY NOT NULL,
+ c int COLUMN_FORMAT DYNAMIC,
+ d int COLUMN_FORMAT FIXED,
+ e int COLUMN_FORMAT DEFAULT,
+ f int STORAGE DISK COLUMN_FORMAT DYNAMIC NOT NULL,
+ g int STORAGE MEMORY COLUMN_FORMAT DYNAMIC,
+ h int STORAGE DISK COLUMN_FORMAT FIXED,
+ i int STORAGE MEMORY COLUMN_FORMAT FIXED
+);
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1
+  ADD COLUMN j int STORAGE DISK,
+  ADD COLUMN k int STORAGE MEMORY NOT NULL,
+  ADD COLUMN l int COLUMN_FORMAT DYNAMIC,
+  ADD COLUMN m int COLUMN_FORMAT FIXED,
+  ADD COLUMN n int COLUMN_FORMAT DEFAULT,
+  ADD COLUMN o int STORAGE DISK COLUMN_FORMAT DYNAMIC NOT NULL,
+  ADD COLUMN p int STORAGE MEMORY COLUMN_FORMAT DYNAMIC,
+  ADD COLUMN q int STORAGE DISK COLUMN_FORMAT FIXED,
+  ADD COLUMN r int STORAGE MEMORY COLUMN_FORMAT FIXED;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;

=== modified file 'sql/field.h'
--- a/sql/field.h	2010-10-27 11:32:32 +0000
+++ b/sql/field.h	2011-03-04 09:53:26 +0000
@@ -509,6 +509,31 @@ public:
     DBUG_ASSERT(0);
     return GEOM_GEOMETRY;
   }
+
+#ifndef MCP_WL3627
+  ha_storage_media field_storage_type() const
+  {
+    return (ha_storage_media)
+      ((flags >> FIELD_FLAGS_STORAGE_MEDIA) & 3);
+  }
+
+  void set_storage_type(ha_storage_media storage_type)
+  {
+    flags |= (storage_type << FIELD_FLAGS_STORAGE_MEDIA);
+  }
+
+  column_format_type column_format() const
+  {
+    return (column_format_type)
+      ((flags >> FIELD_FLAGS_COLUMN_FORMAT) & 3);
+  }
+
+  void set_column_format(column_format_type column_format)
+  {
+    flags |= (column_format << FIELD_FLAGS_COLUMN_FORMAT);
+  }
+#endif
+
   /* Hash value */
   virtual void hash(ulong *nr, ulong *nr2);
   friend int cre_myisam(char * name, register TABLE *form, uint options,
@@ -2118,6 +2143,20 @@ public:
   {
     return (flags & (BINCMP_FLAG | BINARY_FLAG)) != 0;
   }
+
+#ifndef MCP_WL3627
+  ha_storage_media field_storage_type() const
+  {
+    return (ha_storage_media)
+      ((flags >> FIELD_FLAGS_STORAGE_MEDIA) & 3);
+  }
+
+  column_format_type column_format() const
+  {
+    return (column_format_type)
+      ((flags >> FIELD_FLAGS_COLUMN_FORMAT) & 3);
+  }
+#endif
 };
 
 

=== modified file 'sql/ha_ndbcluster_glue.h'
--- a/sql/ha_ndbcluster_glue.h	2011-02-09 11:28:03 +0000
+++ b/sql/ha_ndbcluster_glue.h	2011-03-04 09:53:26 +0000
@@ -67,16 +67,6 @@ bool close_cached_tables(THD *thd, TABLE
 /* Online alter table not supported */
 #define NDB_WITHOUT_ONLINE_ALTER
 
-/* Column format not supported */
-#define NDB_WITHOUT_COLUMN_FORMAT
-
-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
-};
-
 /* Tablespace in .frm and TABLE_SHARE->tablespace not supported */
 #define NDB_WITHOUT_TABLESPACE_IN_FRM
 

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2011-03-04 08:52:27 +0000
+++ b/sql/handler.h	2011-03-04 09:53:26 +0000
@@ -322,6 +322,14 @@ enum row_type { ROW_TYPE_NOT_USED=-1, RO
                 /** Unused. Reserved for future versions. */
                 ROW_TYPE_PAGE };
 
+#ifndef MCP_WL3627
+enum column_format_type {
+  COLUMN_FORMAT_TYPE_DEFAULT=   0,
+  COLUMN_FORMAT_TYPE_FIXED=     1,
+  COLUMN_FORMAT_TYPE_DYNAMIC=   2
+};
+#endif
+
 enum enum_binlog_func {
   BFN_RESET_LOGS=        1,
   BFN_RESET_SLAVE=       2,

=== modified file 'sql/lex.h'
--- a/sql/lex.h	2010-11-29 14:38:44 +0000
+++ b/sql/lex.h	2011-03-04 09:53:26 +0000
@@ -117,6 +117,9 @@ static SYMBOL symbols[] = {
   { "COLLATE",		SYM(COLLATE_SYM)},
   { "COLLATION",	SYM(COLLATION_SYM)},
   { "COLUMN",		SYM(COLUMN_SYM)},
+#ifndef MCP_WL3627
+  { "COLUMN_FORMAT",	SYM(COLUMN_FORMAT_SYM)},
+#endif
   { "COLUMN_NAME",      SYM(COLUMN_NAME_SYM)},
   { "COLUMNS",		SYM(COLUMNS)},
   { "COMMENT",		SYM(COMMENT_SYM)},

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-03-04 08:52:27 +0000
+++ b/sql/sql_show.cc	2011-03-04 09:53:26 +0000
@@ -1267,6 +1267,30 @@ int store_create_info(THD *thd, TABLE_LI
       packet->append(STRING_WITH_LEN(" NULL"));
     }
 
+#ifndef MCP_WL3627
+    switch(field->field_storage_type()){
+    case HA_SM_DISK:
+      packet->append(STRING_WITH_LEN(" /*!50120 STORAGE DISK */"));
+      break;
+    case HA_SM_MEMORY:
+      packet->append(STRING_WITH_LEN(" /*!50120 STORAGE MEMORY */"));
+      break;
+    default:
+      break;
+    }
+
+    switch(field->column_format()){
+    case COLUMN_FORMAT_TYPE_FIXED:
+      packet->append(STRING_WITH_LEN(" /*!50120 COLUMN_FORMAT FIXED */"));
+      break;
+    case COLUMN_FORMAT_TYPE_DYNAMIC:
+      packet->append(STRING_WITH_LEN(" /*!50120 COLUMN_FORMAT DYNAMIC */"));
+      break;
+    default:
+      break;
+    }
+#endif
+
     if (get_field_default_value(thd, table->timestamp_field,
                                 field, &def_value, 1))
     {

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2010-11-29 14:38:44 +0000
+++ b/sql/sql_yacc.yy	2011-03-04 09:53:26 +0000
@@ -871,6 +871,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  COLLATION_SYM                 /* SQL-2003-N */
 %token  COLUMNS
 %token  COLUMN_SYM                    /* SQL-2003-R */
+%token  COLUMN_FORMAT_SYM /* MCP_WL3627 */
 %token  COLUMN_NAME_SYM               /* SQL-2003-N */
 %token  COMMENT_SYM
 %token  COMMITTED_SYM                 /* SQL-2003-N */
@@ -5718,6 +5719,35 @@ attribute:
               Lex->charset=$2;
             }
           }
+/* MCP_WL3627 -> */
+        | COLUMN_FORMAT_SYM DEFAULT
+          {
+            Lex->type|=
+              (COLUMN_FORMAT_TYPE_DEFAULT << FIELD_FLAGS_COLUMN_FORMAT);
+          }
+        | COLUMN_FORMAT_SYM FIXED_SYM
+          {
+            Lex->type|=
+              (COLUMN_FORMAT_TYPE_FIXED << FIELD_FLAGS_COLUMN_FORMAT);
+          }
+        | COLUMN_FORMAT_SYM DYNAMIC_SYM
+          {
+            Lex->type|=
+              (COLUMN_FORMAT_TYPE_DYNAMIC << FIELD_FLAGS_COLUMN_FORMAT);
+          }
+        | STORAGE_SYM DEFAULT
+          {
+            Lex->type|= (HA_SM_DEFAULT << FIELD_FLAGS_STORAGE_MEDIA);
+          }
+        | STORAGE_SYM DISK_SYM
+          {
+            Lex->type|= (HA_SM_DISK << FIELD_FLAGS_STORAGE_MEDIA);
+          }
+        | STORAGE_SYM MEMORY_SYM
+          {
+            Lex->type|= (HA_SM_MEMORY << FIELD_FLAGS_STORAGE_MEDIA);
+          }
+/* MCP_WL3627 <- */
         ;
 
 
@@ -12448,6 +12478,7 @@ keyword_sp:
         | CODE_SYM                 {}
         | COLLATION_SYM            {}
         | COLUMN_NAME_SYM          {}
+        | COLUMN_FORMAT_SYM        {} /* MCP_WL3627 */
         | COLUMNS                  {}
         | COMMITTED_SYM            {}
         | COMPACT_SYM              {}

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-03-04 08:52:27 +0000
+++ b/sql/table.cc	2011-03-04 09:53:26 +0000
@@ -1492,8 +1492,13 @@ static int open_binary_frm(THD *thd, TAB
         ((field_flags >> COLUMN_FORMAT_SHIFT)& STORAGE_TYPE_MASK);
       DBUG_PRINT("debug", ("field flags: %u, storage: %u, column_format: %u",
                            field_flags, field_storage, field_column_format));
+#ifndef MCP_WL3627
+      reg_field->set_storage_type((ha_storage_media)field_storage);
+      reg_field->set_column_format((column_format_type)field_column_format);
+#else
       (void)field_storage; /* Reserved by and used in MySQL Cluster */
       (void)field_column_format; /* Reserved by and used in MySQL Cluster */
+#endif
     }
   }
   *field_ptr=0;					// End marker

=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc	2011-03-04 08:52:27 +0000
+++ b/sql/unireg.cc	2011-03-04 09:53:26 +0000
@@ -397,8 +397,13 @@ bool mysql_create_frm(THD *thd, const ch
     List_iterator<Create_field> it(create_fields);
     while ((field=it++))
     {
+#ifndef MCP_WL3627
+      const uchar field_storage= field->field_storage_type();
+      const uchar field_column_format= field->column_format();
+#else
       const uchar field_storage= 0; /* Used in MySQL Cluster */
       const uchar field_column_format= 0; /* Used in MySQL Cluster */
+#endif
       const uchar field_flags=
         field_storage + (field_column_format << COLUMN_FORMAT_SHIFT);
       *ptr= field_flags;

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@oracle.com-20110304095326-6e727gbjhktj4zsv.bundle
Thread
bzr commit into mysql-5.5-telco-7.0 branch (magnus.blaudd:3220) WL#3627Magnus Blåudd4 Mar